@pie-element/categorize 6.9.16 → 6.9.19
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 +24 -0
- package/configure/CHANGELOG.md +24 -0
- package/configure/lib/design/buttons.js +4 -2
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/index.js +53 -5
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +14 -4
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/index.js +25 -5
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +14 -4
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +6 -3
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +6 -3
- package/configure/lib/design/input-header.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 +8 -0
- package/controller/lib/index.js +80 -0
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +15 -0
- package/docs/config-schema.json.md +12 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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
|
+
## [6.9.19](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize@6.9.18...@pie-element/categorize@6.9.19) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/categorize
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [6.9.18](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize@6.9.17...@pie-element/categorize@6.9.18) (2022-05-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/categorize
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [6.9.17](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize@6.9.16...@pie-element/categorize@6.9.17) (2022-05-03)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/categorize
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [6.9.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize@6.9.15...@pie-element/categorize@6.9.16) (2022-04-12)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @pie-element/categorize
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.4.23](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-configure@5.4.22...@pie-element/categorize-configure@5.4.23) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/categorize-configure
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [5.4.22](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-configure@5.4.21...@pie-element/categorize-configure@5.4.22) (2022-05-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/categorize-configure
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [5.4.21](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-configure@5.4.20...@pie-element/categorize-configure@5.4.21) (2022-05-03)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/categorize-configure
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [5.4.20](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-configure@5.4.19...@pie-element/categorize-configure@5.4.20) (2022-04-12)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @pie-element/categorize-configure
|
|
@@ -99,12 +99,14 @@ var DeleteButton = (0, _styles.withStyles)(function () {
|
|
|
99
99
|
})(function (_ref) {
|
|
100
100
|
var classes = _ref.classes,
|
|
101
101
|
label = _ref.label,
|
|
102
|
-
onClick = _ref.onClick
|
|
102
|
+
onClick = _ref.onClick,
|
|
103
|
+
disabled = _ref.disabled;
|
|
103
104
|
return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
104
105
|
className: classes.deleteButton,
|
|
105
106
|
onClick: onClick,
|
|
106
107
|
size: "small",
|
|
107
|
-
color: "primary"
|
|
108
|
+
color: "primary",
|
|
109
|
+
disabled: disabled
|
|
108
110
|
}, label);
|
|
109
111
|
});
|
|
110
112
|
exports.DeleteButton = DeleteButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/design/buttons.jsx"],"names":["RawAddButton","props","classes","className","label","onClick","disabled","addButton","React","Component","PropTypes","object","isRequired","string","func","bool","styles","theme","height","spacing","unit","AddButton","DeleteButton","deleteButton","margin","padding","Divider","divider","marginTop","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,Y;;;;;;;;;;;;WAaX,kBAAS;AACP,wBAAyD,KAAKC,KAA9D;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BC,KAA5B,eAA4BA,KAA5B;AAAA,UAAmCC,OAAnC,eAAmCA,OAAnC;AAAA,UAA4CC,QAA5C,eAA4CA,QAA5C;AACA,0BACE,gCAAC,kBAAD;AACE,QAAA,OAAO,EAAED,OADX;AAEE,QAAA,QAAQ,EAAEC,QAFZ;AAGE,QAAA,SAAS,EAAE,4BAAWJ,OAAO,CAACK,SAAnB,EAA8BJ,SAA9B,CAHb;AAIE,QAAA,IAAI,EAAC,OAJP;AAKE,QAAA,OAAO,EAAC,WALV;AAME,QAAA,KAAK,EAAC;AANR,SAQGC,KARH,CADF;AAYD;;;EA3B+BI,kBAAMC,S;;;iCAA3BT,Y,eACQ;AACjBE,EAAAA,OAAO,EAAEQ,sBAAUC,MAAV,CAAiBC,UADT;AAEjBT,EAAAA,SAAS,EAAEO,sBAAUG,MAFJ;AAGjBT,EAAAA,KAAK,EAAEM,sBAAUG,MAHA;AAIjBR,EAAAA,OAAO,EAAEK,sBAAUI,IAJF;AAKjBR,EAAAA,QAAQ,EAAEI,sBAAUK;AALH,C;iCADRf,Y,kBASW;AACpBI,EAAAA,KAAK,EAAE;AADa,C;;AAoBxB,IAAMY,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBV,IAAAA,SAAS,EAAE;AACTW,MAAAA,MAAM,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AADpB;AADY,GAAL;AAAA,CAApB;;AAMA,IAAMC,SAAS,GAAG,wBAAWL,MAAX,EAAmBhB,YAAnB,CAAlB;;AAEA,IAAMsB,YAAY,GAAG,wBAAW;AAAA,SAAO;AACrCC,IAAAA,YAAY,EAAE;AACZC,MAAAA,MAAM,EAAE,CADI;AAEZC,MAAAA,OAAO,EAAE;AAFG;AADuB,GAAP;AAAA,CAAX,EAKjB;AAAA,MAAGvB,OAAH,QAAGA,OAAH;AAAA,MAAYE,KAAZ,QAAYA,KAAZ;AAAA,MAAmBC,OAAnB,QAAmBA,OAAnB;AAAA,sBACF,gCAAC,kBAAD;AACE,IAAA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/design/buttons.jsx"],"names":["RawAddButton","props","classes","className","label","onClick","disabled","addButton","React","Component","PropTypes","object","isRequired","string","func","bool","styles","theme","height","spacing","unit","AddButton","DeleteButton","deleteButton","margin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;AAAA,SAAO;AACrCC,IAAAA,YAAY,EAAE;AACZC,MAAAA,MAAM,EAAE,CADI;AAEZC,MAAAA,OAAO,EAAE;AAFG;AADuB,GAAP;AAAA,CAAX,EAKjB;AAAA,MAAGvB,OAAH,QAAGA,OAAH;AAAA,MAAYE,KAAZ,QAAYA,KAAZ;AAAA,MAAmBC,OAAnB,QAAmBA,OAAnB;AAAA,MAA4BC,QAA5B,QAA4BA,QAA5B;AAAA,sBACF,gCAAC,kBAAD;AACE,IAAA,SAAS,EAAEJ,OAAO,CAACqB,YADrB;AAEE,IAAA,OAAO,EAAElB,OAFX;AAGE,IAAA,IAAI,EAAC,OAHP;AAIE,IAAA,KAAK,EAAC,SAJR;AAKE,IAAA,QAAQ,EAAEC;AALZ,KAOGF,KAPH,CADE;AAAA,CALiB,CAArB;;AAiBA,IAAMsB,OAAO,GAAG,wBAAW,UAAAT,KAAK;AAAA,SAAK;AACnCU,IAAAA,OAAO,EAAE;AACPC,MAAAA,SAAS,EAAE,IAAIX,KAAK,CAACE,OAAN,CAAcC,IADtB;AAEPS,MAAAA,YAAY,EAAE,IAAIZ,KAAK,CAACE,OAAN,CAAcC;AAFzB;AAD0B,GAAL;AAAA,CAAhB,EAKZ;AAAA,MAAGlB,OAAH,SAAGA,OAAH;AAAA,sBAAiB,gCAAC,mBAAD;AAAY,IAAA,SAAS,EAAEA,OAAO,CAACyB;AAA/B,IAAjB;AAAA,CALY,CAAhB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport MuiDivider from '@material-ui/core/Divider';\n\nexport class RawAddButton extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n label: PropTypes.string,\n onClick: PropTypes.func,\n disabled: PropTypes.bool\n };\n\n static defaultProps = {\n label: 'Add'\n };\n\n render() {\n const { classes, className, label, onClick, disabled } = this.props;\n return (\n <Button\n onClick={onClick}\n disabled={disabled}\n className={classNames(classes.addButton, className)}\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n >\n {label}\n </Button>\n );\n }\n}\nconst styles = theme => ({\n addButton: {\n height: theme.spacing.unit * 4\n }\n});\n\nconst AddButton = withStyles(styles)(RawAddButton);\n\nconst DeleteButton = withStyles(() => ({\n deleteButton: {\n margin: 0,\n padding: 0\n }\n}))(({ classes, label, onClick, disabled }) => (\n <Button\n className={classes.deleteButton}\n onClick={onClick}\n size=\"small\"\n color=\"primary\"\n disabled={disabled}\n >\n {label}\n </Button>\n));\n\nconst Divider = withStyles(theme => ({\n divider: {\n marginTop: 2 * theme.spacing.unit,\n marginBottom: 2 * theme.spacing.unit\n }\n}))(({ classes }) => <MuiDivider className={classes.divider} />);\n\nexport { AddButton, DeleteButton, Divider };\n"],"file":"buttons.js"}
|
|
@@ -39,11 +39,17 @@ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
|
39
39
|
|
|
40
40
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
41
41
|
|
|
42
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
43
|
+
|
|
44
|
+
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
45
|
+
|
|
46
|
+
var _categorize = require("@pie-lib/categorize");
|
|
47
|
+
|
|
42
48
|
var _category = _interopRequireDefault(require("./category"));
|
|
43
49
|
|
|
44
50
|
var _header = _interopRequireDefault(require("../header"));
|
|
45
51
|
|
|
46
|
-
var
|
|
52
|
+
var _utils = require("../../utils");
|
|
47
53
|
|
|
48
54
|
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); }; }
|
|
49
55
|
|
|
@@ -73,6 +79,16 @@ var styles = function styles(theme) {
|
|
|
73
79
|
},
|
|
74
80
|
rowLabelHolder: {
|
|
75
81
|
width: '100%'
|
|
82
|
+
},
|
|
83
|
+
tooltip: {
|
|
84
|
+
fontSize: '12px',
|
|
85
|
+
whiteSpace: 'pre',
|
|
86
|
+
maxWidth: '500px'
|
|
87
|
+
},
|
|
88
|
+
errorText: {
|
|
89
|
+
fontSize: '12px',
|
|
90
|
+
color: 'red',
|
|
91
|
+
padding: '5px 0'
|
|
76
92
|
}
|
|
77
93
|
};
|
|
78
94
|
};
|
|
@@ -227,19 +243,50 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
227
243
|
categories = _this$props4.categories,
|
|
228
244
|
imageSupport = _this$props4.imageSupport,
|
|
229
245
|
toolbarOpts = _this$props4.toolbarOpts,
|
|
230
|
-
spellCheck = _this$props4.spellCheck
|
|
246
|
+
spellCheck = _this$props4.spellCheck,
|
|
247
|
+
configuration = _this$props4.configuration;
|
|
231
248
|
var categoriesPerRow = model.categoriesPerRow,
|
|
232
|
-
rowLabels = model.rowLabels
|
|
249
|
+
rowLabels = model.rowLabels,
|
|
250
|
+
errors = model.errors;
|
|
251
|
+
|
|
252
|
+
var _ref2 = errors || {},
|
|
253
|
+
associationError = _ref2.associationError,
|
|
254
|
+
categoriesError = _ref2.categoriesError;
|
|
255
|
+
|
|
256
|
+
var _ref3 = configuration || {},
|
|
257
|
+
maxCategories = _ref3.maxCategories;
|
|
258
|
+
|
|
233
259
|
var holderStyle = {
|
|
234
260
|
gridTemplateColumns: "repeat(".concat(categoriesPerRow, ", 1fr)")
|
|
235
261
|
};
|
|
262
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
236
263
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
237
264
|
className: (0, _classnames["default"])(classes.categories, className)
|
|
238
265
|
}, /*#__PURE__*/_react["default"].createElement(_header["default"], {
|
|
239
266
|
label: "Categories",
|
|
240
267
|
buttonLabel: "ADD A CATEGORY",
|
|
241
|
-
onAdd: this.add
|
|
242
|
-
|
|
268
|
+
onAdd: this.add,
|
|
269
|
+
info: /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
270
|
+
classes: {
|
|
271
|
+
tooltip: classes.tooltip
|
|
272
|
+
},
|
|
273
|
+
disableFocusListener: true,
|
|
274
|
+
disableTouchListener: true,
|
|
275
|
+
placement: 'right',
|
|
276
|
+
title: validationMessage
|
|
277
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
278
|
+
fontSize: 'small',
|
|
279
|
+
color: 'primary',
|
|
280
|
+
style: {
|
|
281
|
+
marginLeft: '5px'
|
|
282
|
+
}
|
|
283
|
+
})),
|
|
284
|
+
buttonDisabled: maxCategories && categories && maxCategories === categories.length
|
|
285
|
+
}), associationError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
286
|
+
className: classes.errorText
|
|
287
|
+
}, associationError), categoriesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
288
|
+
className: classes.errorText
|
|
289
|
+
}, categoriesError), /*#__PURE__*/_react["default"].createElement("div", {
|
|
243
290
|
className: classes.row
|
|
244
291
|
}, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
245
292
|
label: "Categories per row",
|
|
@@ -299,6 +346,7 @@ exports.Categories = Categories;
|
|
|
299
346
|
categories: _propTypes["default"].array,
|
|
300
347
|
onModelChanged: _propTypes["default"].func,
|
|
301
348
|
model: _propTypes["default"].object.isRequired,
|
|
349
|
+
configuration: _propTypes["default"].object.isRequired,
|
|
302
350
|
toolbarOpts: _propTypes["default"].object
|
|
303
351
|
});
|
|
304
352
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/design/categories/index.jsx"],"names":["styles","theme","categories","marginBottom","spacing","unit","categoriesHolder","display","gridRowGap","gridColumnGap","row","gridTemplateColumns","alignItems","width","marginTop","rowLabel","gridColumn","rowLabelHolder","RowLabel","categoriesPerRow","classes","markup","imageSupport","onChange","toolbarOpts","spellCheck","text","Categories","event","numberValue","parseInt","target","value","props","onModelChanged","model","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","concat","category","index","findIndex","splice","correctResponse","c","choice","categoryId","undefined","choiceIndex","val","newRowLabels","className","holderStyle","add","min","max","changeCategoryColumns","hasRowLabel","rowIndex","changeRowLabel","change","addChoiceToCategory","deleteChoiceFromCategory","React","Component","PropTypes","shape","func","isRequired","object","string","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC;AADlB,KADW;AAIvBC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,OAAO,EAAE,MADO;AAEhBC,MAAAA,UAAU,YAAKP,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAFM;AAGhBI,MAAAA,aAAa,YAAKR,KAAK,CAACG,OAAN,CAAcC,IAAnB;AAHG,KAJK;AASvBK,IAAAA,GAAG,EAAE;AACHH,MAAAA,OAAO,EAAE,MADN;AAEHI,MAAAA,mBAAmB,EAAE,gBAFlB;AAGHF,MAAAA,aAAa,YAAKR,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAHV;AAIHO,MAAAA,UAAU,EAAE,UAJT;AAKHC,MAAAA,KAAK,EAAE,MALJ;AAMHC,MAAAA,SAAS,EAAEb,KAAK,CAACG,OAAN,CAAcC,IANtB;AAOHF,MAAAA,YAAY,EAAE,IAAIF,KAAK,CAACG,OAAN,CAAcC;AAP7B,KATkB;AAkBvBU,IAAAA,QAAQ,EAAE;AACRC,MAAAA,UAAU,EAAE;AADJ,KAlBa;AAqBvBC,IAAA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W,EAAE,MAAI,CAACsB,mBALpB;AAME,UAAA,WAAW,EAAE9C,WANf;AAOE,UAAA,UAAU,EAAEC,UAPd;AAQE,UAAA,cAAc,EAAE,wBAAC6B,MAAD,EAASG,WAAT;AAAA,mBACd,MAAI,CAACc,wBAAL,CAA8BvB,QAA9B,EAAwCM,MAAxC,EAAgDG,WAAhD,CADc;AAAA;AARlB,UAdF,CADF;AA6BD,OAjCA,CADH,CAdF,CADF;AAqDD;;;EA/K6Be,kBAAMC,S;;;iCAAzB9C,U,eACQ;AACjBL,EAAAA,YAAY,EAAEoD,sBAAUC,KAAV,CAAgB;AAC5Bb,IAAAA,GAAG,EAAEY,sBAAUE,IAAV,CAAeC,UADQ;AAE5B,cAAQH,sBAAUE,IAAV,CAAeC;AAFK,GAAhB,CADG;AAKjBzD,EAAAA,OAAO,EAAEsD,sBAAUI,MAAV,CAAiBD,UALT;AAMjBjB,EAAAA,SAAS,EAAEc,sBAAUK,MANJ;AAOjB7E,EAAAA,UAAU,EAAEwE,sBAAUM,KAPL;AAQjB9C,EAAAA,cAAc,EAAEwC,sBAAUE,IART;AASjBzC,EAAAA,KAAK,EAAEuC,sBAAUI,MAAV,CAAiBD,UATP;AAUjBrD,EAAAA,WAAW,EAAEkD,sBAAUI;AAVN,C;;eAiLN,wBAAW9E,MAAX,EAAmB2B,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport classNames from 'classnames';\nimport Category from './category';\nimport Header from '../header';\nimport { moveChoiceToCategory, removeCategory, removeChoiceFromCategory } from '@pie-lib/categorize';\n\nconst styles = theme => ({\n categories: {\n marginBottom: theme.spacing.unit\n },\n categoriesHolder: {\n display: 'grid',\n gridRowGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`\n },\n row: {\n display: 'grid',\n gridTemplateColumns: 'repeat(2, 1fr)',\n gridColumnGap: `${theme.spacing.unit}px`,\n alignItems: 'baseline',\n width: '100%',\n marginTop: theme.spacing.unit,\n marginBottom: 2 * theme.spacing.unit\n },\n rowLabel: {\n gridColumn: '1/3'\n },\n rowLabelHolder: {\n width: '100%'\n }\n});\n\nconst RowLabel = withStyles(styles)(({ categoriesPerRow, classes, markup, imageSupport, onChange, toolbarOpts, spellCheck}) => {\n return (\n <div\n style={{\n gridColumn: `1/${categoriesPerRow + 1}`,\n width: '100%'\n }}\n >\n <Typography className={classes.text}>\n Row Label\n </Typography>\n <EditableHtml\n className={classes.rowLabelHolder}\n markup={markup}\n onChange={onChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n />\n </div>\n );\n});\n\nexport class Categories extends React.Component {\n static propTypes = {\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n categories: PropTypes.array,\n onModelChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object\n };\n\n changeCategoryColumns = event => {\n const numberValue = parseInt(event.target.value, 10);\n\n if (numberValue && numberValue >= 1 && numberValue <= 4) {\n this.props.onModelChanged({ categoriesPerRow: numberValue });\n }\n };\n\n add = () => {\n const { model } = this.props;\n const { categoriesPerRow } = model;\n const id = utils.firstAvailableIndex(model.categories.map(a => a.id), 0);\n const data = { id, label: 'Category ' + id };\n const addRowLabel = (model.categories.length) % categoriesPerRow === 0;\n const rowLabels = [...model.rowLabels];\n\n if (addRowLabel) {\n rowLabels.push('');\n }\n\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data])\n });\n };\n\n delete = category => {\n const { model, onModelChanged } = this.props;\n const index = model.categories.findIndex(a => a.id === category.id);\n\n if (index !== -1) {\n model.categories.splice(index, 1);\n model.correctResponse = removeCategory(\n category.id,\n model.correctResponse\n );\n onModelChanged(model);\n }\n };\n\n change = c => {\n const { categories } = this.props;\n const index = categories.findIndex(a => a.id === c.id);\n\n if (index !== -1) {\n categories.splice(index, 1, c);\n this.props.onModelChanged({ categories });\n }\n };\n\n addChoiceToCategory = (choice, categoryId) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = moveChoiceToCategory(\n choice.id,\n undefined,\n categoryId,\n 0,\n model.correctResponse\n );\n\n onModelChanged({ correctResponse });\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(\n choice.id,\n category.id,\n choiceIndex,\n model.correctResponse\n );\n\n onModelChanged({ correctResponse });\n };\n\n changeRowLabel = (val, index) => {\n const { model } = this.props;\n const { rowLabels } = model;\n const newRowLabels = [...rowLabels];\n\n if (newRowLabels.length < index) {\n newRowLabels.push(val);\n } else {\n newRowLabels[index] = val;\n }\n\n this.props.onModelChanged({\n rowLabels: newRowLabels\n });\n };\n\n render() {\n const {\n model,\n classes,\n className,\n categories,\n imageSupport,\n toolbarOpts,\n spellCheck\n } = this.props;\n\n const { categoriesPerRow, rowLabels } = model;\n\n const holderStyle = {\n gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`\n };\n\n return (\n <div className={classNames(classes.categories, className)}>\n <Header label=\"Categories\" buttonLabel=\"ADD A CATEGORY\" onAdd={this.add} />\n <div className={classes.row}>\n <TextField\n label=\"Categories per row\"\n type=\"number\"\n inputProps={{\n min: 1,\n max: 4\n }}\n value={categoriesPerRow}\n onChange={this.changeCategoryColumns}\n />\n </div>\n <div className={classes.categoriesHolder} style={holderStyle}>\n {categories.map((category, index) => {\n const hasRowLabel = index % categoriesPerRow === 0;\n const rowIndex = index / categoriesPerRow;\n\n return (\n <React.Fragment\n key={index}\n >\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n />\n )}\n <Category\n imageSupport={imageSupport}\n category={category}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n onAddChoice={this.addChoiceToCategory}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) =>\n this.deleteChoiceFromCategory(category, choice, choiceIndex)\n }\n />\n </React.Fragment>\n );\n })}\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(Categories);\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/design/categories/index.jsx"],"names":["styles","theme","categories","marginBottom","spacing","unit","categoriesHolder","display","gridRowGap","gridColumnGap","row","gridTemplateColumns","alignItems","width","marginTop","rowLabel","gridColumn","rowLabelHolder","tooltip","fontSize","whiteSpace","maxWidth","errorText","color","padding","RowLabel","categoriesPerRow","classes","markup","imageSupport","onChange","toolbarOpts","spellCheck","text","Categories","event","numberValue","parseInt","target","value","props","onModelChanged","model","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","concat","category","index","findIndex","splice","correctResponse","c","choice","categoryId","undefined","choiceIndex","val","newRowLabels","className","configuration","errors","associationError","categoriesError","maxCategories","holderStyle","validationMessage","add","marginLeft","min","max","changeCategoryColumns","hasRowLabel","rowIndex","changeRowLabel","change","addChoiceToCategory","deleteChoiceFromCategory","React","Component","PropTypes","shape","func","isRequired","object","string","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC;AADl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D,UALT;AAMjBxB,EAAAA,SAAS,EAAEqB,sBAAUK,MANJ;AAOjB3F,EAAAA,UAAU,EAAEsF,sBAAUM,KAPL;AAQjBrD,EAAAA,cAAc,EAAE+C,sBAAUE,IART;AASjBhD,EAAAA,KAAK,EAAE8C,sBAAUI,MAAV,CAAiBD,UATP;AAUjBvB,EAAAA,aAAa,EAAEoB,sBAAUI,MAAV,CAAiBD,UAVf;AAWjB5D,EAAAA,WAAW,EAAEyD,sBAAUI;AAXN,C;;eAsMN,wBAAW5F,MAAX,EAAmBkC,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport classNames from 'classnames';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { moveChoiceToCategory, removeCategory, removeChoiceFromCategory } from '@pie-lib/categorize';\n\nimport Category from './category';\nimport Header from '../header';\nimport { generateValidationMessage } from '../../utils';\n\nconst styles = theme => ({\n categories: {\n marginBottom: theme.spacing.unit\n },\n categoriesHolder: {\n display: 'grid',\n gridRowGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`\n },\n row: {\n display: 'grid',\n gridTemplateColumns: 'repeat(2, 1fr)',\n gridColumnGap: `${theme.spacing.unit}px`,\n alignItems: 'baseline',\n width: '100%',\n marginTop: theme.spacing.unit,\n marginBottom: 2 * theme.spacing.unit\n },\n rowLabel: {\n gridColumn: '1/3'\n },\n rowLabelHolder: {\n width: '100%'\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n },\n});\n\nconst RowLabel = withStyles(styles)(({ categoriesPerRow, classes, markup, imageSupport, onChange, toolbarOpts, spellCheck}) => {\n return (\n <div\n style={{\n gridColumn: `1/${categoriesPerRow + 1}`,\n width: '100%'\n }}\n >\n <Typography className={classes.text}>\n Row Label\n </Typography>\n <EditableHtml\n className={classes.rowLabelHolder}\n markup={markup}\n onChange={onChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n />\n </div>\n );\n});\n\nexport class Categories extends React.Component {\n static propTypes = {\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n categories: PropTypes.array,\n onModelChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object\n };\n\n changeCategoryColumns = event => {\n const numberValue = parseInt(event.target.value, 10);\n\n if (numberValue && numberValue >= 1 && numberValue <= 4) {\n this.props.onModelChanged({ categoriesPerRow: numberValue });\n }\n };\n\n add = () => {\n const { model } = this.props;\n const { categoriesPerRow } = model;\n const id = utils.firstAvailableIndex(model.categories.map(a => a.id), 0);\n const data = { id, label: 'Category ' + id };\n const addRowLabel = (model.categories.length) % categoriesPerRow === 0;\n const rowLabels = [...model.rowLabels];\n\n if (addRowLabel) {\n rowLabels.push('');\n }\n\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data])\n });\n };\n\n delete = category => {\n const { model, onModelChanged } = this.props;\n const index = model.categories.findIndex(a => a.id === category.id);\n\n if (index !== -1) {\n model.categories.splice(index, 1);\n model.correctResponse = removeCategory(\n category.id,\n model.correctResponse\n );\n onModelChanged(model);\n }\n };\n\n change = c => {\n const { categories } = this.props;\n const index = categories.findIndex(a => a.id === c.id);\n\n if (index !== -1) {\n categories.splice(index, 1, c);\n this.props.onModelChanged({ categories });\n }\n };\n\n addChoiceToCategory = (choice, categoryId) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = moveChoiceToCategory(\n choice.id,\n undefined,\n categoryId,\n 0,\n model.correctResponse\n );\n\n onModelChanged({ correctResponse });\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(\n choice.id,\n category.id,\n choiceIndex,\n model.correctResponse\n );\n\n onModelChanged({ correctResponse });\n };\n\n changeRowLabel = (val, index) => {\n const { model } = this.props;\n const { rowLabels } = model;\n const newRowLabels = [...rowLabels];\n\n if (newRowLabels.length < index) {\n newRowLabels.push(val);\n } else {\n newRowLabels[index] = val;\n }\n\n this.props.onModelChanged({\n rowLabels: newRowLabels\n });\n };\n\n render() {\n const {\n model,\n classes,\n className,\n categories,\n imageSupport,\n toolbarOpts,\n spellCheck,\n configuration\n } = this.props;\n\n const { categoriesPerRow, rowLabels, errors } = model;\n const { associationError, categoriesError } = errors || {};\n const { maxCategories } = configuration || {};\n const holderStyle = {\n gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n return (\n <div className={classNames(classes.categories, className)}>\n <Header\n label=\"Categories\"\n buttonLabel=\"ADD A CATEGORY\"\n onAdd={this.add}\n info={<Tooltip\n classes={{tooltip: classes.tooltip}}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }}/>\n </Tooltip>}\n buttonDisabled={maxCategories && categories && maxCategories === categories.length}\n />\n {associationError && <div className={classes.errorText}>{associationError}</div>}\n {categoriesError && <div className={classes.errorText}>{categoriesError}</div>}\n <div className={classes.row}>\n <TextField\n label=\"Categories per row\"\n type=\"number\"\n inputProps={{\n min: 1,\n max: 4\n }}\n value={categoriesPerRow}\n onChange={this.changeCategoryColumns}\n />\n </div>\n <div className={classes.categoriesHolder} style={holderStyle}>\n {categories.map((category, index) => {\n const hasRowLabel = index % categoriesPerRow === 0;\n const rowIndex = index / categoriesPerRow;\n\n return (\n <React.Fragment\n key={index}\n >\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n />\n )}\n <Category\n imageSupport={imageSupport}\n category={category}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n onAddChoice={this.addChoiceToCategory}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) =>\n this.deleteChoiceFromCategory(category, choice, choiceIndex)\n }\n />\n </React.Fragment>\n );\n })}\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(Categories);\n"],"file":"index.js"}
|
|
@@ -113,7 +113,8 @@ var Choice = /*#__PURE__*/function (_React$Component) {
|
|
|
113
113
|
connectDragPreview = _this$props3.connectDragPreview,
|
|
114
114
|
imageSupport = _this$props3.imageSupport,
|
|
115
115
|
spellCheck = _this$props3.spellCheck,
|
|
116
|
-
toolbarOpts = _this$props3.toolbarOpts
|
|
116
|
+
toolbarOpts = _this$props3.toolbarOpts,
|
|
117
|
+
error = _this$props3.error;
|
|
117
118
|
var draggable = canDrag(this.props);
|
|
118
119
|
return /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
119
120
|
className: (0, _classnames["default"])(classes.choice, className)
|
|
@@ -129,8 +130,11 @@ var Choice = /*#__PURE__*/function (_React$Component) {
|
|
|
129
130
|
onChange: this.changeContent,
|
|
130
131
|
onDelete: onDelete,
|
|
131
132
|
toolbarOpts: toolbarOpts,
|
|
132
|
-
spellCheck: spellCheck
|
|
133
|
-
|
|
133
|
+
spellCheck: spellCheck,
|
|
134
|
+
error: error
|
|
135
|
+
}), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
136
|
+
className: classes.errorText
|
|
137
|
+
}, error))), /*#__PURE__*/_react["default"].createElement(_CardActions["default"], {
|
|
134
138
|
className: classes.actions
|
|
135
139
|
}, /*#__PURE__*/_react["default"].createElement(_buttons.DeleteButton, {
|
|
136
140
|
label: 'delete',
|
|
@@ -160,7 +164,8 @@ exports.Choice = Choice;
|
|
|
160
164
|
add: _propTypes["default"].func.isRequired,
|
|
161
165
|
"delete": _propTypes["default"].func.isRequired
|
|
162
166
|
}),
|
|
163
|
-
toolbarOpts: _propTypes["default"].object
|
|
167
|
+
toolbarOpts: _propTypes["default"].object,
|
|
168
|
+
error: _propTypes["default"].string
|
|
164
169
|
});
|
|
165
170
|
(0, _defineProperty2["default"])(Choice, "defaultProps", {});
|
|
166
171
|
|
|
@@ -179,6 +184,11 @@ var styles = function styles(theme) {
|
|
|
179
184
|
},
|
|
180
185
|
dragDisabled: {
|
|
181
186
|
cursor: 'inherit'
|
|
187
|
+
},
|
|
188
|
+
errorText: {
|
|
189
|
+
fontSize: '11px',
|
|
190
|
+
color: 'red',
|
|
191
|
+
paddingBottom: '5px'
|
|
182
192
|
}
|
|
183
193
|
};
|
|
184
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/design/choices/choice.jsx"],"names":["log","canDrag","props","count","choice","categoryCount","correctResponseCount","Choice","content","onChange","classes","className","onDelete","connectDragSource","connectDragPreview","imageSupport","spellCheck","toolbarOpts","draggable","actions","dragHandle","dragDisabled","changeContent","changeCategoryCount","React","Component","PropTypes","object","isRequired","string","func","number","shape","add","styles","theme","padding","justifyContent","spacing","unit","overflow","cursor","StyledChoice","spec","beginDrag","out","id","endDrag","monitor","didDrop","item","getItem","categoryId","onRemoveChoice","DraggableChoice","uid","connect","dragSource","dragPreview","isDragging","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAAAC,KAAK,EAAI;AACvB,MAAMC,KAAK,GAAGD,KAAK,CAACE,MAAN,CAAaC,aAAb,IAA8B,CAA5C;;AACA,MAAIF,KAAK,KAAK,CAAd,EAAiB;AACf,WAAO,IAAP;AACD,GAFD,MAEO;AACL,WAAOD,KAAK,CAACI,oBAAN,GAA6BH,KAApC;AACD;AACF,CAPD;;IASaI,M;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/design/choices/choice.jsx"],"names":["log","canDrag","props","count","choice","categoryCount","correctResponseCount","Choice","content","onChange","classes","className","onDelete","connectDragSource","connectDragPreview","imageSupport","spellCheck","toolbarOpts","error","draggable","actions","dragHandle","dragDisabled","changeContent","errorText","changeCategoryCount","React","Component","PropTypes","object","isRequired","string","func","number","shape","add","styles","theme","padding","justifyContent","spacing","unit","overflow","cursor","fontSize","color","paddingBottom","StyledChoice","spec","beginDrag","out","id","endDrag","monitor","didDrop","item","getItem","categoryId","onRemoveChoice","DraggableChoice","uid","connect","dragSource","dragPreview","isDragging","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAAAC,KAAK,EAAI;AACvB,MAAMC,KAAK,GAAGD,KAAK,CAACE,MAAN,CAAaC,aAAb,IAA8B,CAA5C;;AACA,MAAIF,KAAK,KAAK,CAAd,EAAiB;AACf,WAAO,IAAP;AACD,GAFD,MAEO;AACL,WAAOD,KAAK,CAACI,oBAAN,GAA6BH,KAApC;AACD;AACF,CAPD;;IASaI,M;;;;;;;;;;;;;;;sGAoBK,UAAAC,OAAO,EAAI;AACzB,wBAA6B,MAAKN,KAAlC;AAAA,UAAQO,QAAR,eAAQA,QAAR;AAAA,UAAkBL,MAAlB,eAAkBA,MAAlB;AACAA,MAAAA,MAAM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,EAAQmD,OAAR,EAAoB;AAC3B,QAAI,CAACA,OAAO,CAACC,OAAR,EAAL,EAAwB;AACtB,UAAMC,IAAI,GAAGF,OAAO,CAACG,OAAR,EAAb;;AACA,UAAID,IAAI,CAACE,UAAT,EAAqB;AACnBzD,QAAAA,GAAG,CAAC,8BAAD,CAAH;AACAE,QAAAA,KAAK,CAACwD,cAAN,CAAqBH,IAArB;AACD;AACF;AACF;AAjBiB,CAAb;;AAoBP,IAAMI,eAAe,GAAG,0BACtB;AAAA,MAAGC,GAAH,QAAGA,GAAH;AAAA,SAAaA,GAAb;AAAA,CADsB,EAEtBZ,IAFsB,EAGtB,UAACa,OAAD,EAAUR,OAAV;AAAA,SAAuB;AACrBxC,IAAAA,iBAAiB,EAAEgD,OAAO,CAACC,UAAR,EADE;AAErBhD,IAAAA,kBAAkB,EAAE+C,OAAO,CAACE,WAAR,EAFC;AAGrBC,IAAAA,UAAU,EAAEX,OAAO,CAACW,UAAR;AAHS,GAAvB;AAAA,CAHsB,EAQtBjB,YARsB,CAAxB;;eAUea,UAAIK,OAAJ,CAAYN,eAAZ,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport InputHeader from '../input-header';\nimport { Checkbox } from '@pie-lib/config-ui';\nimport { DeleteButton } from '../buttons';\nimport DragHandle from '@material-ui/icons/DragHandle';\nimport { DragSource } from 'react-dnd';\nimport debug from 'debug';\nimport { uid } from '@pie-lib/drag';\n\nconst log = debug('@pie-element:categorize:configure:choice');\n\nconst canDrag = props => {\n const count = props.choice.categoryCount || 0;\n if (count === 0) {\n return true;\n } else {\n return props.correctResponseCount < count;\n }\n};\n\nexport class Choice extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n choice: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n connectDragSource: PropTypes.func.isRequired,\n connectDragPreview: PropTypes.func.isRequired,\n correctResponseCount: PropTypes.number.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n toolbarOpts: PropTypes.object,\n error: PropTypes.string\n };\n\n static defaultProps = {};\n\n changeContent = content => {\n const { onChange, choice } = this.props;\n choice.content = content;\n onChange(choice);\n };\n\n changeCategoryCount = () => {\n const { onChange, choice } = this.props;\n if (choice.categoryCount === 1) {\n choice.categoryCount = 0;\n } else {\n choice.categoryCount = 1;\n }\n onChange(choice);\n };\n\n render() {\n const {\n classes,\n className,\n choice,\n onDelete,\n connectDragSource,\n connectDragPreview,\n imageSupport,\n spellCheck,\n toolbarOpts,\n error\n } = this.props;\n\n const draggable = canDrag(this.props);\n\n return (\n <Card className={classNames(classes.choice, className)}>\n <CardActions className={classes.actions}>\n {connectDragSource(\n <span\n className={classNames(\n classes.dragHandle,\n draggable === false && classes.dragDisabled\n )}\n >\n <DragHandle color={draggable ? 'primary' : 'disabled'} />\n </span>\n )}\n </CardActions>\n {connectDragPreview(\n <span>\n <InputHeader\n imageSupport={imageSupport}\n label={choice.content}\n onChange={this.changeContent}\n onDelete={onDelete}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n error={error}\n />\n {error && <div className={classes.errorText}>{error}</div>}\n </span>\n )}\n\n <CardActions className={classes.actions}>\n <DeleteButton label={'delete'} onClick={onDelete} />\n <Checkbox\n mini\n label={'Remove after placing'}\n checked={choice.categoryCount === 1}\n onChange={this.changeCategoryCount}\n />\n </CardActions>\n </Card>\n );\n }\n}\nconst styles = theme => ({\n actions: {\n padding: 0,\n justifyContent: 'space-between'\n },\n choice: {\n padding: theme.spacing.unit,\n overflow: 'visible'\n },\n dragHandle: {\n cursor: 'move'\n },\n dragDisabled: {\n cursor: 'inherit'\n },\n errorText: {\n fontSize: '11px',\n color: 'red',\n paddingBottom: '5px'\n },\n});\n\nconst StyledChoice = withStyles(styles)(Choice);\n\nexport const spec = {\n canDrag,\n beginDrag: props => {\n const out = {\n id: props.choice.id\n };\n log('[beginDrag] out:', out);\n return out;\n },\n endDrag: (props, monitor) => {\n if (!monitor.didDrop()) {\n const item = monitor.getItem();\n if (item.categoryId) {\n log('wasnt droppped - what to do?');\n props.onRemoveChoice(item);\n }\n }\n }\n};\n\nconst DraggableChoice = DragSource(\n ({ uid }) => uid,\n spec,\n (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n connectDragPreview: connect.dragPreview(),\n isDragging: monitor.isDragging()\n })\n)(StyledChoice);\n\nexport default uid.withUid(DraggableChoice);\n"],"file":"choice.js"}
|
|
@@ -130,7 +130,17 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
130
130
|
imageSupport = _this$props4.imageSupport,
|
|
131
131
|
onModelChanged = _this$props4.onModelChanged,
|
|
132
132
|
spellCheck = _this$props4.spellCheck,
|
|
133
|
-
toolbarOpts = _this$props4.toolbarOpts
|
|
133
|
+
toolbarOpts = _this$props4.toolbarOpts,
|
|
134
|
+
configuration = _this$props4.configuration;
|
|
135
|
+
var errors = model.errors;
|
|
136
|
+
|
|
137
|
+
var _ref = errors || {},
|
|
138
|
+
choicesError = _ref.choicesError,
|
|
139
|
+
choicesErrors = _ref.choicesErrors;
|
|
140
|
+
|
|
141
|
+
var _ref2 = configuration || {},
|
|
142
|
+
maxChoices = _ref2.maxChoices;
|
|
143
|
+
|
|
134
144
|
var categoryCountIsOne = this.allChoicesHaveCount(1);
|
|
135
145
|
var choiceHolderStyle = {
|
|
136
146
|
gridTemplateColumns: "repeat(".concat(model.categoriesPerRow, ", 1fr)")
|
|
@@ -140,8 +150,11 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
140
150
|
}, /*#__PURE__*/_react["default"].createElement(_header["default"], {
|
|
141
151
|
label: "Choices",
|
|
142
152
|
buttonLabel: "ADD A CHOICE",
|
|
143
|
-
onAdd: this.addChoice
|
|
144
|
-
|
|
153
|
+
onAdd: this.addChoice,
|
|
154
|
+
buttonDisabled: maxChoices && choices && maxChoices === choices.length
|
|
155
|
+
}), choicesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
156
|
+
className: classes.errorText
|
|
157
|
+
}, choicesError), /*#__PURE__*/_react["default"].createElement(_config["default"], {
|
|
145
158
|
config: model,
|
|
146
159
|
categoryCountIsOne: categoryCountIsOne,
|
|
147
160
|
onModelChanged: onModelChanged,
|
|
@@ -161,7 +174,8 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
161
174
|
return _this2.deleteChoice(h);
|
|
162
175
|
},
|
|
163
176
|
toolbarOpts: toolbarOpts,
|
|
164
|
-
spellCheck: spellCheck
|
|
177
|
+
spellCheck: spellCheck,
|
|
178
|
+
error: choicesErrors && choicesErrors[h.id]
|
|
165
179
|
});
|
|
166
180
|
})), /*#__PURE__*/_react["default"].createElement(_buttons.Divider, null));
|
|
167
181
|
}
|
|
@@ -172,6 +186,7 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
172
186
|
exports.Choices = Choices;
|
|
173
187
|
(0, _defineProperty2["default"])(Choices, "propTypes", {
|
|
174
188
|
model: _propTypes["default"].object.isRequired,
|
|
189
|
+
configuration: _propTypes["default"].object.isRequired,
|
|
175
190
|
classes: _propTypes["default"].object.isRequired,
|
|
176
191
|
className: _propTypes["default"].string,
|
|
177
192
|
choices: _propTypes["default"].array.isRequired,
|
|
@@ -197,7 +212,12 @@ var styles = function styles(theme) {
|
|
|
197
212
|
paddingTop: theme.spacing.unit * 2,
|
|
198
213
|
paddingBottom: theme.spacing.unit * 2
|
|
199
214
|
},
|
|
200
|
-
label: {}
|
|
215
|
+
label: {},
|
|
216
|
+
errorText: {
|
|
217
|
+
fontSize: '12px',
|
|
218
|
+
color: 'red',
|
|
219
|
+
padding: '5px 0'
|
|
220
|
+
}
|
|
201
221
|
};
|
|
202
222
|
};
|
|
203
223
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/design/choices/index.jsx"],"names":["Choices","choice","props","choices","onModelChanged","index","findIndex","h","id","splice","count","c","categoryCount","model","utils","firstAvailableIndex","map","a","data","content","concat","correctResponse","classes","className","imageSupport","spellCheck","toolbarOpts","categoryCountIsOne","allChoicesHaveCount","choiceHolderStyle","gridTemplateColumns","categoriesPerRow","addChoice","choiceHolder","correctResponseCount","changeChoice","deleteChoice","React","Component","PropTypes","object","isRequired","string","array","func","shape","add","styles","theme","paddingTop","spacing","unit","paddingBottom","display","gridRowGap","gridColumnGap","label"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,O;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/design/choices/index.jsx"],"names":["Choices","choice","props","choices","onModelChanged","index","findIndex","h","id","splice","count","c","categoryCount","model","utils","firstAvailableIndex","map","a","data","content","concat","correctResponse","classes","className","imageSupport","spellCheck","toolbarOpts","configuration","errors","choicesError","choicesErrors","maxChoices","categoryCountIsOne","allChoicesHaveCount","choiceHolderStyle","gridTemplateColumns","categoriesPerRow","addChoice","length","errorText","choiceHolder","correctResponseCount","changeChoice","deleteChoice","React","Component","PropTypes","object","isRequired","string","array","func","shape","add","styles","theme","paddingTop","spacing","unit","paddingBottom","display","gridRowGap","gridColumnGap","label","fontSize","color","padding"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,O;;;;;;;;;;;;;;;qGAiBI,UAAAC,MAAM,EAAI;AACvB,wBAAoC,MAAKC,KAAzC;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,cAAjB,eAAiBA,cAAjB;AACA,UAAMC,KAAK,GAAGF,OAAO,CAACG,SAAR,CAAkB,UAAAC,CAAC;AAAA,eAAI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":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Divider } from '../buttons';\nimport classNames from 'classnames';\nimport Choice from './choice';\nimport Header from '../header';\nimport every from 'lodash/every';\nimport Config from './config';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport { removeAllChoices } from '@pie-lib/categorize';\n\nexport class Choices extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n choices: PropTypes.array.isRequired,\n onModelChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n toolbarOpts: PropTypes.object\n };\n\n static defaultProps = {};\n\n changeChoice = choice => {\n const { choices, onModelChanged } = this.props;\n const index = choices.findIndex(h => h.id === choice.id);\n if (index !== -1) {\n choices.splice(index, 1, choice);\n onModelChanged({ choices });\n }\n };\n\n allChoicesHaveCount = count => {\n const { choices } = this.props;\n return every(choices, c => c.categoryCount === count);\n };\n\n addChoice = () => {\n const { onModelChanged, model } = this.props;\n\n const id = utils.firstAvailableIndex(model.choices.map(a => a.id), 0);\n const data = { id, content: 'Choice ' + id };\n\n onModelChanged({ choices: model.choices.concat([data]) });\n };\n\n deleteChoice = choice => {\n const { model, onModelChanged } = this.props;\n const index = model.choices.findIndex(a => a.id === choice.id);\n if (index !== -1) {\n model.choices.splice(index, 1);\n model.correctResponse = removeAllChoices(\n choice.id,\n model.correctResponse\n );\n onModelChanged(model);\n }\n };\n\n render() {\n const {\n classes,\n className,\n choices,\n model,\n imageSupport,\n onModelChanged,\n spellCheck,\n toolbarOpts,\n configuration,\n } = this.props;\n const { errors } = model;\n const { choicesError, choicesErrors } = errors || {};\n const { maxChoices } = configuration || {};\n\n const categoryCountIsOne = this.allChoicesHaveCount(1);\n const choiceHolderStyle = {\n gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`\n };\n\n return (\n <div className={classNames(classes.choices, className)}>\n <Header\n label=\"Choices\"\n buttonLabel=\"ADD A CHOICE\"\n onAdd={this.addChoice}\n buttonDisabled={maxChoices && choices && maxChoices === choices.length}\n />\n {choicesError && <div className={classes.errorText}>{choicesError}</div>}\n <Config\n config={model}\n categoryCountIsOne={categoryCountIsOne}\n onModelChanged={onModelChanged}\n allChoicesHaveCount={this.allChoicesHaveCount}\n spellCheck={spellCheck}\n />\n <div className={classes.choiceHolder} style={choiceHolderStyle}>\n {choices.map((h, index) => (\n <Choice\n choice={h}\n correctResponseCount={h.correctResponseCount}\n key={index}\n imageSupport={imageSupport}\n onChange={this.changeChoice}\n onDelete={() => this.deleteChoice(h)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n error={choicesErrors && choicesErrors[h.id]}\n />\n ))}\n </div>\n <Divider />\n </div>\n );\n }\n}\nconst styles = theme => ({\n choiceHolder: {\n paddingTop: theme.spacing.unit,\n paddingBottom: theme.spacing.unit,\n display: 'grid',\n gridRowGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`\n },\n choices: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n label: {},\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n },\n});\nexport default withStyles(styles)(Choices);\n"],"file":"index.js"}
|
|
@@ -53,15 +53,20 @@ var Header = /*#__PURE__*/function (_React$Component) {
|
|
|
53
53
|
className = _this$props.className,
|
|
54
54
|
onAdd = _this$props.onAdd,
|
|
55
55
|
label = _this$props.label,
|
|
56
|
-
buttonLabel = _this$props.buttonLabel
|
|
56
|
+
buttonLabel = _this$props.buttonLabel,
|
|
57
|
+
info = _this$props.info,
|
|
58
|
+
buttonDisabled = _this$props.buttonDisabled;
|
|
57
59
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
58
60
|
className: (0, _classnames["default"])(classes.header, className)
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
62
|
+
className: classes.titleContainer
|
|
59
63
|
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
60
64
|
variant: "title",
|
|
61
65
|
className: classes.title
|
|
62
|
-
}, label), /*#__PURE__*/_react["default"].createElement(_buttons.AddButton, {
|
|
66
|
+
}, label), info), /*#__PURE__*/_react["default"].createElement(_buttons.AddButton, {
|
|
63
67
|
onClick: onAdd,
|
|
64
|
-
label: buttonLabel
|
|
68
|
+
label: buttonLabel,
|
|
69
|
+
disabled: buttonDisabled
|
|
65
70
|
}));
|
|
66
71
|
}
|
|
67
72
|
}]);
|
|
@@ -74,7 +79,9 @@ exports.Header = Header;
|
|
|
74
79
|
className: _propTypes["default"].string,
|
|
75
80
|
buttonLabel: _propTypes["default"].string,
|
|
76
81
|
onAdd: _propTypes["default"].func.isRequired,
|
|
77
|
-
label: _propTypes["default"].string.isRequired
|
|
82
|
+
label: _propTypes["default"].string.isRequired,
|
|
83
|
+
info: _propTypes["default"].any,
|
|
84
|
+
buttonDisabled: _propTypes["default"].bool
|
|
78
85
|
});
|
|
79
86
|
(0, _defineProperty2["default"])(Header, "defaultProps", {});
|
|
80
87
|
|
|
@@ -84,6 +91,9 @@ var styles = function styles(theme) {
|
|
|
84
91
|
display: 'flex',
|
|
85
92
|
justifyContent: 'space-between',
|
|
86
93
|
marginBottom: 2 * theme.spacing.unit
|
|
94
|
+
},
|
|
95
|
+
titleContainer: {
|
|
96
|
+
display: 'flex'
|
|
87
97
|
}
|
|
88
98
|
};
|
|
89
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/design/header.jsx"],"names":["Header","props","classes","className","onAdd","label","buttonLabel","header","title","React","Component","PropTypes","object","isRequired","string","func","styles","theme","display","justifyContent","marginBottom","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,M;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/design/header.jsx"],"names":["Header","props","classes","className","onAdd","label","buttonLabel","info","buttonDisabled","header","titleContainer","title","React","Component","PropTypes","object","isRequired","string","func","any","bool","styles","theme","display","justifyContent","marginBottom","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,M;;;;;;;;;;;;WAYX,kBAAS;AACP,wBAAgF,KAAKC,KAArF;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BC,KAA5B,eAA4BA,KAA5B;AAAA,UAAmCC,KAAnC,eAAmCA,KAAnC;AAAA,UAA0CC,WAA1C,eAA0CA,WAA1C;AAAA,UAAuDC,IAAvD,eAAuDA,IAAvD;AAAA,UAA6DC,cAA7D,eAA6DA,cAA7D;AACA,0BACE;AAAK,QAAA,SAAS,EAAE,4BAAWN,OAAO,CAACO,MAAnB,EAA2BN,SAA3B;AAAhB,sBACE;AAAK,QAAA,SAAS,EAAED,OAAO,CAACQ;AAAxB,sBACA,gCAAC,sBAAD;AAAY,QAAA,OAAO,EAAC,OAApB;AAA4B,QAAA,SAAS,EAAER,OAAO,CAACS;AAA/C,SACGN,KADH,CADA,EAICE,IAJD,CADF,eAOE,gCAAC,kBAAD;AAAW,QAAA,OAAO,EAAEH,KAApB;AAA2B,QAAA,KAAK,EAAEE,WAAlC;AAA+C,QAAA,QAAQ,EAAEE;AAAzD,QAPF,CADF;AAWD;;;EAzByBI,kBAAMC,S;;;iCAArBb,M,eACQ;AACjBE,EAAAA,OAAO,EAAEY,sBAAUC,MAAV,CAAiBC,UADT;AAEjBb,EAAAA,SAAS,EAAEW,sBAAUG,MAFJ;AAGjBX,EAAAA,WAAW,EAAEQ,sBAAUG,MAHN;AAIjBb,EAAAA,KAAK,EAAEU,sBAAUI,IAAV,CAAeF,UAJL;AAKjBX,EAAAA,KAAK,EAAES,sBAAUG,MAAV,CAAiBD,UALP;AAMjBT,EAAAA,IAAI,EAAEO,sBAAUK,GANC;AAOjBX,EAAAA,cAAc,EAAEM,sBAAUM;AAPT,C;iCADRpB,M,kBAWW,E;;AAgBxB,IAAMqB,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBb,IAAAA,MAAM,EAAE;AACNc,MAAAA,OAAO,EAAE,MADH;AAENC,MAAAA,cAAc,EAAE,eAFV;AAGNC,MAAAA,YAAY,EAAE,IAAIH,KAAK,CAACI,OAAN,CAAcC;AAH1B,KADe;AAMvBjB,IAAAA,cAAc,EAAE;AACda,MAAAA,OAAO,EAAE;AADK;AANO,GAAL;AAAA,CAApB;;eAUe,wBAAWF,MAAX,EAAmBrB,MAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { AddButton } from './buttons';\n\nexport class Header extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n buttonLabel: PropTypes.string,\n onAdd: PropTypes.func.isRequired,\n label: PropTypes.string.isRequired,\n info: PropTypes.any,\n buttonDisabled: PropTypes.bool\n };\n\n static defaultProps = {};\n render() {\n const { classes, className, onAdd, label, buttonLabel, info, buttonDisabled } = this.props;\n return (\n <div className={classNames(classes.header, className)}>\n <div className={classes.titleContainer}>\n <Typography variant=\"title\" className={classes.title}>\n {label}\n </Typography>\n {info}\n </div>\n <AddButton onClick={onAdd} label={buttonLabel} disabled={buttonDisabled}/>\n </div>\n );\n }\n}\nconst styles = theme => ({\n header: {\n display: 'flex',\n justifyContent: 'space-between',\n marginBottom: 2 * theme.spacing.unit\n },\n titleContainer: {\n display: 'flex',\n }\n});\nexport default withStyles(styles)(Header);\n"],"file":"header.js"}
|
|
@@ -196,7 +196,8 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
196
196
|
promptEnabled = _ref2.promptEnabled,
|
|
197
197
|
rationaleEnabled = _ref2.rationaleEnabled,
|
|
198
198
|
feedbackEnabled = _ref2.feedbackEnabled,
|
|
199
|
-
spellCheckEnabled = _ref2.spellCheckEnabled
|
|
199
|
+
spellCheckEnabled = _ref2.spellCheckEnabled,
|
|
200
|
+
errors = _ref2.errors;
|
|
200
201
|
|
|
201
202
|
var toolbarOpts = {};
|
|
202
203
|
|
|
@@ -287,7 +288,8 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
287
288
|
categories: categories || [],
|
|
288
289
|
onModelChanged: this.updateModel,
|
|
289
290
|
toolbarOpts: toolbarOpts,
|
|
290
|
-
spellCheck: spellCheckEnabled
|
|
291
|
+
spellCheck: spellCheckEnabled,
|
|
292
|
+
configuration: configuration
|
|
291
293
|
}), /*#__PURE__*/_react["default"].createElement(_header["default"], {
|
|
292
294
|
className: classes.alternatesHeader,
|
|
293
295
|
label: "Alternate Responses",
|
|
@@ -316,7 +318,8 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
316
318
|
model: model,
|
|
317
319
|
onModelChanged: this.updateModel,
|
|
318
320
|
toolbarOpts: toolbarOpts,
|
|
319
|
-
spellCheck: spellCheckEnabled
|
|
321
|
+
spellCheck: spellCheckEnabled,
|
|
322
|
+
configuration: configuration
|
|
320
323
|
}), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
|
|
321
324
|
feedback: model.feedback,
|
|
322
325
|
onChange: this.changeFeedback,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/design/index.jsx"],"names":["Panel","settings","toggle","radio","IdProvider","uid","Provider","Design","props","model","onChange","updatedModel","correctResponse","choices","categories","map","c","id","label","h","content","categoryCount","rationale","teacherInstructions","feedback","updateModel","cr","alternateResponses","prompt","index","filter","alt","altIndex","choice","generateId","classes","className","imageSupport","configuration","onConfigurationChanged","partialScoring","lockChoiceOrder","studentInstructions","scoringType","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","feedbackEnabled","spellCheckEnabled","toolbarOpts","toolbarEditorPosition","position","config","columns","correctResponseCount","countChoiceInCorrectResponse","Settings","Properties","studentInstructionsEnabled","design","promptHolder","onPromptChanged","inputHolder","input","changeTeacherInstructions","changeRationale","alternatesHeader","onAddAlternateResponse","categoriesList","onRemoveAlternateResponse","changeFeedback","React","Component","PropTypes","object","isRequired","string","func","shape","add","styles","theme","paddingTop","spacing","unit","paddingBottom","text","width","marginBottom","maxWidth","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAAiCC,kBAAjC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAiCD,kBAAjC,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAAiCF,kBAAjC,CAAuBE,KAAvB;AACA,IAAkBC,UAAlB,GAAiCC,SAAjC,CAAQC,QAAR;;IAEaC,M;;;;;AAeX,kBAAYC,MAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,MAAN;AADiB,oGAKL,UAACA,KAAD,EAAW;AACvB,wBAA4B,MAAKA,KAAjC;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,QAAf,eAAeA,QAAf;;AAEA,UAAMC,YAAY,mCACbF,KADa,GAEbD,KAFa,CAAlB,CAHuB,CAQvB;;;AACAG,MAAAA,YAAY,CAACC,eAAb,GAA+B,8CAC7BD,YAAY,CAACC,eAAb,IAAgC,EADH,EAE7BD,YAAY,CAACE,OAFgB,CAA/B,CATuB,CAcvB;;AACAF,MAAAA,YAAY,CAACG,UAAb,GAA0BH,YAAY,CAACG,UAAb,CAAwBC,GAAxB,CAA4B,UAACC,CAAD;AAAA,eAAQ;AAC5DC,UAAAA,EAAE,EAAED,CAAC,CAACC,EADsD;AAE5DC,UAAAA,KAAK,EAAEF,CAAC,CAACE;A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MAAAA,aAAa,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZI,MAAAA,YAAY,EAAEP,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KA3BW;AAgCzBM,IAAAA,KAAK,EAAE;AACLF,MAAAA,YAAY,EAAE;AADT;AAhCkB,GAAZ;AAAA,CAAf;;eAqCe,2BAAgB,wBAAWR,MAAX,EAAmB1E,MAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport {\n FeedbackConfig,\n InputContainer,\n layout,\n settings,\n} from '@pie-lib/config-ui';\nimport {\n countInAnswer,\n ensureNoExtraChoicesInAnswer,\n} from '@pie-lib/categorize';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { uid, withDragContext } from '@pie-lib/drag';\n\nimport Categories from './categories';\nimport AlternateResponses from './categories/alternateResponses';\nimport Choices from './choices';\nimport { Divider } from './buttons';\nimport { buildAlternateResponses, buildCategories } from './builder';\nimport Header from './header';\n\nconst { Panel, toggle, radio } = settings;\nconst { Provider: IdProvider } = uid;\n\nexport class Design extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n className: PropTypes.string,\n onConfigurationChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n uid: PropTypes.string,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n constructor(props) {\n super(props);\n this.uid = props.uid || uid.generateId();\n }\n\n updateModel = (props) => {\n const { model, onChange } = this.props;\n\n const updatedModel = {\n ...model,\n ...props,\n };\n\n //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.\n updatedModel.correctResponse = ensureNoExtraChoicesInAnswer(\n updatedModel.correctResponse || [],\n updatedModel.choices\n );\n\n //clean categories\n updatedModel.categories = updatedModel.categories.map((c) => ({\n id: c.id,\n label: c.label,\n }));\n\n updatedModel.choices = updatedModel.choices.map((h) => ({\n id: h.id,\n content: h.content,\n categoryCount: h.categoryCount,\n }));\n\n onChange(updatedModel);\n };\n\n changeRationale = (rationale) => {\n const { model, onChange } = this.props;\n\n onChange({\n ...model,\n rationale,\n });\n };\n\n changeTeacherInstructions = (teacherInstructions) => {\n const { model, onChange } = this.props;\n\n onChange({\n ...model,\n teacherInstructions,\n });\n };\n\n changeFeedback = (feedback) => {\n this.updateModel({ feedback });\n };\n\n onAddAlternateResponse = () => {\n const {\n model: { correctResponse },\n } = this.props;\n\n this.updateModel({\n correctResponse: (correctResponse || []).map((cr) => ({\n ...cr,\n alternateResponses: [...(cr.alternateResponses || []), []],\n })),\n });\n };\n\n onPromptChanged = (prompt) => this.updateModel({ prompt });\n\n onRemoveAlternateResponse = (index) => {\n const {\n model: { correctResponse },\n } = this.props;\n\n this.updateModel({\n correctResponse: (correctResponse || []).map((cr) => ({\n ...cr,\n alternateResponses: (cr.alternateResponses || []).filter(\n (alt, altIndex) => altIndex !== index\n ),\n })),\n });\n };\n\n countChoiceInCorrectResponse = (choice) => {\n const { model } = this.props;\n\n return countInAnswer(choice.id, model.correctResponse);\n };\n\n render() {\n const {\n classes,\n className,\n model,\n imageSupport,\n configuration,\n onChange,\n onConfigurationChanged,\n } = this.props;\n const {\n partialScoring = {},\n lockChoiceOrder = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n scoringType = {},\n feedback = {},\n prompt = {},\n spellCheck = {},\n } = configuration || {};\n const {\n teacherInstructionsEnabled,\n promptEnabled,\n rationaleEnabled,\n feedbackEnabled,\n spellCheckEnabled,\n } = model || {};\n\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n const config = model.config || {};\n config.choices = config.choices || { label: '', columns: 2 };\n\n const categories = buildCategories(\n model.categories || [],\n model.choices || [],\n model.correctResponse || []\n );\n\n const alternateResponses = buildAlternateResponses(\n model.categories || [],\n model.choices || [],\n model.correctResponse || []\n );\n\n const choices = model.choices.map((c) => {\n c.correctResponseCount = this.countChoiceInCorrectResponse(c);\n return c;\n });\n\n return (\n <IdProvider value={this.uid}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onChange}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder:\n lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric']),\n },\n }}\n />\n }\n >\n <div className={classNames(classes.design, className)}>\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt || ''}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.inputHolder}\n >\n <EditableHtml\n className={classes.input}\n markup={model.teacherInstructions || ''}\n onChange={this.changeTeacherInstructions}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.inputHolder}\n >\n <EditableHtml\n className={classes.input}\n markup={model.rationale || ''}\n onChange={this.changeRationale}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <Categories\n imageSupport={imageSupport}\n model={model}\n categories={categories || []}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Responses\"\n buttonLabel=\"ADD AN ALTERNATE RESPONSE\"\n onAdd={this.onAddAlternateResponse}\n />\n\n {alternateResponses.map((categoriesList, index) => {\n return (\n <React.Fragment key={index}>\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Response\"\n buttonLabel=\"REMOVE ALTERNATE RESPONSE\"\n onAdd={() => this.onRemoveAlternateResponse(index)}\n />\n\n <AlternateResponses\n altIndex={index}\n imageSupport={imageSupport}\n model={model}\n categories={categoriesList}\n onModelChanged={this.updateModel}\n />\n </React.Fragment>\n );\n })}\n\n <Divider />\n <Choices\n imageSupport={imageSupport}\n choices={choices}\n model={model}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n\n {feedbackEnabled && (\n <FeedbackConfig\n feedback={model.feedback}\n onChange={this.changeFeedback}\n toolbarOpts={toolbarOpts}\n />\n )}\n </div>\n </layout.ConfigLayout>\n </IdProvider>\n );\n }\n}\n\nconst styles = (theme) => ({\n alternatesHeader: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n text: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n design: {\n paddingTop: theme.spacing.unit,\n paddingBottom: theme.spacing.unit,\n },\n inputHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n input: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n maxWidth: '600px',\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n title: {\n marginBottom: '30px',\n },\n});\n\nexport default withDragContext(withStyles(styles)(Design));\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/design/index.jsx"],"names":["Panel","settings","toggle","radio","IdProvider","uid","Provider","Design","props","model","onChange","updatedModel","correctResponse","choices","categories","map","c","id","label","h","content","categoryCount","rationale","teacherInstructions","feedback","updateModel","cr","alternateResponses","prompt","index","filter","alt","altIndex","choice","generateId","classes","className","imageSupport","configuration","onConfigurationChanged","partialScoring","lockChoiceOrder","studentInstructions","scoringType","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","feedbackEnabled","spellCheckEnabled","errors","toolbarOpts","toolbarEditorPosition","position","config","columns","correctResponseCount","countChoiceInCorrectResponse","Settings","Properties","studentInstructionsEnabled","design","promptHolder","onPromptChanged","inputHolder","input","changeTeacherInstructions","changeRationale","alternatesHeader","onAddAlternateResponse","categoriesList","onRemoveAlternateResponse","changeFeedback","React","Component","PropTypes","object","isRequired","string","func","shape","add","styles","theme","paddingTop","spacing","unit","paddingBottom","text","width","marginBottom","maxWidth","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAAiCC,kBAAjC,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAAiCD,kBAAjC,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAAiCF,kBAAjC,CAAuBE,KAAvB;AACA,IAAkBC,UAAlB,GAAiCC,SAAjC,CAAQC,QAAR;;IAEaC,M;;;;;AAeX,kBAAYC,MAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,MAAN;AADiB,o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AAFvB,KATiB;AAazBtB,IAAAA,WAAW,EAAE;AACXyB,MAAAA,KAAK,EAAE,MADI;AAEXF,MAAAA,aAAa,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAFzB;AAGXI,MAAAA,YAAY,EAAEP,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAHxB,KAbY;AAkBzBrB,IAAAA,KAAK,EAAE;AACLmB,MAAAA,UAAU,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAD5B;AAELG,MAAAA,KAAK,EAAE,MAFF;AAGLE,MAAAA,QAAQ,EAAE;AAHL,KAlBkB;AAuBzB/D,IAAAA,MAAM,EAAE;AACNwD,MAAAA,UAAU,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENG,MAAAA,KAAK,EAAE;AAFD,KAvBiB;AA2BzB3B,IAAAA,YAAY,EAAE;AACZ2B,MAAAA,KAAK,EAAE,MADK;AAEZF,MAAAA,aAAa,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZI,MAAAA,YAAY,EAAEP,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KA3BW;AAgCzBM,IAAAA,KAAK,EAAE;AACLF,MAAAA,YAAY,EAAE;AADT;AAhCkB,GAAZ;AAAA,CAAf;;eAqCe,2BAAgB,wBAAWR,MAAX,EAAmB3E,MAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport {\n FeedbackConfig,\n InputContainer,\n layout,\n settings,\n} from '@pie-lib/config-ui';\nimport {\n countInAnswer,\n ensureNoExtraChoicesInAnswer,\n} from '@pie-lib/categorize';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { uid, withDragContext } from '@pie-lib/drag';\n\nimport Categories from './categories';\nimport AlternateResponses from './categories/alternateResponses';\nimport Choices from './choices';\nimport { Divider } from './buttons';\nimport { buildAlternateResponses, buildCategories } from './builder';\nimport Header from './header';\n\nconst { Panel, toggle, radio } = settings;\nconst { Provider: IdProvider } = uid;\n\nexport class Design extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n className: PropTypes.string,\n onConfigurationChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n uid: PropTypes.string,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n constructor(props) {\n super(props);\n this.uid = props.uid || uid.generateId();\n }\n\n updateModel = (props) => {\n const { model, onChange } = this.props;\n\n const updatedModel = {\n ...model,\n ...props,\n };\n\n //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.\n updatedModel.correctResponse = ensureNoExtraChoicesInAnswer(\n updatedModel.correctResponse || [],\n updatedModel.choices\n );\n\n //clean categories\n updatedModel.categories = updatedModel.categories.map((c) => ({\n id: c.id,\n label: c.label,\n }));\n\n updatedModel.choices = updatedModel.choices.map((h) => ({\n id: h.id,\n content: h.content,\n categoryCount: h.categoryCount,\n }));\n\n onChange(updatedModel);\n };\n\n changeRationale = (rationale) => {\n const { model, onChange } = this.props;\n\n onChange({\n ...model,\n rationale,\n });\n };\n\n changeTeacherInstructions = (teacherInstructions) => {\n const { model, onChange } = this.props;\n\n onChange({\n ...model,\n teacherInstructions,\n });\n };\n\n changeFeedback = (feedback) => {\n this.updateModel({ feedback });\n };\n\n onAddAlternateResponse = () => {\n const {\n model: { correctResponse },\n } = this.props;\n\n this.updateModel({\n correctResponse: (correctResponse || []).map((cr) => ({\n ...cr,\n alternateResponses: [...(cr.alternateResponses || []), []],\n })),\n });\n };\n\n onPromptChanged = (prompt) => this.updateModel({ prompt });\n\n onRemoveAlternateResponse = (index) => {\n const {\n model: { correctResponse },\n } = this.props;\n\n this.updateModel({\n correctResponse: (correctResponse || []).map((cr) => ({\n ...cr,\n alternateResponses: (cr.alternateResponses || []).filter(\n (alt, altIndex) => altIndex !== index\n ),\n })),\n });\n };\n\n countChoiceInCorrectResponse = (choice) => {\n const { model } = this.props;\n\n return countInAnswer(choice.id, model.correctResponse);\n };\n\n render() {\n const {\n classes,\n className,\n model,\n imageSupport,\n configuration,\n onChange,\n onConfigurationChanged,\n } = this.props;\n const {\n partialScoring = {},\n lockChoiceOrder = {},\n teacherInstructions = {},\n studentInstructions = {},\n rationale = {},\n scoringType = {},\n feedback = {},\n prompt = {},\n spellCheck = {},\n } = configuration || {};\n const {\n teacherInstructionsEnabled,\n promptEnabled,\n rationaleEnabled,\n feedbackEnabled,\n spellCheckEnabled,\n errors\n } = model || {};\n\n const toolbarOpts = {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n const config = model.config || {};\n config.choices = config.choices || { label: '', columns: 2 };\n\n const categories = buildCategories(\n model.categories || [],\n model.choices || [],\n model.correctResponse || []\n );\n\n const alternateResponses = buildAlternateResponses(\n model.categories || [],\n model.choices || [],\n model.correctResponse || []\n );\n\n const choices = model.choices.map((c) => {\n c.correctResponseCount = this.countChoiceInCorrectResponse(c);\n return c;\n });\n\n return (\n <IdProvider value={this.uid}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onChange}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder:\n lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, ['auto', 'rubric']),\n },\n }}\n />\n }\n >\n <div className={classNames(classes.design, className)}>\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt || ''}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.inputHolder}\n >\n <EditableHtml\n className={classes.input}\n markup={model.teacherInstructions || ''}\n onChange={this.changeTeacherInstructions}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.inputHolder}\n >\n <EditableHtml\n className={classes.input}\n markup={model.rationale || ''}\n onChange={this.changeRationale}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <Categories\n imageSupport={imageSupport}\n model={model}\n categories={categories || []}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n />\n\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Responses\"\n buttonLabel=\"ADD AN ALTERNATE RESPONSE\"\n onAdd={this.onAddAlternateResponse}\n />\n\n {alternateResponses.map((categoriesList, index) => {\n return (\n <React.Fragment key={index}>\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Response\"\n buttonLabel=\"REMOVE ALTERNATE RESPONSE\"\n onAdd={() => this.onRemoveAlternateResponse(index)}\n />\n\n <AlternateResponses\n altIndex={index}\n imageSupport={imageSupport}\n model={model}\n categories={categoriesList}\n onModelChanged={this.updateModel}\n />\n </React.Fragment>\n );\n })}\n\n <Divider />\n <Choices\n imageSupport={imageSupport}\n choices={choices}\n model={model}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n />\n\n {feedbackEnabled && (\n <FeedbackConfig\n feedback={model.feedback}\n onChange={this.changeFeedback}\n toolbarOpts={toolbarOpts}\n />\n )}\n </div>\n </layout.ConfigLayout>\n </IdProvider>\n );\n }\n}\n\nconst styles = (theme) => ({\n alternatesHeader: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n text: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n design: {\n paddingTop: theme.spacing.unit,\n paddingBottom: theme.spacing.unit,\n },\n inputHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n input: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n maxWidth: '600px',\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n title: {\n marginBottom: '30px',\n },\n});\n\nexport default withDragContext(withStyles(styles)(Design));\n"],"file":"index.js"}
|
|
@@ -53,7 +53,8 @@ var InputHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
53
53
|
className = _this$props.className,
|
|
54
54
|
imageSupport = _this$props.imageSupport,
|
|
55
55
|
toolbarOpts = _this$props.toolbarOpts,
|
|
56
|
-
spellCheck = _this$props.spellCheck
|
|
56
|
+
spellCheck = _this$props.spellCheck,
|
|
57
|
+
error = _this$props.error;
|
|
57
58
|
var choicePlugins = {
|
|
58
59
|
audio: {
|
|
59
60
|
disabled: true
|
|
@@ -73,7 +74,8 @@ var InputHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
73
74
|
className: classes.editor,
|
|
74
75
|
pluginProps: choicePlugins,
|
|
75
76
|
toolbarOpts: toolbarOpts,
|
|
76
|
-
spellCheck: spellCheck
|
|
77
|
+
spellCheck: spellCheck,
|
|
78
|
+
error: error
|
|
77
79
|
}));
|
|
78
80
|
}
|
|
79
81
|
}]);
|
|
@@ -91,7 +93,8 @@ exports.InputHeader = InputHeader;
|
|
|
91
93
|
add: _propTypes["default"].func.isRequired,
|
|
92
94
|
"delete": _propTypes["default"].func.isRequired
|
|
93
95
|
}),
|
|
94
|
-
toolbarOpts: _propTypes["default"].object
|
|
96
|
+
toolbarOpts: _propTypes["default"].object,
|
|
97
|
+
error: _propTypes["default"].string
|
|
95
98
|
});
|
|
96
99
|
(0, _defineProperty2["default"])(InputHeader, "defaultProps", {});
|
|
97
100
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/design/input-header.jsx"],"names":["InputHeader","props","onChange","label","classes","className","imageSupport","toolbarOpts","spellCheck","choicePlugins","audio","disabled","video","inputHeader","editor","React","Component","PropTypes","object","isRequired","string","func","onDelete","shape","add","styles","theme","flex","paddingBottom","spacing","unit","iconButtonRoot","width","height","display","justifyContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,W;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/design/input-header.jsx"],"names":["InputHeader","props","onChange","label","classes","className","imageSupport","toolbarOpts","spellCheck","error","choicePlugins","audio","disabled","video","inputHeader","editor","React","Component","PropTypes","object","isRequired","string","func","onDelete","shape","add","styles","theme","flex","paddingBottom","spacing","unit","iconButtonRoot","width","height","display","justifyContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,W;;;;;;;;;;;;WAgBX,kBAAS;AACP,wBAA8F,KAAKC,KAAnG;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,KAAlB,eAAk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AQF,sBAAUI,IAAV,CAAeF;AAFK,GAAhB,CANG;AAUjBb,EAAAA,WAAW,EAAEW,sBAAUC,MAVN;AAWjBV,EAAAA,KAAK,EAAES,sBAAUG;AAXA,C;iCADRrB,W,kBAeW,E;;AA0BxB,IAAM0B,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBZ,IAAAA,MAAM,EAAE;AACNa,MAAAA,IAAI,EAAE,GADA;AAENC,MAAAA,aAAa,EAAEF,KAAK,CAACG,OAAN,CAAcC;AAFvB,KADe;AAKvBC,IAAAA,cAAc,EAAE;AACdC,MAAAA,KAAK,EAAE,MADO;AAEdC,MAAAA,MAAM,EAAE;AAFM,KALO;AASvBpB,IAAAA,WAAW,EAAE;AACXqB,MAAAA,OAAO,EAAE,MADE;AAEXC,MAAAA,cAAc,EAAE;AAFL;AATU,GAAL;AAAA,CAApB;;eAce,wBAAWV,MAAX,EAAmB1B,WAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport EditableHtml from '@pie-lib/editable-html';\n\nexport class InputHeader extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n label: PropTypes.string,\n onChange: PropTypes.func,\n onDelete: PropTypes.func,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n }),\n toolbarOpts: PropTypes.object,\n error: PropTypes.string,\n };\n\n static defaultProps = {};\n render() {\n const { onChange, label, classes, className, imageSupport, toolbarOpts, spellCheck, error } = this.props;\n const choicePlugins = {\n audio: { disabled: true },\n video: { disabled: true }\n };\n\n return (\n <div className={classNames(classes.inputHeader, className)}>\n <EditableHtml\n imageSupport={imageSupport}\n autoWidthToolbar\n label={'label'}\n markup={label}\n onChange={onChange}\n className={classes.editor}\n pluginProps={choicePlugins}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n error={error}\n />\n </div>\n );\n }\n}\nconst styles = theme => ({\n editor: {\n flex: '1',\n paddingBottom: theme.spacing.unit\n },\n iconButtonRoot: {\n width: 'auto',\n height: 'auto'\n },\n inputHeader: {\n display: 'flex',\n justifyContent: 'space-between'\n }\n});\nexport default withStyles(styles)(InputHeader);\n"],"file":"input-header.js"}
|
|
@@ -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.23",
|
|
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.0",
|
|
17
17
|
"@pie-lib/drag": "^1.1.52",
|
|
18
|
-
"@pie-lib/editable-html": "^7.
|
|
19
|
-
"@pie-lib/render-ui": "^4.12.
|
|
18
|
+
"@pie-lib/editable-html": "^7.22.3",
|
|
19
|
+
"@pie-lib/render-ui": "^4.12.6",
|
|
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,14 @@
|
|
|
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.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/categorize-controller@5.2.7...@pie-element/categorize-controller@5.2.8) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/categorize-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [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
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/categorize-controller
|
package/controller/lib/index.js
CHANGED
|
@@ -12,9 +12,12 @@ Object.defineProperty(exports, "score", {
|
|
|
12
12
|
return _categorize.score;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
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"));
|
|
@@ -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;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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AAO,CAAC;AACN3B,QAAAA,KAAK,EAAEc,aAAa,CAACC,QAAD,EAAWC,OAAX,EAAoBC,GAApB,CADd;AAEN6C,QAAAA,KAAK,EAAE,CAAC9C,OAAD,IAAY,yBAAQA,OAAR;AAFb,OAAD,CAAP;AAID,KALM,CAAP;AAMD;AACF,CAbM;;;;AAeA,IAAM+C,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAChD,QAAD,EAAWE,GAAX,EAAmB;AAC7D,SAAO,IAAIS,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,gBAAuBV,GAAG,IAAI,EAA9B;AAAA,QAAQW,IAAR,SAAQA,IAAR;AAAA,QAAcc,IAAd,SAAcA,IAAd;;AAEA,QAAId,IAAI,KAAK,UAAT,IAAuBc,IAAI,KAAK,YAApC,EAAkD;AAChD,UAAQjD,eAAR,GAA4BsB,QAA5B,CAAQtB,eAAR;AAEAkC,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,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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
|
@@ -99,6 +99,21 @@
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
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
|
+
},
|
|
102
117
|
"showPrompt": {
|
|
103
118
|
"description": "Determines whether prompt field will be displayed or not",
|
|
104
119
|
"default": true,
|
|
@@ -74,6 +74,18 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
74
74
|
|
|
75
75
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
76
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
|
+
|
|
77
89
|
# `showPrompt` (boolean)
|
|
78
90
|
|
|
79
91
|
Determines whether prompt field will be displayed or not
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "6.9.
|
|
7
|
+
"version": "6.9.19",
|
|
8
8
|
"description": "",
|
|
9
9
|
"author": "pie framework developers",
|
|
10
10
|
"license": "ISC",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"@material-ui/core": "^3.9.2",
|
|
13
13
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
14
14
|
"@pie-lib/categorize": "^0.6.24",
|
|
15
|
-
"@pie-lib/correct-answer-toggle": "^2.3.
|
|
15
|
+
"@pie-lib/correct-answer-toggle": "^2.3.36",
|
|
16
16
|
"@pie-lib/drag": "^1.1.52",
|
|
17
|
-
"@pie-lib/math-rendering": "^2.
|
|
18
|
-
"@pie-lib/render-ui": "^4.12.
|
|
17
|
+
"@pie-lib/math-rendering": "^2.4.0",
|
|
18
|
+
"@pie-lib/render-ui": "^4.12.6",
|
|
19
19
|
"classnames": "^2.2.5",
|
|
20
20
|
"debug": "^4.1.1",
|
|
21
21
|
"lodash": "^4.17.15",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-dnd": "^9.3.2",
|
|
25
25
|
"react-dom": "^16.8.1"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "8ea971e13e74d785cd35a04fd9fe1abe1fa2dabf",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postpublish": "../../scripts/postpublish"
|
|
30
30
|
},
|