@pie-element/categorize 8.0.2-next.3 → 8.0.2-next.45
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/configure/lib/defaults.js +6 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/categories/index.js +14 -4
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/index.js +100 -55
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/utils.js +14 -1
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +1 -1
- package/controller/lib/defaults.js +1 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +3 -2
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/pie-schema.json +12 -0
- package/docs/pie-schema.json.md +8 -0
- package/lib/categorize/index.js +68 -13
- package/lib/categorize/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -15,6 +15,8 @@ var _default = {
|
|
|
15
15
|
lockChoiceOrder: true,
|
|
16
16
|
allowMultiplePlacementsEnabled: _utils.multiplePlacements.enabled,
|
|
17
17
|
allowAlternateEnabled: false,
|
|
18
|
+
allowMaxChoicesPerCategory: false,
|
|
19
|
+
maxChoicesPerCategory: 0,
|
|
18
20
|
categoriesPerRow: 2,
|
|
19
21
|
categories: [],
|
|
20
22
|
alternates: [],
|
|
@@ -51,6 +53,10 @@ var _default = {
|
|
|
51
53
|
settings: true,
|
|
52
54
|
label: 'Allow Multiple Placements'
|
|
53
55
|
},
|
|
56
|
+
maxPlacements: {
|
|
57
|
+
settings: true,
|
|
58
|
+
label: 'Max choices per category'
|
|
59
|
+
},
|
|
54
60
|
allowAlternate: {
|
|
55
61
|
settings: true,
|
|
56
62
|
label: 'Allow Alternate Correct Answers'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","choices","choicesPosition","choicesLabel","lockChoiceOrder","allowMultiplePlacementsEnabled","multiplePlacements","enabled","allowAlternateEnabled","categoriesPerRow","categories","alternates","correctResponse","rowLabels","partialScoring","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition","configuration","spellCheck","label","settings","feedback","allowMultiplePlacements","allowAlternate","prompt","rationale","scoringType","settingsPanelDisabled","studentInstructions","teacherInstructions","maxImageWidth","rowLabel","categoryLabel","maxImageHeight","withRubric","minCategoriesPerRow","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,EADJ;AAELC,IAAAA,eAAe,EAAE,OAFZ;AAGLC,IAAAA,YAAY,EAAE,EAHT;AAILC,IAAAA,eAAe,EAAE,IAJZ;AAKLC,IAAAA,8BAA8B,EAAEC,0BAAmBC,OAL9C;AAMLC,IAAAA,qBAAqB,EAAE,KANlB;AAOLC,IAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","choices","choicesPosition","choicesLabel","lockChoiceOrder","allowMultiplePlacementsEnabled","multiplePlacements","enabled","allowAlternateEnabled","allowMaxChoicesPerCategory","maxChoicesPerCategory","categoriesPerRow","categories","alternates","correctResponse","rowLabels","partialScoring","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition","configuration","spellCheck","label","settings","feedback","allowMultiplePlacements","maxPlacements","allowAlternate","prompt","rationale","scoringType","settingsPanelDisabled","studentInstructions","teacherInstructions","maxImageWidth","rowLabel","categoryLabel","maxImageHeight","withRubric","minCategoriesPerRow","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,EADJ;AAELC,IAAAA,eAAe,EAAE,OAFZ;AAGLC,IAAAA,YAAY,EAAE,EAHT;AAILC,IAAAA,eAAe,EAAE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,IAAAA,cAAc,EAAE;AACdJ,MAAAA,mBAAmB,EAAE,GADP;AAEdL,MAAAA,MAAM,EAAE,GAFM;AAGdC,MAAAA,SAAS,EAAE,GAHG;AAIdM,MAAAA,QAAQ,EAAE,GAJI;AAKdC,MAAAA,aAAa,EAAE,GALD;AAMdtC,MAAAA,OAAO,EAAE;AANK,KAxEH;AAgFbwC,IAAAA,UAAU,EAAE;AACVf,MAAAA,QAAQ,EAAE,KADA;AAEVD,MAAAA,KAAK,EAAE;AAFG,KAhFC;AAoFbiB,IAAAA,mBAAmB,EAAE,CApFR;AAqFbC,IAAAA,aAAa,EAAE;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,UAAU,EAAE;AAFC,KArFF;AAyFbC,IAAAA,QAAQ,EAAE;AACRpB,MAAAA,QAAQ,EAAE,KADF;AAERD,MAAAA,KAAK,EAAE,kBAFC;AAGRlB,MAAAA,OAAO,EAAE;AAHD,KAzFG;AA8FbwC,IAAAA,eAAe,EAAE;AACftB,MAAAA,KAAK,EAAE,kBADQ;AAEfuB,MAAAA,OAAO,EAAE;AAFM;AA9FJ;AAvBF,C","sourcesContent":["import { multiplePlacements } from './utils';\n\nexport default {\n model: {\n choices: [],\n choicesPosition: 'below',\n choicesLabel: '',\n lockChoiceOrder: true,\n allowMultiplePlacementsEnabled: multiplePlacements.enabled,\n allowAlternateEnabled: false,\n allowMaxChoicesPerCategory: false,\n maxChoicesPerCategory: 0,\n categoriesPerRow: 2,\n categories: [],\n alternates: [],\n correctResponse: [],\n rowLabels: [''],\n partialScoring: true,\n feedbackEnabled: false,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n feedback: {\n settings: true,\n label: 'Feedback',\n enabled: true,\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n choicesPosition: {\n settings: true,\n label: 'Choices Position',\n },\n allowMultiplePlacements: {\n settings: true,\n label: 'Allow Multiple Placements',\n },\n maxPlacements: {\n settings: true,\n label: 'Max choices per category',\n },\n allowAlternate: {\n settings: true,\n label: 'Allow Alternate Correct Answers',\n },\n categoriesPerRow: {\n settings: true,\n label: 'Categories per row',\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type',\n },\n settingsPanelDisabled: false,\n studentInstructions: {\n settings: false,\n label: 'Student Instructions',\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n },\n toolbarEditorPosition: {\n settings: false,\n label: 'Toolbar Editor Position',\n },\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n rowLabel: 200,\n categoryLabel: 260,\n choices: 240,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n rowLabel: 100,\n categoryLabel: 100,\n choices: 150,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n minCategoriesPerRow: 1,\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n },\n};\n"],"file":"defaults.js"}
|
|
@@ -179,7 +179,9 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
179
179
|
_ref$choices = _ref.choices,
|
|
180
180
|
choices = _ref$choices === void 0 ? [] : _ref$choices,
|
|
181
181
|
_ref$correctResponse = _ref.correctResponse,
|
|
182
|
-
correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse
|
|
182
|
+
correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse,
|
|
183
|
+
_ref$maxChoicesPerCat = _ref.maxChoicesPerCategory,
|
|
184
|
+
maxChoicesPerCategory = _ref$maxChoicesPerCat === void 0 ? 0 : _ref$maxChoicesPerCat;
|
|
183
185
|
|
|
184
186
|
var choice = (choices || []).find(function (choice) {
|
|
185
187
|
return choice.id === addedChoice.id;
|
|
@@ -190,8 +192,11 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
190
192
|
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, correctResponse);
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
var maxCategoryChoices = (0, _utils.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
196
|
+
|
|
193
197
|
onModelChanged({
|
|
194
|
-
correctResponse: correctResponse
|
|
198
|
+
correctResponse: correctResponse,
|
|
199
|
+
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
195
200
|
});
|
|
196
201
|
});
|
|
197
202
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoiceFromCategory", function (category, choice, choiceIndex) {
|
|
@@ -211,7 +216,9 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
211
216
|
var _ref2 = model || {},
|
|
212
217
|
choices = _ref2.choices,
|
|
213
218
|
_ref2$correctResponse = _ref2.correctResponse,
|
|
214
|
-
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse
|
|
219
|
+
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse,
|
|
220
|
+
_ref2$maxChoicesPerCa = _ref2.maxChoicesPerCategory,
|
|
221
|
+
maxChoicesPerCategory = _ref2$maxChoicesPerCa === void 0 ? 0 : _ref2$maxChoicesPerCa;
|
|
215
222
|
|
|
216
223
|
var choice = (choices || []).find(function (choice) {
|
|
217
224
|
return choice.id === choiceId;
|
|
@@ -228,8 +235,11 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
228
235
|
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
|
|
229
236
|
}
|
|
230
237
|
|
|
238
|
+
var maxCategoryChoices = (0, _utils.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
239
|
+
|
|
231
240
|
onModelChanged({
|
|
232
|
-
correctResponse: correctResponse
|
|
241
|
+
correctResponse: correctResponse,
|
|
242
|
+
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
233
243
|
});
|
|
234
244
|
});
|
|
235
245
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRowLabel", function (val, index) {
|
|
@@ -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","tooltip","fontSize","typography","whiteSpace","maxWidth","errorText","color","palette","error","main","paddingTop","Categories","focusedEl","props","model","oldCategories","categoriesPerRow","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","setState","onModelChanged","concat","category","index","findIndex","splice","correctResponse","c","addedChoice","categoryId","choices","choice","find","undefined","categoryCount","choiceIndex","choiceId","from","to","val","newRowLabels","classes","className","imageSupport","uploadSoundSupport","toolbarOpts","spellCheck","configuration","defaultImageMaxHeight","defaultImageMaxWidth","mathMlOptions","errors","associationError","categoriesError","categoriesErrors","maxCategories","maxImageWidth","maxImageHeight","holderStyle","validationMessage","add","marginLeft","hasRowLabel","rowIndex","changeRowLabel","state","deleteFocusedEl","change","addChoiceToCategory","moveChoice","deleteChoiceFromCategory","categoryLabel","React","Component","PropTypes","number","shape","func","isRequired","object","string","array","bool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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AfP;AAgBjB/B,EAAAA,aAAa,EAAE2B,sBAAUK,MAAV,CAAiBD,UAhBf;AAiBjBjC,EAAAA,WAAW,EAAE6B,sBAAUK,MAjBN;AAkBjBjC,EAAAA,UAAU,EAAE4B,sBAAUQ;AAlBL,C;;eAsON,wBAAW7G,MAAX,EAAmB6B,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { choiceUtils as utils } from '@pie-lib/pie-toolbox/config-ui';\nimport classNames from 'classnames';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n moveChoiceToCategory,\n removeCategory,\n removeChoiceFromCategory,\n verifyAllowMultiplePlacements,\n} from '@pie-lib/pie-toolbox/categorize';\n\nimport Category from './category';\nimport Header from '../header';\nimport { generateValidationMessage } from '../../utils';\nimport { RowLabel } from './RowLabel';\n\nconst styles = (theme) => ({\n categories: {\n marginBottom: theme.spacing.unit * 3,\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: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit / 2,\n },\n});\n\nexport class Categories extends React.Component {\n static propTypes = {\n defaultImageMaxHeight: PropTypes.number,\n defaultImageMaxWidth: PropTypes.number,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: 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 spellCheck: PropTypes.bool,\n };\n\n state = {\n focusedEl: null,\n };\n\n add = () => {\n const { model, categories: oldCategories } = this.props;\n const { categoriesPerRow } = model;\n const id = utils.firstAvailableIndex(\n model.categories.map((a) => a.id),\n 0,\n );\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.setState(\n {\n focusedEl: oldCategories.length,\n },\n () => {\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data]),\n });\n },\n );\n };\n\n deleteFocusedEl = () => {\n this.setState({\n focusedEl: null,\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(category.id, model.correctResponse);\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 = (addedChoice, categoryId) => {\n const { model, onModelChanged } = this.props;\n let { choices = [], correctResponse = [] } = model || {};\n const choice = (choices || []).find((choice) => choice.id === addedChoice.id);\n correctResponse = moveChoiceToCategory(addedChoice.id, undefined, categoryId, 0, model.correctResponse);\n // if multiplePlacements not allowed, ensure the consistency in the other categories\n if (choice.categoryCount !== 0) {\n correctResponse = verifyAllowMultiplePlacements(addedChoice, categoryId, correctResponse);\n }\n onModelChanged({ correctResponse });\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);\n\n onModelChanged({ correctResponse });\n };\n\n moveChoice = (choiceId, from, to, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n let { choices, correctResponse = [] } = model || {};\n const choice = (choices || []).find((choice) => choice.id === choiceId);\n if (to === from || !choice) {\n return;\n }\n if (choice.categoryCount !== 0) {\n correctResponse = moveChoiceToCategory(choice.id, from, to, choiceIndex, correctResponse);\n correctResponse = verifyAllowMultiplePlacements(choice, to, correctResponse);\n } else if (choice.categoryCount === 0) {\n correctResponse = moveChoiceToCategory(choice.id, undefined, to, 0, correctResponse);\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 uploadSoundSupport,\n toolbarOpts,\n spellCheck,\n configuration,\n defaultImageMaxHeight,\n defaultImageMaxWidth,\n mathMlOptions = {}\n } = this.props;\n\n const { categoriesPerRow, rowLabels, errors } = model;\n const { associationError, categoriesError, categoriesErrors } = errors || {};\n const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = 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={\n <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 }\n buttonDisabled={maxCategories && categories && maxCategories === categories.length}\n />\n\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 key={index}>\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n disabled={false}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n )}\n\n <Category\n imageSupport={imageSupport}\n focusedEl={this.state.focusedEl}\n deleteFocusedEl={this.deleteFocusedEl}\n index={index}\n category={category}\n error={categoriesErrors && categoriesErrors[category.id]}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n onAddChoice={this.addChoiceToCategory}\n onMoveChoice={(choiceId, from, to, choiceIndex) => this.moveChoice(choiceId, from, to, choiceIndex)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}\n maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n />\n </React.Fragment>\n );\n })}\n </div>\n\n {associationError && <div className={classes.errorText}>{associationError}</div>}\n {categoriesError && <div className={classes.errorText}>{categoriesError}</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","typography","whiteSpace","maxWidth","errorText","color","palette","error","main","paddingTop","Categories","focusedEl","props","model","oldCategories","categoriesPerRow","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","setState","onModelChanged","concat","category","index","findIndex","splice","correctResponse","c","addedChoice","categoryId","choices","maxChoicesPerCategory","choice","find","undefined","categoryCount","maxCategoryChoices","choiceIndex","choiceId","from","to","val","newRowLabels","classes","className","imageSupport","uploadSoundSupport","toolbarOpts","spellCheck","configuration","defaultImageMaxHeight","defaultImageMaxWidth","mathMlOptions","errors","associationError","categoriesError","categoriesErrors","maxCategories","maxImageWidth","maxImageHeight","holderStyle","validationMessage","add","marginLeft","hasRowLabel","rowIndex","changeRowLabel","state","deleteFocusedEl","change","addChoiceToCategory","moveChoice","deleteChoiceFromCategory","categoryLabel","React","Component","PropTypes","number","shape","func","isRequired","object","string","array","bool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB;AADzB,KADa;AAIzBC,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,KAJO;AASzBK,IAAAA,GAAG,EAAE;AACHH,MAAAA,OAAO,EAAE,MADN;AAEHI,MAAAA,mBAAmB,EAAE,gBAFlB;AAGHF,MAAAA,aA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AUK,MAAV,CAAiBD,UAhBf;AAiBjBjC,EAAAA,WAAW,EAAE6B,sBAAUK,MAjBN;AAkBjBjC,EAAAA,UAAU,EAAE4B,sBAAUQ;AAlBL,C;;eA0ON,wBAAW/G,MAAX,EAAmB6B,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { choiceUtils as utils } from '@pie-lib/pie-toolbox/config-ui';\nimport classNames from 'classnames';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n moveChoiceToCategory,\n removeCategory,\n removeChoiceFromCategory,\n verifyAllowMultiplePlacements,\n} from '@pie-lib/pie-toolbox/categorize';\n\nimport Category from './category';\nimport Header from '../header';\nimport { generateValidationMessage, getMaxCategoryChoices } from '../../utils';\nimport { RowLabel } from './RowLabel';\n\nconst styles = (theme) => ({\n categories: {\n marginBottom: theme.spacing.unit * 3,\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: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit / 2,\n },\n});\n\nexport class Categories extends React.Component {\n static propTypes = {\n defaultImageMaxHeight: PropTypes.number,\n defaultImageMaxWidth: PropTypes.number,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: 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 spellCheck: PropTypes.bool,\n };\n\n state = {\n focusedEl: null,\n };\n\n add = () => {\n const { model, categories: oldCategories } = this.props;\n const { categoriesPerRow } = model;\n const id = utils.firstAvailableIndex(\n model.categories.map((a) => a.id),\n 0,\n );\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.setState(\n {\n focusedEl: oldCategories.length,\n },\n () => {\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data]),\n });\n },\n );\n };\n\n deleteFocusedEl = () => {\n this.setState({\n focusedEl: null,\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(category.id, model.correctResponse);\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 = (addedChoice, categoryId) => {\n const { model, onModelChanged } = this.props;\n let { choices = [], correctResponse = [], maxChoicesPerCategory = 0 } = model || {};\n const choice = (choices || []).find((choice) => choice.id === addedChoice.id);\n correctResponse = moveChoiceToCategory(addedChoice.id, undefined, categoryId, 0, model.correctResponse);\n // if multiplePlacements not allowed, ensure the consistency in the other categories\n if (choice.categoryCount !== 0) {\n correctResponse = verifyAllowMultiplePlacements(addedChoice, categoryId, correctResponse);\n }\n const maxCategoryChoices = getMaxCategoryChoices(model);\n // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated\n onModelChanged({ correctResponse, maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory });\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);\n\n onModelChanged({ correctResponse });\n };\n\n moveChoice = (choiceId, from, to, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n let { choices, correctResponse = [], maxChoicesPerCategory = 0 } = model || {};\n const choice = (choices || []).find((choice) => choice.id === choiceId);\n if (to === from || !choice) {\n return;\n }\n if (choice.categoryCount !== 0) {\n correctResponse = moveChoiceToCategory(choice.id, from, to, choiceIndex, correctResponse);\n correctResponse = verifyAllowMultiplePlacements(choice, to, correctResponse);\n } else if (choice.categoryCount === 0) {\n correctResponse = moveChoiceToCategory(choice.id, undefined, to, 0, correctResponse);\n }\n const maxCategoryChoices = getMaxCategoryChoices(model);\n // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated\n onModelChanged({ correctResponse, maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory });\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 uploadSoundSupport,\n toolbarOpts,\n spellCheck,\n configuration,\n defaultImageMaxHeight,\n defaultImageMaxWidth,\n mathMlOptions = {}\n } = this.props;\n\n const { categoriesPerRow, rowLabels, errors } = model;\n const { associationError, categoriesError, categoriesErrors } = errors || {};\n const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = 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={\n <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 }\n buttonDisabled={maxCategories && categories && maxCategories === categories.length}\n />\n\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 key={index}>\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n disabled={false}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n )}\n\n <Category\n imageSupport={imageSupport}\n focusedEl={this.state.focusedEl}\n deleteFocusedEl={this.deleteFocusedEl}\n index={index}\n category={category}\n error={categoriesErrors && categoriesErrors[category.id]}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n onAddChoice={this.addChoiceToCategory}\n onMoveChoice={(choiceId, from, to, choiceIndex) => this.moveChoice(choiceId, from, to, choiceIndex)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}\n maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n />\n </React.Fragment>\n );\n })}\n </div>\n\n {associationError && <div className={classes.errorText}>{associationError}</div>}\n {categoriesError && <div className={classes.errorText}>{categoriesError}</div>}\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(Categories);\n"],"file":"index.js"}
|
|
@@ -49,6 +49,8 @@ var _header = _interopRequireDefault(require("./header"));
|
|
|
49
49
|
|
|
50
50
|
var _utils = require("../utils");
|
|
51
51
|
|
|
52
|
+
var _translator = _interopRequireDefault(require("@pie-lib/pie-toolbox/translator"));
|
|
53
|
+
|
|
52
54
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
55
|
|
|
54
56
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -57,6 +59,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
57
59
|
|
|
58
60
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
59
61
|
|
|
62
|
+
var translator = _translator["default"].translator;
|
|
60
63
|
var dropdown = _configUi.settings.dropdown,
|
|
61
64
|
Panel = _configUi.settings.Panel,
|
|
62
65
|
toggle = _configUi.settings.toggle,
|
|
@@ -103,7 +106,9 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
103
106
|
content: h.content,
|
|
104
107
|
categoryCount: h.categoryCount
|
|
105
108
|
};
|
|
106
|
-
});
|
|
109
|
+
}); // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)
|
|
110
|
+
|
|
111
|
+
updatedModel.maxChoicesPerCategory = updatedModel.allowMaxChoicesPerCategory ? updatedModel.maxChoicesPerCategory : 0;
|
|
107
112
|
onChange(updatedModel);
|
|
108
113
|
});
|
|
109
114
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRationale", function (rationale) {
|
|
@@ -171,6 +176,25 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
171
176
|
|
|
172
177
|
return c.categoryCount || 0;
|
|
173
178
|
});
|
|
179
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isAlertModalOpened", function () {
|
|
180
|
+
var model = _this.props.model;
|
|
181
|
+
|
|
182
|
+
var _ref = model || {},
|
|
183
|
+
_ref$maxChoicesPerCat = _ref.maxChoicesPerCategory,
|
|
184
|
+
maxChoicesPerCategory = _ref$maxChoicesPerCat === void 0 ? 0 : _ref$maxChoicesPerCat;
|
|
185
|
+
|
|
186
|
+
var maxChoices = (0, _utils.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened
|
|
187
|
+
|
|
188
|
+
return maxChoicesPerCategory !== 0 ? maxChoices > maxChoicesPerCategory : false;
|
|
189
|
+
});
|
|
190
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAlertModalCancel", function () {
|
|
191
|
+
var model = _this.props.model;
|
|
192
|
+
var maxChoices = (0, _utils.getMaxCategoryChoices)(model);
|
|
193
|
+
|
|
194
|
+
_this.updateModel({
|
|
195
|
+
maxChoicesPerCategory: maxChoices
|
|
196
|
+
});
|
|
197
|
+
});
|
|
174
198
|
_this.uid = _props.uid || _drag.uid.generateId();
|
|
175
199
|
return _this;
|
|
176
200
|
}
|
|
@@ -188,59 +212,63 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
188
212
|
uploadSoundSupport = _this$props4.uploadSoundSupport,
|
|
189
213
|
onConfigurationChanged = _this$props4.onConfigurationChanged;
|
|
190
214
|
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
-
allowMultiplePlacements =
|
|
194
|
-
|
|
195
|
-
allowAlternate =
|
|
196
|
-
|
|
197
|
-
categoriesPerRow =
|
|
198
|
-
|
|
199
|
-
choicesPosition =
|
|
200
|
-
|
|
201
|
-
contentDimensions =
|
|
202
|
-
|
|
203
|
-
feedback =
|
|
204
|
-
|
|
205
|
-
lockChoiceOrder =
|
|
206
|
-
|
|
207
|
-
maxImageHeight =
|
|
208
|
-
|
|
209
|
-
maxImageWidth =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
215
|
+
var _ref2 = configuration || {},
|
|
216
|
+
_ref2$allowMultiplePl = _ref2.allowMultiplePlacements,
|
|
217
|
+
allowMultiplePlacements = _ref2$allowMultiplePl === void 0 ? {} : _ref2$allowMultiplePl,
|
|
218
|
+
_ref2$allowAlternate = _ref2.allowAlternate,
|
|
219
|
+
allowAlternate = _ref2$allowAlternate === void 0 ? {} : _ref2$allowAlternate,
|
|
220
|
+
_ref2$categoriesPerRo = _ref2.categoriesPerRow,
|
|
221
|
+
categoriesPerRow = _ref2$categoriesPerRo === void 0 ? {} : _ref2$categoriesPerRo,
|
|
222
|
+
_ref2$choicesPosition = _ref2.choicesPosition,
|
|
223
|
+
choicesPosition = _ref2$choicesPosition === void 0 ? {} : _ref2$choicesPosition,
|
|
224
|
+
_ref2$contentDimensio = _ref2.contentDimensions,
|
|
225
|
+
contentDimensions = _ref2$contentDimensio === void 0 ? {} : _ref2$contentDimensio,
|
|
226
|
+
_ref2$feedback = _ref2.feedback,
|
|
227
|
+
feedback = _ref2$feedback === void 0 ? {} : _ref2$feedback,
|
|
228
|
+
_ref2$lockChoiceOrder = _ref2.lockChoiceOrder,
|
|
229
|
+
lockChoiceOrder = _ref2$lockChoiceOrder === void 0 ? {} : _ref2$lockChoiceOrder,
|
|
230
|
+
_ref2$maxImageHeight = _ref2.maxImageHeight,
|
|
231
|
+
maxImageHeight = _ref2$maxImageHeight === void 0 ? {} : _ref2$maxImageHeight,
|
|
232
|
+
_ref2$maxImageWidth = _ref2.maxImageWidth,
|
|
233
|
+
maxImageWidth = _ref2$maxImageWidth === void 0 ? {} : _ref2$maxImageWidth,
|
|
234
|
+
_ref2$maxPlacements = _ref2.maxPlacements,
|
|
235
|
+
maxPlacements = _ref2$maxPlacements === void 0 ? {} : _ref2$maxPlacements,
|
|
236
|
+
_ref2$minCategoriesPe = _ref2.minCategoriesPerRow,
|
|
237
|
+
minCategoriesPerRow = _ref2$minCategoriesPe === void 0 ? 1 : _ref2$minCategoriesPe,
|
|
238
|
+
_ref2$partialScoring = _ref2.partialScoring,
|
|
239
|
+
partialScoring = _ref2$partialScoring === void 0 ? {} : _ref2$partialScoring,
|
|
240
|
+
_ref2$prompt = _ref2.prompt,
|
|
241
|
+
prompt = _ref2$prompt === void 0 ? {} : _ref2$prompt,
|
|
242
|
+
_ref2$rationale = _ref2.rationale,
|
|
243
|
+
rationale = _ref2$rationale === void 0 ? {} : _ref2$rationale,
|
|
244
|
+
_ref2$scoringType = _ref2.scoringType,
|
|
245
|
+
scoringType = _ref2$scoringType === void 0 ? {} : _ref2$scoringType,
|
|
246
|
+
settingsPanelDisabled = _ref2.settingsPanelDisabled,
|
|
247
|
+
_ref2$spellCheck = _ref2.spellCheck,
|
|
248
|
+
spellCheck = _ref2$spellCheck === void 0 ? {} : _ref2$spellCheck,
|
|
249
|
+
_ref2$studentInstruct = _ref2.studentInstructions,
|
|
250
|
+
studentInstructions = _ref2$studentInstruct === void 0 ? {} : _ref2$studentInstruct,
|
|
251
|
+
_ref2$teacherInstruct = _ref2.teacherInstructions,
|
|
252
|
+
teacherInstructions = _ref2$teacherInstruct === void 0 ? {} : _ref2$teacherInstruct,
|
|
253
|
+
_ref2$withRubric = _ref2.withRubric,
|
|
254
|
+
withRubric = _ref2$withRubric === void 0 ? {} : _ref2$withRubric,
|
|
255
|
+
_ref2$mathMlOptions = _ref2.mathMlOptions,
|
|
256
|
+
mathMlOptions = _ref2$mathMlOptions === void 0 ? {} : _ref2$mathMlOptions,
|
|
257
|
+
_ref2$language = _ref2.language,
|
|
258
|
+
language = _ref2$language === void 0 ? {} : _ref2$language,
|
|
259
|
+
_ref2$languageChoices = _ref2.languageChoices,
|
|
260
|
+
languageChoices = _ref2$languageChoices === void 0 ? {} : _ref2$languageChoices;
|
|
261
|
+
|
|
262
|
+
var _ref3 = model || {},
|
|
263
|
+
allowAlternateEnabled = _ref3.allowAlternateEnabled,
|
|
264
|
+
allowMaxChoicesPerCategory = _ref3.allowMaxChoicesPerCategory,
|
|
265
|
+
feedbackEnabled = _ref3.feedbackEnabled,
|
|
266
|
+
maxChoicesPerCategory = _ref3.maxChoicesPerCategory,
|
|
267
|
+
promptEnabled = _ref3.promptEnabled,
|
|
268
|
+
rationaleEnabled = _ref3.rationaleEnabled,
|
|
269
|
+
spellCheckEnabled = _ref3.spellCheckEnabled,
|
|
270
|
+
teacherInstructionsEnabled = _ref3.teacherInstructionsEnabled,
|
|
271
|
+
toolbarEditorPosition = _ref3.toolbarEditorPosition;
|
|
244
272
|
|
|
245
273
|
var toolbarOpts = {
|
|
246
274
|
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
@@ -268,6 +296,12 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
268
296
|
}),
|
|
269
297
|
choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
|
|
270
298
|
allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [_utils.multiplePlacements.enabled, _utils.multiplePlacements.disabled, _utils.multiplePlacements.perChoice]),
|
|
299
|
+
allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
|
|
300
|
+
maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
|
|
301
|
+
label: '',
|
|
302
|
+
min: 0,
|
|
303
|
+
max: 30
|
|
304
|
+
}),
|
|
271
305
|
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
272
306
|
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
273
307
|
// PD-2960: deleted temporary from settings panel
|
|
@@ -283,6 +317,11 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
283
317
|
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
|
|
284
318
|
rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
|
|
285
319
|
};
|
|
320
|
+
var isOpened = this.isAlertModalOpened();
|
|
321
|
+
var alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
|
|
322
|
+
lng: model.language,
|
|
323
|
+
maxChoicesPerCategory: maxChoicesPerCategory
|
|
324
|
+
});
|
|
286
325
|
return /*#__PURE__*/_react["default"].createElement(IdProvider, {
|
|
287
326
|
value: this.uid
|
|
288
327
|
}, /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
|
|
@@ -296,7 +335,13 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
296
335
|
groups: {
|
|
297
336
|
Settings: panelSettings,
|
|
298
337
|
Properties: panelProperties
|
|
299
|
-
}
|
|
338
|
+
},
|
|
339
|
+
modal: /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
340
|
+
title: 'Warning',
|
|
341
|
+
text: alertMaxChoicesMsg,
|
|
342
|
+
open: isOpened,
|
|
343
|
+
onClose: this.onAlertModalCancel
|
|
344
|
+
})
|
|
300
345
|
})
|
|
301
346
|
}, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
302
347
|
label: teacherInstructions.label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/design/index.jsx"],"names":["dropdown","settings","Panel","toggle","radio","numberField","IdProvider","uid","Provider","Design","props","model","onChange","updatedModel","choices","map","c","categoryCount","checkAllowMultiplePlacements","allowMultiplePlacementsEnabled","correctResponse","categories","id","label","h","content","rationale","teacherInstructions","feedback","updateModel","cr","alternateResponses","prompt","index","filter","alt","altIndex","choice","allowMultiplePlacements","multiplePlacements","enabled","disabled","generateId","classes","configuration","imageSupport","uploadSoundSupport","onConfigurationChanged","allowAlternate","categoriesPerRow","choicesPosition","contentDimensions","lockChoiceOrder","maxImageHeight","maxImageWidth","minCategoriesPerRow","partialScoring","scoringType","settingsPanelDisabled","spellCheck","studentInstructions","withRubric","mathMlOptions","language","languageChoices","allowAlternateEnabled","feedbackEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","toolbarOpts","position","config","columns","correctResponseCount","countChoiceInCorrectResponse","defaultImageMaxWidth","defaultImageMaxHeight","panelSettings","min","max","perChoice","options","panelProperties","studentInstructionsEnabled","rubricEnabled","Settings","Properties","inputContainer","input","changeTeacherInstructions","onPromptChanged","alternatesHeader","onAddAlternateResponse","categoriesList","onRemoveAlternateResponse","changeRationale","changeFeedback","React","Component","PropTypes","object","isRequired","className","string","func","shape","add","styles","theme","marginBottom","spacing","unit","text","paddingTop","paddingBottom","width","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,QAAR,GAAwDC,kBAAxD,CAAQD,QAAR;AAAA,IAAkBE,KAAlB,GAAwDD,kBAAxD,CAAkBC,KAAlB;AAAA,IAAyBC,MAAzB,GAAwDF,kBAAxD,CAAyBE,MAAzB;AAAA,IAAiCC,KAAjC,GAAwDH,kBAAxD,CAAiCG,KAAjC;AAAA,IAAwCC,WAAxC,GAAwDJ,kBAAxD,CAAwCI,WAAxC;AACA,IAAkBC,UAAlB,GAAiCC,SAAjC,CAAQC,QAAR;;IAEaC,M;;;;;AAmBX,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;;AAKAG,MAAAA,YAAY,CAACC,OAAb,GAAuBD,YAAY,CAACC,OAAb,CAAqBC,GAArB,CAAyB,UAACC,CAAD;AAAA,+CAC3CA,CAD2C;AAE9CC,UAAAA,aAAa,EAAE,MAAKC,4BAAL,CAAkCL,YAAY,CAACM,8BAA/C,EAA+EH,CAA/E;AAF+B;AAAA,OAAzB,CAAvB,CARuB,CAavB;;AACAH,MAAAA,YAAY,CAACO,eAAb,GAA+B,8CAC7BP,YAAY,CAACO,eAAb,IAAgC,EADH,EAE7BP,YAAY,CAACC,OAFgB,CAA/B,CAduB,C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Ad,GAAqB,CAFnB;AAGdF,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAHrB,KARS;AAazBK,IAAAA,KAAK,EAAE;AACLP,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAD9B;AAbkB,GAAZ;AAAA,CAAf;;eAkBe,2BAAgB,wBAAWJ,MAAX,EAAmBrG,MAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { FeedbackConfig, InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { countInAnswer, ensureNoExtraChoicesInAnswer, ensureNoExtraChoicesInAlternate } from '@pie-lib/pie-toolbox/categorize';\nimport EditableHtml from '@pie-lib/pie-toolbox/editable-html';\nimport { uid, withDragContext } from '@pie-lib/pie-toolbox/drag';\n\nimport Categories from './categories';\nimport AlternateResponses from './categories/alternateResponses';\nimport Choices from './choices';\nimport { buildAlternateResponses, buildCategories } from './builder';\nimport Header from './header';\nimport { multiplePlacements } from '../utils';\n\nconst { dropdown, Panel, toggle, radio, numberField } = 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 uploadSoundSupport: 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 updatedModel.choices = updatedModel.choices.map((c) => ({\n ...c,\n categoryCount: this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c),\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 //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.\n updatedModel.correctResponse = ensureNoExtraChoicesInAlternate(\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((alt, altIndex) => altIndex !== index),\n })),\n });\n };\n\n countChoiceInCorrectResponse = (choice) => {\n const { model } = this.props;\n\n return countInAnswer(choice.id, model.correctResponse);\n };\n\n checkAllowMultiplePlacements = (allowMultiplePlacements, c) => {\n if (allowMultiplePlacements === multiplePlacements.enabled) {\n return 0;\n }\n\n if (allowMultiplePlacements === multiplePlacements.disabled) {\n return 1;\n }\n\n return c.categoryCount || 0;\n };\n\n render() {\n const { classes, configuration, imageSupport, model, uploadSoundSupport, onConfigurationChanged } = this.props;\n const {\n allowMultiplePlacements = {},\n allowAlternate = {},\n categoriesPerRow = {},\n choicesPosition = {},\n contentDimensions = {},\n feedback = {},\n lockChoiceOrder = {},\n maxImageHeight = {},\n maxImageWidth = {},\n minCategoriesPerRow = 1,\n partialScoring = {},\n prompt = {},\n rationale = {},\n scoringType = {},\n settingsPanelDisabled,\n spellCheck = {},\n studentInstructions = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n allowAlternateEnabled,\n feedbackEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const config = model.config || {};\n config.choices = config.choices || { label: '', columns: 2 };\n\n const categories = buildCategories(model.categories || [], model.choices || [], model.correctResponse || []);\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\n return c;\n });\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n categoriesPerRow:\n categoriesPerRow.settings &&\n numberField(categoriesPerRow.label, {\n label: categoriesPerRow.label,\n min: minCategoriesPerRow,\n max: 6,\n }),\n choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),\n allowMultiplePlacementsEnabled:\n allowMultiplePlacements.settings &&\n dropdown(allowMultiplePlacements.label, [\n multiplePlacements.enabled,\n multiplePlacements.disabled,\n multiplePlacements.perChoice,\n ]),\n promptEnabled: prompt.settings && toggle(prompt.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n // PD-2960: deleted temporary from settings panel\n // allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n return (\n <IdProvider value={this.uid}>\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={this.updateModel}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.inputContainer}>\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 maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.inputContainer}>\n <EditableHtml\n className={classes.input}\n markup={model.prompt || ''}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.prompt}\n maxImageHeight={maxImageHeight && maxImageHeight.prompt}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n <Categories\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n model={model}\n categories={categories || []}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n />\n\n <Choices\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n choices={choices}\n model={model}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n />\n\n {allowAlternateEnabled && (\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Responses\"\n buttonLabel=\"ADD AN ALTERNATE RESPONSE\"\n onAdd={this.onAddAlternateResponse}\n />\n )}\n {allowAlternateEnabled &&\n alternateResponses.map((categoriesList, index) => {\n return (\n <React.Fragment key={index}>\n <Header\n className={classes.alternatesHeader}\n variant={'subtitle1'}\n label=\"Alternate Response\"\n buttonLabel=\"REMOVE ALTERNATE RESPONSE\"\n onAdd={() => this.onRemoveAlternateResponse(index)}\n />\n <AlternateResponses\n altIndex={index}\n imageSupport={imageSupport}\n model={model}\n configuration={configuration}\n categories={categoriesList}\n onModelChanged={this.updateModel}\n uploadSoundSupport={uploadSoundSupport}\n toolbarOpts={toolbarOpts}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n />\n </React.Fragment>\n );\n })}\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.inputContainer}>\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 maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n {feedbackEnabled && (\n <FeedbackConfig feedback={model.feedback} onChange={this.changeFeedback} toolbarOpts={toolbarOpts} />\n )}\n </layout.ConfigLayout>\n </IdProvider>\n );\n }\n}\n\nconst styles = (theme) => ({\n alternatesHeader: {\n marginBottom: theme.spacing.unit * 2,\n },\n text: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n inputContainer: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n title: {\n marginBottom: theme.spacing.unit * 4,\n },\n});\n\nexport default withDragContext(withStyles(styles)(Design));\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/design/index.jsx"],"names":["translator","Translator","dropdown","settings","Panel","toggle","radio","numberField","IdProvider","uid","Provider","Design","props","model","onChange","updatedModel","choices","map","c","categoryCount","checkAllowMultiplePlacements","allowMultiplePlacementsEnabled","correctResponse","categories","id","label","h","content","maxChoicesPerCategory","allowMaxChoicesPerCategory","rationale","teacherInstructions","feedback","updateModel","cr","alternateResponses","prompt","index","filter","alt","altIndex","choice","allowMultiplePlacements","multiplePlacements","enabled","disabled","maxChoices","generateId","classes","configuration","imageSupport","uploadSoundSupport","onConfigurationChanged","allowAlternate","categoriesPerRow","choicesPosition","contentDimensions","lockChoiceOrder","maxImageHeight","maxImageWidth","maxPlacements","minCategoriesPerRow","partialScoring","scoringType","settingsPanelDisabled","spellCheck","studentInstructions","withRubric","mathMlOptions","language","languageChoices","allowAlternateEnabled","feedbackEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","toolbarOpts","position","config","columns","correctResponseCount","countChoiceInCorrectResponse","defaultImageMaxWidth","defaultImageMaxHeight","panelSettings","min","max","perChoice","options","panelProperties","studentInstructionsEnabled","rubricEnabled","isOpened","isAlertModalOpened","alertMaxChoicesMsg","t","lng","Settings","Properties","onAlertModalCancel","inputContainer","input","changeTeacherInstructions","onPromptChanged","alternatesHeader","onAddAlternateResponse","categoriesList","onRemoveAlternateResponse","changeRationale","changeFeedback","React","Component","PropTypes","object","isRequired","className","string","func","shape","add","styles","theme","marginBottom","spacing","unit","text","paddingTop","paddingBottom","width","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AACA,IAAQE,QAAR,GAAwDC,kBAAxD,CAAQD,QAAR;AAAA,IAAkBE,KAAlB,GAAwDD,kBAAxD,CAAkBC,KAAlB;AAAA,IAAyBC,MAAzB,GAAwDF,kBAAxD,CAAyBE,MAAzB;AAAA,IAAiCC,KAAjC,GAAwDH,kBAAxD,CAAiCG,KAAjC;AAAA,IAAwCC,WAAxC,GAAwDJ,kBAAxD,CAAwCI,WAAxC;AACA,IAAkBC,UAAlB,GAAiCC,SAAjC,CAAQC,QAAR;;IAEaC,M;;;;;AAmBX,kBAAYC,MAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,MAAN;AADiB,oGAKL,UAACA,KAAD,EAAW;AACvB,wBAA4B,MAAKA,KAAjC;AAAA,UAA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,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CARG;AAYjBjE,EAAAA,kBAAkB,EAAE+D,sBAAUM,KAAV,CAAgB;AAClCC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADc;AAElC,cAAQF,sBAAUK,IAAV,CAAeH;AAFW,GAAhB;AAZH,C;;AA4ZrB,IAAMM,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBjB,IAAAA,gBAAgB,EAAE;AAChBkB,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AADnB,KADO;AAIzBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,UAAU,EAAEL,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAD7B;AAEJG,MAAAA,aAAa,EAAEN,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAFhC,KAJmB;AAQzBxB,IAAAA,cAAc,EAAE;AACd4B,MAAAA,KAAK,EAAE,MADO;AAEdF,MAAAA,UAAU,EAAEL,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAFnB;AAGdF,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAHrB,KARS;AAazBK,IAAAA,KAAK,EAAE;AACLP,MAAAA,YAAY,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AAD9B;AAbkB,GAAZ;AAAA,CAAf;;eAkBe,2BAAgB,wBAAWJ,MAAX,EAAmB/G,MAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { FeedbackConfig, InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { countInAnswer, ensureNoExtraChoicesInAnswer, ensureNoExtraChoicesInAlternate } from '@pie-lib/pie-toolbox/categorize';\nimport EditableHtml from '@pie-lib/pie-toolbox/editable-html';\nimport { uid, withDragContext } from '@pie-lib/pie-toolbox/drag';\n\nimport Categories from './categories';\nimport AlternateResponses from './categories/alternateResponses';\nimport Choices from './choices';\nimport { buildAlternateResponses, buildCategories } from './builder';\nimport Header from './header';\nimport { getMaxCategoryChoices, multiplePlacements } from '../utils';\nimport { AlertDialog } from '@pie-lib/pie-toolbox/config-ui';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\nconst { dropdown, Panel, toggle, radio, numberField } = 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 uploadSoundSupport: 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 updatedModel.choices = updatedModel.choices.map((c) => ({\n ...c,\n categoryCount: this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c),\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 //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.\n updatedModel.correctResponse = ensureNoExtraChoicesInAlternate(\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 // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)\n updatedModel.maxChoicesPerCategory = updatedModel.allowMaxChoicesPerCategory ? updatedModel.maxChoicesPerCategory : 0;\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((alt, altIndex) => altIndex !== index),\n })),\n });\n };\n\n countChoiceInCorrectResponse = (choice) => {\n const { model } = this.props;\n\n return countInAnswer(choice.id, model.correctResponse);\n };\n\n checkAllowMultiplePlacements = (allowMultiplePlacements, c) => {\n if (allowMultiplePlacements === multiplePlacements.enabled) {\n return 0;\n }\n\n if (allowMultiplePlacements === multiplePlacements.disabled) {\n return 1;\n }\n\n return c.categoryCount || 0;\n };\n\n isAlertModalOpened = () => {\n const { model } = this.props;\n const { maxChoicesPerCategory = 0 } = model || {};\n const maxChoices = getMaxCategoryChoices(model);\n // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened\n return maxChoicesPerCategory !== 0 ? maxChoices > maxChoicesPerCategory : false;\n };\n\n onAlertModalCancel = () => {\n const { model } = this.props;\n const maxChoices = getMaxCategoryChoices(model);\n this.updateModel({ maxChoicesPerCategory: maxChoices });\n };\n\n\n render() {\n const { classes, configuration, imageSupport, model, uploadSoundSupport, onConfigurationChanged } = this.props;\n const {\n allowMultiplePlacements = {},\n allowAlternate = {},\n categoriesPerRow = {},\n choicesPosition = {},\n contentDimensions = {},\n feedback = {},\n lockChoiceOrder = {},\n maxImageHeight = {},\n maxImageWidth = {},\n maxPlacements = {},\n minCategoriesPerRow = 1,\n partialScoring = {},\n prompt = {},\n rationale = {},\n scoringType = {},\n settingsPanelDisabled,\n spellCheck = {},\n studentInstructions = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n allowAlternateEnabled,\n allowMaxChoicesPerCategory,\n feedbackEnabled,\n maxChoicesPerCategory,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const config = model.config || {};\n config.choices = config.choices || { label: '', columns: 2 };\n\n const categories = buildCategories(model.categories || [], model.choices || [], model.correctResponse || []);\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\n return c;\n });\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n categoriesPerRow:\n categoriesPerRow.settings &&\n numberField(categoriesPerRow.label, {\n label: categoriesPerRow.label,\n min: minCategoriesPerRow,\n max: 6,\n }),\n choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),\n allowMultiplePlacementsEnabled:\n allowMultiplePlacements.settings &&\n dropdown(allowMultiplePlacements.label, [\n multiplePlacements.enabled,\n multiplePlacements.disabled,\n multiplePlacements.perChoice,\n ]),\n allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),\n maxChoicesPerCategory:\n allowMaxChoicesPerCategory === true &&\n numberField(maxPlacements.label, {\n label: '',\n min: 0,\n max: 30,\n }),\n promptEnabled: prompt.settings && toggle(prompt.label),\n feedbackEnabled: feedback.settings && toggle(feedback.label),\n // PD-2960: deleted temporary from settings panel\n // allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n const isOpened = this.isAlertModalOpened();\n const alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {lng: model.language, maxChoicesPerCategory });\n\n return (\n <IdProvider value={this.uid}>\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={this.updateModel}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n modal={<AlertDialog\n title={'Warning'}\n text={alertMaxChoicesMsg}\n open={isOpened}\n onClose={this.onAlertModalCancel}\n />}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.inputContainer}>\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 maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.inputContainer}>\n <EditableHtml\n className={classes.input}\n markup={model.prompt || ''}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.prompt}\n maxImageHeight={maxImageHeight && maxImageHeight.prompt}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n <Categories\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n model={model}\n categories={categories || []}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n />\n\n <Choices\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n choices={choices}\n model={model}\n onModelChanged={this.updateModel}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n configuration={configuration}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n />\n\n {allowAlternateEnabled && (\n <Header\n className={classes.alternatesHeader}\n label=\"Alternate Responses\"\n buttonLabel=\"ADD AN ALTERNATE RESPONSE\"\n onAdd={this.onAddAlternateResponse}\n />\n )}\n {allowAlternateEnabled &&\n alternateResponses.map((categoriesList, index) => {\n return (\n <React.Fragment key={index}>\n <Header\n className={classes.alternatesHeader}\n variant={'subtitle1'}\n label=\"Alternate Response\"\n buttonLabel=\"REMOVE ALTERNATE RESPONSE\"\n onAdd={() => this.onRemoveAlternateResponse(index)}\n />\n <AlternateResponses\n altIndex={index}\n imageSupport={imageSupport}\n model={model}\n configuration={configuration}\n categories={categoriesList}\n onModelChanged={this.updateModel}\n uploadSoundSupport={uploadSoundSupport}\n toolbarOpts={toolbarOpts}\n defaultImageMaxWidth={defaultImageMaxWidth}\n defaultImageMaxHeight={defaultImageMaxHeight}\n mathMlOptions={mathMlOptions}\n />\n </React.Fragment>\n );\n })}\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.inputContainer}>\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 maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </InputContainer>\n )}\n\n {feedbackEnabled && (\n <FeedbackConfig feedback={model.feedback} onChange={this.changeFeedback} toolbarOpts={toolbarOpts} />\n )}\n </layout.ConfigLayout>\n </IdProvider>\n );\n }\n}\n\nconst styles = (theme) => ({\n alternatesHeader: {\n marginBottom: theme.spacing.unit * 2,\n },\n text: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n inputContainer: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n title: {\n marginBottom: theme.spacing.unit * 4,\n },\n});\n\nexport default withDragContext(withStyles(styles)(Design));\n"],"file":"index.js"}
|
package/configure/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.multiplePlacements = exports.generateValidationMessage = void 0;
|
|
6
|
+
exports.multiplePlacements = exports.getMaxCategoryChoices = exports.generateValidationMessage = void 0;
|
|
7
7
|
|
|
8
8
|
var generateValidationMessage = function generateValidationMessage(config) {
|
|
9
9
|
var _ref = config || {},
|
|
@@ -24,4 +24,17 @@ var multiplePlacements = {
|
|
|
24
24
|
perChoice: 'Set Per Choice'
|
|
25
25
|
};
|
|
26
26
|
exports.multiplePlacements = multiplePlacements;
|
|
27
|
+
|
|
28
|
+
var getMaxCategoryChoices = function getMaxCategoryChoices(model) {
|
|
29
|
+
var _ref2 = model || {},
|
|
30
|
+
_ref2$correctResponse = _ref2.correctResponse,
|
|
31
|
+
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse;
|
|
32
|
+
|
|
33
|
+
return correctResponse.reduce(function (max, correctRes) {
|
|
34
|
+
var choicesLength = correctRes.choices.length;
|
|
35
|
+
return choicesLength > max ? choicesLength : max;
|
|
36
|
+
}, 0);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.getMaxCategoryChoices = getMaxCategoryChoices;
|
|
27
40
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","minChoices","maxChoices","maxCategories","validationMessage","multiplePlacements","enabled","disabled","perChoice"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,MAAD,EAAY;AACnD,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,GACrB,kCACA,iEADA,IAECD,aAAa,yBAAkBA,aAAlB,SAAqC,EAFnD,IAGA,UAHA,IAICA,aAAa,GAAG,GAAH,GAAS,EAJvB,IAKA,WALA,IAMCF,UAAU,wCAAiCA,UAAjC,yBAAiE,EAN5E,KAOCC,UAAU,4BAAqBA,UAArB,mCAA+D,EAP1E,IAQA,mEATF;AAWA,SAAO,6BAA6BE,iBAApC;AACD,CAhBM,C,CAkBP;;;;AACO,IAAMC,kBAAkB,GAAG;AAAEC,EAAAA,OAAO,EAAE,KAAX;AAAkBC,EAAAA,QAAQ,EAAE,IAA5B;AAAkCC,EAAAA,SAAS,EAAE;AAA7C,CAA3B","sourcesContent":["export const generateValidationMessage = (config) => {\n let { minChoices, maxChoices, maxCategories } = config || {};\n minChoices = minChoices || 1;\n\n const validationMessage =\n '\\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' +\n (maxCategories ? 's' : '') +\n ' 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\n// used in controller too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' };\n"],"file":"utils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","minChoices","maxChoices","maxCategories","validationMessage","multiplePlacements","enabled","disabled","perChoice","getMaxCategoryChoices","model","correctResponse","reduce","max","correctRes","choicesLength","choices","length"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,MAAD,EAAY;AACnD,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,GACrB,kCACA,iEADA,IAECD,aAAa,yBAAkBA,aAAlB,SAAqC,EAFnD,IAGA,UAHA,IAICA,aAAa,GAAG,GAAH,GAAS,EAJvB,IAKA,WALA,IAMCF,UAAU,wCAAiCA,UAAjC,yBAAiE,EAN5E,KAOCC,UAAU,4BAAqBA,UAArB,mCAA+D,EAP1E,IAQA,mEATF;AAWA,SAAO,6BAA6BE,iBAApC;AACD,CAhBM,C,CAkBP;;;;AACO,IAAMC,kBAAkB,GAAG;AAAEC,EAAAA,OAAO,EAAE,KAAX;AAAkBC,EAAAA,QAAQ,EAAE,IAA5B;AAAkCC,EAAAA,SAAS,EAAE;AAA7C,CAA3B;;;AAEA,IAAOC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,KAAD,EAAW;AAC/C,cAAiCA,KAAK,IAAI,EAA1C;AAAA,oCAAQC,eAAR;AAAA,MAAQA,eAAR,sCAA0B,EAA1B;;AACA,SAAOA,eAAe,CAACC,MAAhB,CAAuB,UAACC,GAAD,EAAMC,UAAN,EAAqB;AACjD,QAAMC,aAAa,GAAGD,UAAU,CAACE,OAAX,CAAmBC,MAAzC;AACA,WAAOF,aAAa,GAAGF,GAAhB,GAAsBE,aAAtB,GAAsCF,GAA7C;AACD,GAHM,EAGJ,CAHI,CAAP;AAID,CANM","sourcesContent":["export const generateValidationMessage = (config) => {\n let { minChoices, maxChoices, maxCategories } = config || {};\n minChoices = minChoices || 1;\n\n const validationMessage =\n '\\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' +\n (maxCategories ? 's' : '') +\n ' 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\n// used in controller too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' };\n\nexport const getMaxCategoryChoices = (model) => {\n const { correctResponse = [] } = model || {};\n return correctResponse.reduce((max, correctRes) => {\n const choicesLength = correctRes.choices.length;\n return choicesLength > max ? choicesLength : max;\n }, 0);\n};\n"],"file":"utils.js"}
|
package/configure/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@material-ui/core": "^3.9.2",
|
|
13
13
|
"@material-ui/icons": "^3.0.1",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
-
"@pie-lib/pie-toolbox": "1.0
|
|
15
|
+
"@pie-lib/pie-toolbox": "1.1.0",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"debug": "^3.1.0",
|
|
18
18
|
"lodash": "^4.17.15",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["choices","choicesPosition","choicesLabel","lockChoiceOrder","allowMultiplePlacementsEnabled","multiplePlacements","enabled","categoriesPerRow","categories","alternates","correctResponse","rowLabels","partialScoring","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,OAAO,EAAE,EADI;AAEbC,EAAAA,eAAe,EAAE,OAFJ;AAGbC,EAAAA,YAAY,EAAE,EAHD;AAIbC,EAAAA,eAAe,EAAE,IAJJ;AAKbC,EAAAA,8BAA8B,EAAEC,0BAAmBC,OALtC;AAMbC,EAAAA,gBAAgB,EAAE,CANL;AAObC,EAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["choices","choicesPosition","choicesLabel","lockChoiceOrder","allowMultiplePlacementsEnabled","multiplePlacements","enabled","categoriesPerRow","maxChoicesPerCategory","categories","alternates","correctResponse","rowLabels","partialScoring","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,OAAO,EAAE,EADI;AAEbC,EAAAA,eAAe,EAAE,OAFJ;AAGbC,EAAAA,YAAY,EAAE,EAHD;AAIbC,EAAAA,eAAe,EAAE,IAJJ;AAKbC,EAAAA,8BAA8B,EAAEC,0BAAmBC,OALtC;AAMbC,EAAAA,gBAAgB,EAAE,CANL;AAObC,EAAAA,qBAAqB,EAAE,CAPV;AAQbC,EAAAA,UAAU,EAAE,EARC;AASbC,EAAAA,UAAU,EAAE,EATC;AAUbC,EAAAA,eAAe,EAAE,EAVJ;AAWbC,EAAAA,SAAS,EAAE,CAAC,EAAD,CAXE;AAYbC,EAAAA,cAAc,EAAE,IAZH;AAabC,EAAAA,eAAe,EAAE,KAbJ;AAcbC,EAAAA,gBAAgB,EAAE,IAdL;AAebC,EAAAA,aAAa,EAAE,IAfF;AAgBbC,EAAAA,0BAA0B,EAAE,IAhBf;AAiBbC,EAAAA,0BAA0B,EAAE,IAjBf;AAkBbC,EAAAA,qBAAqB,EAAE;AAlBV,C","sourcesContent":["import { multiplePlacements } from './utils';\n\nexport default {\n choices: [],\n choicesPosition: 'below',\n choicesLabel: '',\n lockChoiceOrder: true,\n allowMultiplePlacementsEnabled: multiplePlacements.enabled,\n categoriesPerRow: 2,\n maxChoicesPerCategory: 0,\n categories: [],\n alternates: [],\n correctResponse: [],\n rowLabels: [''],\n partialScoring: true,\n feedbackEnabled: false,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
CHANGED
|
@@ -200,7 +200,7 @@ exports.normalize = normalize;
|
|
|
200
200
|
var model = function model(question, session, env, updateSession) {
|
|
201
201
|
return new Promise( /*#__PURE__*/function () {
|
|
202
202
|
var _ref7 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve) {
|
|
203
|
-
var normalizedQuestion, answerCorrectness, _ref8, mode, role, categories, categoriesPerRow, choicesLabel, choicesPosition, correctResponse, feedback, feedbackEnabled, promptEnabled, prompt, rowLabels, rationaleEnabled, rationale, teacherInstructionsEnabled, teacherInstructions, language, choices, note, fb, lockChoiceOrder, filteredCorrectResponse, alternates, out;
|
|
203
|
+
var normalizedQuestion, answerCorrectness, _ref8, mode, role, categories, categoriesPerRow, choicesLabel, choicesPosition, correctResponse, feedback, feedbackEnabled, promptEnabled, prompt, rowLabels, rationaleEnabled, rationale, teacherInstructionsEnabled, teacherInstructions, language, maxChoicesPerCategory, choices, note, fb, lockChoiceOrder, filteredCorrectResponse, alternates, out;
|
|
204
204
|
|
|
205
205
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
206
206
|
while (1) {
|
|
@@ -213,7 +213,7 @@ var model = function model(question, session, env, updateSession) {
|
|
|
213
213
|
case 3:
|
|
214
214
|
answerCorrectness = _context.sent;
|
|
215
215
|
_ref8 = env || {}, mode = _ref8.mode, role = _ref8.role;
|
|
216
|
-
categories = normalizedQuestion.categories, categoriesPerRow = normalizedQuestion.categoriesPerRow, choicesLabel = normalizedQuestion.choicesLabel, choicesPosition = normalizedQuestion.choicesPosition, correctResponse = normalizedQuestion.correctResponse, feedback = normalizedQuestion.feedback, feedbackEnabled = normalizedQuestion.feedbackEnabled, promptEnabled = normalizedQuestion.promptEnabled, prompt = normalizedQuestion.prompt, rowLabels = normalizedQuestion.rowLabels, rationaleEnabled = normalizedQuestion.rationaleEnabled, rationale = normalizedQuestion.rationale, teacherInstructionsEnabled = normalizedQuestion.teacherInstructionsEnabled, teacherInstructions = normalizedQuestion.teacherInstructions, language = normalizedQuestion.language;
|
|
216
|
+
categories = normalizedQuestion.categories, categoriesPerRow = normalizedQuestion.categoriesPerRow, choicesLabel = normalizedQuestion.choicesLabel, choicesPosition = normalizedQuestion.choicesPosition, correctResponse = normalizedQuestion.correctResponse, feedback = normalizedQuestion.feedback, feedbackEnabled = normalizedQuestion.feedbackEnabled, promptEnabled = normalizedQuestion.promptEnabled, prompt = normalizedQuestion.prompt, rowLabels = normalizedQuestion.rowLabels, rationaleEnabled = normalizedQuestion.rationaleEnabled, rationale = normalizedQuestion.rationale, teacherInstructionsEnabled = normalizedQuestion.teacherInstructionsEnabled, teacherInstructions = normalizedQuestion.teacherInstructions, language = normalizedQuestion.language, maxChoicesPerCategory = normalizedQuestion.maxChoicesPerCategory;
|
|
217
217
|
choices = normalizedQuestion.choices, note = normalizedQuestion.note;
|
|
218
218
|
lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
|
|
219
219
|
filteredCorrectResponse = correctResponse.map(function (response) {
|
|
@@ -259,6 +259,7 @@ var model = function model(question, session, env, updateSession) {
|
|
|
259
259
|
out = {
|
|
260
260
|
categories: categories || [],
|
|
261
261
|
categoriesPerRow: categoriesPerRow || 2,
|
|
262
|
+
maxChoicesPerCategory: maxChoicesPerCategory,
|
|
262
263
|
correctness: answerCorrectness,
|
|
263
264
|
choices: choices || [],
|
|
264
265
|
choicesLabel: choicesLabel || '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["translator","Translator","disableAlternateResponses","question","correctResponse","mappedCorrectResponse","map","cr","alternateResponses","response","allowAlternateEnabled","getPartialScore","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","c","alternate","getTotalScore","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","newQuestion","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","feedbackEnabled","promptEnabled","prompt","rowLabels","rationaleEnabled","rationale","teacherInstructionsEnabled","teacherInstructions","language","note","lockChoiceOrder","filteredCorrectResponse","filteredChoices","choice","fb","t","lng","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id","validate","config","minChoices","maxChoices","minCategories","maxCategories","maxLengthPerChoice","maxLengthPerCategory","reversedChoices","reverse","errors","choicesErrors","categoriesErrors","forEach","category","label","parsedLabel","replace","index","content","parsedContent","identicalAnswer","slice","some","nbOfCategories","nbOfChoices","categoriesError","choicesError","hasAssociations","duplicateAlternateIndex","duplicateCategory","duplicateAlternate","associationError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAFA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAQA;AACA;AACA,IAAME,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,QAAD,EAAc;AAC9C,aAA0BA,QAAQ,IAAI,EAAtC;AAAA,MAAMC,eAAN,QAAMA,eAAN;;AACAA,EAAAA,eAAe,GAAGA,eAAe,IAAI,EAArC;AACA,MAAMC,qBAAqB,GAAGD,eAAe,CAACE,GAAhB,CAAoB,UAACC,EAAD,EAAQ;AACxD,QAAQC,kBAAR,GAA4CD,EAA5C,CAAQC,kBAAR;AAAA,QAA+BC,QAA/B,6CAA4CF,EAA5C;AACA,WAAOE,QAAP;AACD,GAH6B,CAA9B;AAIA,yCACKN,QADL;AAEEC,IAAAA,eAAe,EAAEC,qBAFnB;AAGEK,IAAAA,qBAAqB,EAAE;AAHzB;AAKD,CAZD;;AAcO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACP,eAAD,EAAkBQ,eAAlB,EAAsC;AACnE;AACA;AACA,8BAA8BA,eAAe,CAACC,MAAhB,CAC5B,UAACC,GAAD;AAAA,8BAAQC,OAAR;AAAA,QAAQA,OAAR,8BAAkB,EAAlB;AAAA,WAA4B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ourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/pie-toolbox/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/pie-toolbox/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\nimport defaults from './defaults';\nimport { isAlternateDuplicated, isCorrectResponseDuplicated } from './utils';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\n// PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)\n// this function is used in configure part, too\nconst disableAlternateResponses = (question) => {\n let { correctResponse } = question || {};\n correctResponse = correctResponse || [];\n const mappedCorrectResponse = correctResponse.map((cr) => {\n const { alternateResponses, ...response } = cr;\n return response;\n });\n return {\n ...question,\n correctResponse: mappedCorrectResponse,\n allowAlternateEnabled: false,\n };\n};\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) =>\n correctResponse.map((c) => c.alternateResponses).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(categories, choices, answers, correctResponse);\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 const newQuestion = disableAlternateResponses(question);\n return {\n ...defaults,\n ...newQuestion,\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport 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 rowLabels,\n rationaleEnabled,\n rationale,\n teacherInstructionsEnabled,\n teacherInstructions,\n language\n } = normalizedQuestion;\n let { choices, note } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n const filteredCorrectResponse = correctResponse.map((response) => {\n const filteredChoices = (response.choices || []).filter((choice) => choice !== 'null');\n return { ...response, choices: filteredChoices };\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(answerCorrectness, feedback);\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: language });\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\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 rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n language\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : 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(new Error('Can not call outcome when mode is not evaluate'));\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 {\n minChoices = 1,\n maxChoices = 15,\n minCategories = 1,\n maxCategories = 12,\n maxLengthPerChoice = 300,\n maxLengthPerCategory = 150,\n } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const categoriesErrors = {};\n\n (categories || []).forEach((category) => {\n const { id, label } = category;\n const parsedLabel = label.replace(/<(?:.|\\n)*?>/gm, '');\n if (parsedLabel.length > maxLengthPerCategory) {\n categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;\n }\n });\n\n (reversedChoices || []).forEach((choice, index) => {\n const { id, content } = choice;\n const parsedContent = content.replace(/<(?:.|\\n)*?>/gm, '');\n if (parsedContent.length > maxLengthPerChoice) {\n choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;\n }\n if (content === '' || content === '<div></div>') {\n choicesErrors[id] = 'Tokens 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] = 'Tokens 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 < minCategories) {\n errors.categoriesError = `There should be at least ${minCategories} 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 let duplicateAlternateIndex = -1;\n let duplicateCategory = '';\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [], category } = response;\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);\n }\n duplicateCategory = category;\n }\n });\n\n if (duplicateAlternateIndex > -1) {\n errors.duplicateAlternate = { index: duplicateAlternateIndex, category: duplicateCategory };\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 if (!isEmpty(categoriesErrors)) {\n errors.categoriesErrors = categoriesErrors;\n }\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["translator","Translator","disableAlternateResponses","question","correctResponse","mappedCorrectResponse","map","cr","alternateResponses","response","allowAlternateEnabled","getPartialScore","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","c","alternate","getTotalScore","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","newQuestion","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","feedbackEnabled","promptEnabled","prompt","rowLabels","rationaleEnabled","rationale","teacherInstructionsEnabled","teacherInstructions","language","maxChoicesPerCategory","note","lockChoiceOrder","filteredCorrectResponse","filteredChoices","choice","fb","t","lng","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id","validate","config","minChoices","maxChoices","minCategories","maxCategories","maxLengthPerChoice","maxLengthPerCategory","reversedChoices","reverse","errors","choicesErrors","categoriesErrors","forEach","category","label","parsedLabel","replace","index","content","parsedContent","identicalAnswer","slice","some","nbOfCategories","nbOfChoices","categoriesError","choicesError","hasAssociations","duplicateAlternateIndex","duplicateCategory","duplicateAlternate","associationError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAFA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAQA;AACA;AACA,IAAME,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,QAAD,EAAc;AAC9C,aAA0BA,QAAQ,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AA5B,EAAqCP,kBAArC,CAA1B;;AACA,YAAI2G,uBAAuB,KAAK,CAAC,CAAjC,EAAoC;AAClCA,UAAAA,uBAAuB,GAAG,kCAAsB3G,kBAAtB,CAA1B;AACD;;AACD4G,QAAAA,iBAAiB,GAAGhB,QAApB;AACD;AACF,KATD;;AAWA,QAAIe,uBAAuB,GAAG,CAAC,CAA/B,EAAkC;AAChCnB,MAAAA,MAAM,CAACqB,kBAAP,GAA4B;AAAEb,QAAAA,KAAK,EAAEW,uBAAT;AAAkCf,QAAAA,QAAQ,EAAEgB;AAA5C,OAA5B;AACD;;AAED,QAAI,CAACF,eAAL,EAAsB;AACpBlB,MAAAA,MAAM,CAACsB,gBAAP,GAA0B,iEAA1B;AACD;AACF;;AAED,MAAI,CAAC,yBAAQrB,aAAR,CAAL,EAA6B;AAC3BD,IAAAA,MAAM,CAACC,aAAP,GAAuBA,aAAvB;AACD;;AAED,MAAI,CAAC,yBAAQC,gBAAR,CAAL,EAAgC;AAC9BF,IAAAA,MAAM,CAACE,gBAAP,GAA0BA,gBAA1B;AACD;;AACD,SAAOF,MAAP;AACD,CAtGM","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/pie-toolbox/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/pie-toolbox/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\nimport defaults from './defaults';\nimport { isAlternateDuplicated, isCorrectResponseDuplicated } from './utils';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\n// PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)\n// this function is used in configure part, too\nconst disableAlternateResponses = (question) => {\n let { correctResponse } = question || {};\n correctResponse = correctResponse || [];\n const mappedCorrectResponse = correctResponse.map((cr) => {\n const { alternateResponses, ...response } = cr;\n return response;\n });\n return {\n ...question,\n correctResponse: mappedCorrectResponse,\n allowAlternateEnabled: false,\n };\n};\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) =>\n correctResponse.map((c) => c.alternateResponses).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(categories, choices, answers, correctResponse);\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 const newQuestion = disableAlternateResponses(question);\n return {\n ...defaults,\n ...newQuestion,\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport 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 rowLabels,\n rationaleEnabled,\n rationale,\n teacherInstructionsEnabled,\n teacherInstructions,\n language,\n maxChoicesPerCategory,\n } = normalizedQuestion;\n let { choices, note } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n const filteredCorrectResponse = correctResponse.map((response) => {\n const filteredChoices = (response.choices || []).filter((choice) => choice !== 'null');\n return { ...response, choices: filteredChoices };\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(answerCorrectness, feedback);\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: language });\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n maxChoicesPerCategory,\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 rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n language\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : 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(new Error('Can not call outcome when mode is not evaluate'));\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 {\n minChoices = 1,\n maxChoices = 15,\n minCategories = 1,\n maxCategories = 12,\n maxLengthPerChoice = 300,\n maxLengthPerCategory = 150,\n } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const categoriesErrors = {};\n\n (categories || []).forEach((category) => {\n const { id, label } = category;\n const parsedLabel = label.replace(/<(?:.|\\n)*?>/gm, '');\n if (parsedLabel.length > maxLengthPerCategory) {\n categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;\n }\n });\n\n (reversedChoices || []).forEach((choice, index) => {\n const { id, content } = choice;\n const parsedContent = content.replace(/<(?:.|\\n)*?>/gm, '');\n if (parsedContent.length > maxLengthPerChoice) {\n choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;\n }\n if (content === '' || content === '<div></div>') {\n choicesErrors[id] = 'Tokens 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] = 'Tokens 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 < minCategories) {\n errors.categoriesError = `There should be at least ${minCategories} 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 let duplicateAlternateIndex = -1;\n let duplicateCategory = '';\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [], category } = response;\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);\n }\n duplicateCategory = category;\n }\n });\n\n if (duplicateAlternateIndex > -1) {\n errors.duplicateAlternate = { index: duplicateAlternateIndex, category: duplicateCategory };\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 if (!isEmpty(categoriesErrors)) {\n errors.categoriesErrors = categoriesErrors;\n }\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/pie-schema.json
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
"additionalProperties": false,
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
+
"allowMaxChoicesPerCategory": {
|
|
7
|
+
"description": "Indicates if author has the possibility to set maxChoicesPerCategory",
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"title": "allowMaxChoicesPerCategory"
|
|
10
|
+
},
|
|
6
11
|
"choices": {
|
|
7
12
|
"description": "The available choices",
|
|
8
13
|
"type": "array",
|
|
@@ -348,6 +353,11 @@
|
|
|
348
353
|
"incorrect"
|
|
349
354
|
]
|
|
350
355
|
},
|
|
356
|
+
"maxChoicesPerCategory": {
|
|
357
|
+
"description": "Indicates the maximum number of choices from a category",
|
|
358
|
+
"type": "number",
|
|
359
|
+
"title": "maxChoicesPerCategory"
|
|
360
|
+
},
|
|
351
361
|
"rationale": {
|
|
352
362
|
"description": "Indicates the value for rationale",
|
|
353
363
|
"type": "string",
|
|
@@ -420,11 +430,13 @@
|
|
|
420
430
|
}
|
|
421
431
|
},
|
|
422
432
|
"required": [
|
|
433
|
+
"allowMaxChoicesPerCategory",
|
|
423
434
|
"categories",
|
|
424
435
|
"choices",
|
|
425
436
|
"element",
|
|
426
437
|
"feedbackEnabled",
|
|
427
438
|
"id",
|
|
439
|
+
"maxChoicesPerCategory",
|
|
428
440
|
"prompt",
|
|
429
441
|
"rationaleEnabled",
|
|
430
442
|
"rubricEnabled",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -2,6 +2,10 @@ Pie Model Object for @pie-elements/categorize
|
|
|
2
2
|
|
|
3
3
|
The schema defines the following properties:
|
|
4
4
|
|
|
5
|
+
# `allowMaxChoicesPerCategory` (boolean, required)
|
|
6
|
+
|
|
7
|
+
Indicates if author has the possibility to set maxChoicesPerCategory
|
|
8
|
+
|
|
5
9
|
# `choices` (array, required)
|
|
6
10
|
|
|
7
11
|
The available choices
|
|
@@ -129,6 +133,10 @@ Indicates the configuration for feedback when answer is incorrect
|
|
|
129
133
|
|
|
130
134
|
Indicates the configuration for feedback when answer is partially correct
|
|
131
135
|
|
|
136
|
+
# `maxChoicesPerCategory` (number, required)
|
|
137
|
+
|
|
138
|
+
Indicates the maximum number of choices from a category
|
|
139
|
+
|
|
132
140
|
# `rationale` (string)
|
|
133
141
|
|
|
134
142
|
Indicates the value for rationale
|
package/lib/categorize/index.js
CHANGED
|
@@ -43,6 +43,8 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
43
43
|
|
|
44
44
|
var _translator = _interopRequireDefault(require("@pie-lib/pie-toolbox/translator"));
|
|
45
45
|
|
|
46
|
+
var _configUi = require("@pie-lib/pie-toolbox/config-ui");
|
|
47
|
+
|
|
46
48
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
47
49
|
|
|
48
50
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -78,7 +80,18 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
78
80
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dropChoice", function (categoryId, draggedChoice) {
|
|
79
81
|
var _this$props2 = _this.props,
|
|
80
82
|
session = _this$props2.session,
|
|
81
|
-
onAnswersChange = _this$props2.onAnswersChange
|
|
83
|
+
onAnswersChange = _this$props2.onAnswersChange,
|
|
84
|
+
model = _this$props2.model;
|
|
85
|
+
|
|
86
|
+
var _ref = model || {},
|
|
87
|
+
_ref$maxChoicesPerCat = _ref.maxChoicesPerCategory,
|
|
88
|
+
maxChoicesPerCategory = _ref$maxChoicesPerCat === void 0 ? 0 : _ref$maxChoicesPerCat;
|
|
89
|
+
|
|
90
|
+
var _ref2 = session || {},
|
|
91
|
+
_ref2$answers = _ref2.answers,
|
|
92
|
+
answers = _ref2$answers === void 0 ? [] : _ref2$answers;
|
|
93
|
+
|
|
94
|
+
var newAnswers;
|
|
82
95
|
|
|
83
96
|
if (draggedChoice) {
|
|
84
97
|
log('[dropChoice] category: ', draggedChoice.categoryId, 'choice: ', draggedChoice);
|
|
@@ -86,10 +99,33 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
86
99
|
log('[dropChoice] category: ', undefined, 'choice: ', undefined);
|
|
87
100
|
}
|
|
88
101
|
|
|
89
|
-
var
|
|
102
|
+
var answer = answers.find(function (answer) {
|
|
103
|
+
return answer.category === categoryId;
|
|
104
|
+
}); // treat special case to replace the existing choice with the new one when maxChoicesPerCategory = 1
|
|
105
|
+
|
|
106
|
+
if (draggedChoice && maxChoicesPerCategory === 1 && answer && answer.choices && answer.choices.length === 1) {
|
|
107
|
+
newAnswers = (0, _categorize.moveChoiceToCategory)(draggedChoice.id, draggedChoice.categoryId, categoryId, draggedChoice.choiceIndex, answers);
|
|
108
|
+
newAnswers = (0, _categorize.removeChoiceFromCategory)(answer.choices[0], categoryId, 0, answers);
|
|
109
|
+
} // treat special case when there are as many choices as maxChoicesPerCategory is
|
|
110
|
+
else if (draggedChoice && maxChoicesPerCategory > 1 && answer && answer.choices && answer.choices.length === maxChoicesPerCategory) {
|
|
111
|
+
newAnswers = draggedChoice.categoryId ? (0, _categorize.moveChoiceToCategory)(draggedChoice.id, draggedChoice.categoryId, draggedChoice.categoryId, draggedChoice.choiceIndex, answers) : (0, _categorize.removeChoiceFromCategory)(draggedChoice.id, draggedChoice.categoryId, draggedChoice.choiceIndex, answers);
|
|
112
|
+
|
|
113
|
+
_this.setState({
|
|
114
|
+
showMaxChoiceAlert: true
|
|
115
|
+
});
|
|
116
|
+
} // treat special case when there are more choices that maxChoicesPerCategory is (testing purpose in pits)
|
|
117
|
+
else if (maxChoicesPerCategory !== 0 && answer && answer.choices && answer.choices.length > maxChoicesPerCategory) {
|
|
118
|
+
newAnswers = answers;
|
|
119
|
+
|
|
120
|
+
_this.setState({
|
|
121
|
+
showMaxChoiceAlert: true
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
newAnswers = draggedChoice ? (0, _categorize.moveChoiceToCategory)(draggedChoice.id, draggedChoice.categoryId, categoryId, draggedChoice.choiceIndex, answers) : _this.removeChoice(categoryId);
|
|
125
|
+
}
|
|
90
126
|
|
|
91
127
|
if (draggedChoice) {
|
|
92
|
-
onAnswersChange(
|
|
128
|
+
onAnswersChange(newAnswers);
|
|
93
129
|
}
|
|
94
130
|
});
|
|
95
131
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleShowCorrect", function () {
|
|
@@ -131,7 +167,8 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
131
167
|
});
|
|
132
168
|
});
|
|
133
169
|
_this.state = {
|
|
134
|
-
showCorrect: false
|
|
170
|
+
showCorrect: false,
|
|
171
|
+
showMaxChoiceAlert: false
|
|
135
172
|
};
|
|
136
173
|
return _this;
|
|
137
174
|
}
|
|
@@ -159,20 +196,25 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
159
196
|
}, {
|
|
160
197
|
key: "render",
|
|
161
198
|
value: function render() {
|
|
199
|
+
var _this2 = this;
|
|
200
|
+
|
|
162
201
|
var _this$props3 = this.props,
|
|
163
202
|
classes = _this$props3.classes,
|
|
164
203
|
model = _this$props3.model,
|
|
165
204
|
session = _this$props3.session;
|
|
166
|
-
var
|
|
205
|
+
var _this$state = this.state,
|
|
206
|
+
showCorrect = _this$state.showCorrect,
|
|
207
|
+
showMaxChoiceAlert = _this$state.showMaxChoiceAlert;
|
|
167
208
|
var choicesPosition = model.choicesPosition,
|
|
168
209
|
note = model.note,
|
|
169
210
|
showNote = model.showNote,
|
|
170
211
|
env = model.env,
|
|
171
|
-
language = model.language
|
|
212
|
+
language = model.language,
|
|
213
|
+
maxChoicesPerCategory = model.maxChoicesPerCategory;
|
|
172
214
|
|
|
173
|
-
var
|
|
174
|
-
mode =
|
|
175
|
-
role =
|
|
215
|
+
var _ref3 = env || {},
|
|
216
|
+
mode = _ref3.mode,
|
|
217
|
+
role = _ref3.role;
|
|
176
218
|
|
|
177
219
|
var choicePosition = choicesPosition || 'above';
|
|
178
220
|
var style = {
|
|
@@ -191,6 +233,10 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
191
233
|
var nbOfRows = categories && Math.ceil(categories.length / categoriesPerRow) || 0;
|
|
192
234
|
var existAlternate = this.existAlternateResponse(correctResponse) || false;
|
|
193
235
|
var displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note && existAlternate;
|
|
236
|
+
var alertMessage = translator.t('translation:categorize:limitMaxChoicesPerCategory', {
|
|
237
|
+
lng: model.language,
|
|
238
|
+
maxChoicesPerCategory: maxChoicesPerCategory
|
|
239
|
+
});
|
|
194
240
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
195
241
|
className: classes.mainContainer
|
|
196
242
|
}, model.teacherInstructions && (0, _renderUi.hasText)(model.teacherInstructions) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
@@ -246,6 +292,15 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
246
292
|
})), model.correctness && model.feedback && !showCorrect && /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
|
|
247
293
|
correctness: model.correctness,
|
|
248
294
|
feedback: model.feedback
|
|
295
|
+
}), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
296
|
+
title: 'Warning',
|
|
297
|
+
text: alertMessage,
|
|
298
|
+
open: showMaxChoiceAlert,
|
|
299
|
+
onClose: function onClose() {
|
|
300
|
+
return _this2.setState({
|
|
301
|
+
showMaxChoiceAlert: false
|
|
302
|
+
});
|
|
303
|
+
}
|
|
249
304
|
}));
|
|
250
305
|
}
|
|
251
306
|
}]);
|
|
@@ -275,12 +330,12 @@ var CategorizeProvider = /*#__PURE__*/function (_React$Component2) {
|
|
|
275
330
|
var _super2 = _createSuper(CategorizeProvider);
|
|
276
331
|
|
|
277
332
|
function CategorizeProvider(props) {
|
|
278
|
-
var
|
|
333
|
+
var _this3;
|
|
279
334
|
|
|
280
335
|
(0, _classCallCheck2["default"])(this, CategorizeProvider);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return
|
|
336
|
+
_this3 = _super2.call(this, props);
|
|
337
|
+
_this3.uid = _drag.uid.generateId();
|
|
338
|
+
return _this3;
|
|
284
339
|
}
|
|
285
340
|
|
|
286
341
|
(0, _createClass2["default"])(CategorizeProvider, [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/index.jsx"],"names":["translator","Translator","log","removeHTMLTags","html","tmp","document","createElement","innerHTML","value","textContent","innerText","trim","Categorize","props","c","onAnswersChange","session","answers","id","categoryId","choiceIndex","draggedChoice","undefined","removeChoice","setState","showCorrect","state","onShowCorrectToggle","choicePosition","flexDirection","correctResponse","some","correctRes","alternateResponses","length","nextProps","model","nextModel","note","language","t","lng","classes","choicesPosition","showNote","env","mode","role","style","getPositionDirection","categories","choices","correct","disabled","rowLabels","categoriesPerRow","nbOfRows","Math","ceil","existAlternate","existAlternateResponse","displayNote","mainContainer","teacherInstructions","hidden","visible","collapsible","prompt","toggleShowCorrect","categorize","display","flex","dropChoice","slice","__html","rationale","correctness","feedback","React","Component","PropTypes","object","isRequired","shape","arrayOf","choice","string","category","func","CategorizeProvider","uid","generateId","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","paddingBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AACA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD,EAAU;AAC/B,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,C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;EAZ8BiE,kBAAMC,S;;AAevC,IAAMa,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzB/B,IAAAA,aAAa,EAAE;AACbgC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADM;AAEbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFJ,KADU;AAKzB3D,IAAAA,IAAI,EAAE;AACJ4D,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AAD/B,KALmB;AAQzB/B,IAAAA,UAAU,EAAE;AACV6B,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IADlB;AAEV9B,MAAAA,OAAO,EAAE,MAFC;AAGVzC,MAAAA,aAAa,EAAE;AAHL,KARa;AAazBqC,IAAAA,WAAW,EAAE;AACXmC,MAAAA,aAAa,EAAER,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADzB;AAbY,GAAZ;AAAA,CAAf;;eAkBe,2BAAgB,wBAAWR,MAAX,EAAmBH,kBAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Choices from './choices';\nimport Categories from './categories';\nimport CorrectAnswerToggle from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { withStyles } from '@material-ui/core/styles';\nimport { buildState, removeChoiceFromCategory, moveChoiceToCategory } from '@pie-lib/pie-toolbox/categorize';\nimport { withDragContext, uid } from '@pie-lib/pie-toolbox/drag';\nimport { color, Feedback, Collapsible, hasText, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport debug from 'debug';\nimport Translator from '@pie-lib/pie-toolbox/translator';\nconst { translator } = Translator;\n\nconst log = debug('@pie-ui:categorize');\n\nconst removeHTMLTags = (html) => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\n};\n\nexport class Categorize extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n answers: PropTypes.arrayOf(\n PropTypes.shape({\n choice: PropTypes.string,\n category: PropTypes.string,\n }),\n ),\n }),\n onAnswersChange: PropTypes.func.isRequired,\n onShowCorrectToggle: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n disabled: false,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: false,\n };\n }\n\n removeChoice = (c) => {\n log('[removeChoice]: ', c);\n const { onAnswersChange, session } = this.props;\n const answers = removeChoiceFromCategory(c.id, c.categoryId, c.choiceIndex, session.answers);\n onAnswersChange(answers);\n };\n\n dropChoice = (categoryId, draggedChoice) => {\n const { session, onAnswersChange } = this.props;\n if (draggedChoice) {\n log('[dropChoice] category: ', draggedChoice.categoryId, 'choice: ', draggedChoice);\n } else {\n log('[dropChoice] category: ', undefined, 'choice: ', undefined);\n }\n\n const answers = draggedChoice\n ? moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n categoryId,\n draggedChoice.choiceIndex,\n session.answers,\n )\n : this.removeChoice(categoryId);\n\n if (draggedChoice) {\n onAnswersChange(answers);\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { model } = this.props;\n const { model: nextModel } = nextProps;\n\n // check if the note is the default one for prev language and change to the default one for new language\n // this check is necessary in order to diferanciate between default and authour defined note\n // and only change between languages for default ones\n if (model.note && model.language && model.language !== nextModel.language\n && model.note === translator.t('common:commonCorrectAnswerWithAlternates', { lng: model.language })) {\n model.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: nextModel.language });\n }\n\n this.setState({ showCorrect: false });\n }\n\n toggleShowCorrect = () =>\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n this.props.onShowCorrectToggle();\n });\n\n getPositionDirection = (choicePosition) => {\n let flexDirection;\n\n switch (choicePosition) {\n case 'left':\n flexDirection = 'row-reverse';\n break;\n case 'right':\n flexDirection = 'row';\n break;\n case 'below':\n flexDirection = 'column';\n break;\n default:\n // above\n flexDirection = 'column-reverse';\n break;\n }\n\n return flexDirection;\n };\n\n existAlternateResponse = (correctResponse) =>\n correctResponse?.some((correctRes) => correctRes.alternateResponses?.length > 0);\n\n render() {\n const { classes, model, session } = this.props;\n const { showCorrect } = this.state;\n const { choicesPosition, note, showNote, env, language } = model;\n const { mode, role } = env || {};\n const choicePosition = choicesPosition || 'above';\n\n const style = {\n flexDirection: this.getPositionDirection(choicePosition),\n };\n\n const { categories, choices, correct } = buildState(\n model.categories,\n model.choices,\n showCorrect ? model.correctResponse : session.answers,\n model.correctResponse,\n );\n\n log('[render] disabled: ', model.disabled);\n\n const { rowLabels, categoriesPerRow, correctResponse } = model;\n const nbOfRows = (categories && Math.ceil(categories.length / categoriesPerRow)) || 0;\n const existAlternate = this.existAlternateResponse(correctResponse) || false;\n const displayNote =\n (showCorrect || (mode === 'view' && role === 'instructor')) && showNote && note && existAlternate;\n\n return (\n <div className={classes.mainContainer}>\n {model.teacherInstructions && hasText(model.teacherInstructions) && (\n <React.Fragment>\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n </React.Fragment>\n )}\n\n {model.prompt && removeHTMLTags(model.prompt) && <PreviewPrompt prompt={model.prompt} />}\n\n <CorrectAnswerToggle\n show={showCorrect || correct === false}\n toggled={showCorrect}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n\n <div className={classes.categorize} style={style}>\n <div style={{ display: 'flex', flex: 1 }}>\n <Categories\n model={model}\n disabled={model.disabled}\n categories={categories}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n rowLabels={(rowLabels || []).slice(0, nbOfRows)}\n />\n </div>\n <Choices\n disabled={model.disabled}\n model={model}\n choices={choices}\n choicePosition={choicePosition}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n />\n </div>\n\n {displayNote && (\n <div\n className={classes.note}\n dangerouslySetInnerHTML={{\n __html: note,\n }}\n />\n )}\n\n {model.rationale && hasText(model.rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }} className={classes.collapsible}>\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n )}\n\n {model.correctness && model.feedback && !showCorrect && (\n <Feedback correctness={model.correctness} feedback={model.feedback} />\n )}\n </div>\n );\n }\n}\n\nclass CategorizeProvider extends React.Component {\n constructor(props) {\n super(props);\n this.uid = uid.generateId();\n }\n\n render() {\n return (\n <uid.Provider value={this.uid}>\n <Categorize {...this.props} />\n </uid.Provider>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n note: {\n marginBottom: theme.spacing.unit * 2,\n },\n categorize: {\n marginBottom: theme.spacing.unit,\n display: 'flex',\n flexDirection: 'column',\n },\n collapsible: {\n paddingBottom: theme.spacing.unit * 2,\n },\n});\n\nexport default withDragContext(withStyles(styles)(CategorizeProvider));\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/index.jsx"],"names":["translator","Translator","log","removeHTMLTags","html","tmp","document","createElement","innerHTML","value","textContent","innerText","trim","Categorize","props","c","onAnswersChange","session","answers","id","categoryId","choiceIndex","draggedChoice","model","maxChoicesPerCategory","newAnswers","undefined","answer","find","category","choices","length","setState","showMaxChoiceAlert","removeChoice","showCorrect","state","onShowCorrectToggle","choicePosition","flexDirection","correctResponse","some","correctRes","alternateResponses","nextProps","nextModel","note","language","t","lng","classes","choicesPosition","showNote","env","mode","role","style","getPositionDirection","categories","correct","disabled","rowLabels","categoriesPerRow","nbOfRows","Math","ceil","existAlternate","existAlternateResponse","displayNote","alertMessage","mainContainer","teacherInstructions","hidden","visible","collapsible","prompt","toggleShowCorrect","categorize","display","flex","dropChoice","slice","__html","rationale","correctness","feedback","React","Component","PropTypes","object","isRequired","shape","arrayOf","choice","string","func","CategorizeProvider","uid","generateId","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","paddingBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AACA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD,EAAU;AAC/B,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AAEAF,EAAAA,GAAG,CAACG,SAAJ,GAAgBJ,IAAhB;AAEA,MAAMK,KAAK,GAAGJ,GAAG,CAACK,WAAJ,IAAmBL,GAAG,CAACM,SAAvB,IAAoC,EAAlD;AAEA,SAAOF,KAAK,CAACG,IAAN,EAAP;AACD,CARD;;IAUaC,U;;;;;AAoBX,sBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,qGASJ,UAACC,CAAD,EAAO;AACpBb,MAAAA,GAAG,CAAC,kBAAD,EAAqBa,CAArB,CAAH;AACA,wBAAqC,MAAKD,KAA1C;AAAA,UAAQE,eAAR,eAAQA,eAAR;AAAA,UAAyBC,OAAzB,eAAyBA,OAAzB;AACA,UAAMC,OAAO,GAAG,0CAAyBH,CAAC,CAACI,EAA3B,EAA+BJ,CAAC,CAACK,UAAjC,EAA6CL,CAAC,CAACM,WAA/C,EAA4DJ,OAAO,CAACC,OAApE,CAAhB;AACAF,MAAAA,eAAe,CAACE,OAAD,CAAf;AACD,KAdkB;AAAA,mGAgBN,UAACE,UAAD,EAAaE,aAAb,EAA+B;AAC1C,yBAA4C,MAAKR,KAAjD;AAAA,UAAQG,OAAR,gBAAQA,OAAR;AAAA,UAAiBD,eAAjB,gBAAiBA,eAAjB;AAAA,UAAkCO,KAAlC,gBAAkCA,KAAlC;;AACA,iBAAsCA,KAAK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AD,CAAK,QAAL;AAAc,QAAA,KAAK,EAAE,KAAKD;AAA1B,sBACE,gCAAC,UAAD,EAAgB,KAAKnF,KAArB,CADF,CADF;AAKD;;;EAZ8BwE,kBAAMC,S;;AAevC,IAAMY,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzB9B,IAAAA,aAAa,EAAE;AACb+B,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADM;AAEbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFJ,KADU;AAKzB1D,IAAAA,IAAI,EAAE;AACJ2D,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AAD/B,KALmB;AAQzB9B,IAAAA,UAAU,EAAE;AACV4B,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IADlB;AAEV7B,MAAAA,OAAO,EAAE,MAFC;AAGVvC,MAAAA,aAAa,EAAE;AAHL,KARa;AAazBmC,IAAAA,WAAW,EAAE;AACXkC,MAAAA,aAAa,EAAER,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADzB;AAbY,GAAZ;AAAA,CAAf;;eAkBe,2BAAgB,wBAAWR,MAAX,EAAmBH,kBAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Choices from './choices';\nimport Categories from './categories';\nimport CorrectAnswerToggle from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { withStyles } from '@material-ui/core/styles';\nimport { buildState, removeChoiceFromCategory, moveChoiceToCategory } from '@pie-lib/pie-toolbox/categorize';\nimport { withDragContext, uid } from '@pie-lib/pie-toolbox/drag';\nimport { color, Feedback, Collapsible, hasText, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport debug from 'debug';\nimport Translator from '@pie-lib/pie-toolbox/translator';\nimport { AlertDialog } from '@pie-lib/pie-toolbox/config-ui';\nconst { translator } = Translator;\n\nconst log = debug('@pie-ui:categorize');\n\nconst removeHTMLTags = (html) => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\n};\n\nexport class Categorize extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n answers: PropTypes.arrayOf(\n PropTypes.shape({\n choice: PropTypes.string,\n category: PropTypes.string,\n }),\n ),\n }),\n onAnswersChange: PropTypes.func.isRequired,\n onShowCorrectToggle: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n disabled: false,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: false,\n showMaxChoiceAlert: false,\n };\n }\n\n removeChoice = (c) => {\n log('[removeChoice]: ', c);\n const { onAnswersChange, session } = this.props;\n const answers = removeChoiceFromCategory(c.id, c.categoryId, c.choiceIndex, session.answers);\n onAnswersChange(answers);\n };\n\n dropChoice = (categoryId, draggedChoice) => {\n const { session, onAnswersChange, model } = this.props;\n const { maxChoicesPerCategory = 0 } = model || {};\n const { answers = [] } = session || {};\n let newAnswers;\n if (draggedChoice) {\n log('[dropChoice] category: ', draggedChoice.categoryId, 'choice: ', draggedChoice);\n } else {\n log('[dropChoice] category: ', undefined, 'choice: ', undefined);\n }\n\n const answer = answers.find(answer => answer.category === categoryId);\n\n // treat special case to replace the existing choice with the new one when maxChoicesPerCategory = 1\n if (draggedChoice && maxChoicesPerCategory === 1 && answer && answer.choices && answer.choices.length === 1) {\n newAnswers = moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n categoryId,\n draggedChoice.choiceIndex,\n answers,\n );\n newAnswers = removeChoiceFromCategory(answer.choices[0], categoryId, 0, answers)\n }\n\n // treat special case when there are as many choices as maxChoicesPerCategory is\n else if (draggedChoice && maxChoicesPerCategory > 1 && answer && answer.choices && answer.choices.length === maxChoicesPerCategory ) {\n newAnswers = draggedChoice.categoryId ? moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n draggedChoice.categoryId,\n draggedChoice.choiceIndex,\n answers,\n ) : removeChoiceFromCategory(draggedChoice.id, draggedChoice.categoryId, draggedChoice.choiceIndex, answers);\n this.setState({ showMaxChoiceAlert: true })\n }\n\n // treat special case when there are more choices that maxChoicesPerCategory is (testing purpose in pits)\n else if (maxChoicesPerCategory !== 0 && answer && answer.choices && answer.choices.length > maxChoicesPerCategory) {\n newAnswers = answers;\n this.setState({ showMaxChoiceAlert: true });\n }\n else {\n newAnswers = draggedChoice\n ? moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n categoryId,\n draggedChoice.choiceIndex,\n answers,\n )\n : this.removeChoice(categoryId);\n }\n\n if (draggedChoice) {\n onAnswersChange(newAnswers);\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { model } = this.props;\n const { model: nextModel } = nextProps;\n\n // check if the note is the default one for prev language and change to the default one for new language\n // this check is necessary in order to diferanciate between default and authour defined note\n // and only change between languages for default ones\n if (model.note && model.language && model.language !== nextModel.language\n && model.note === translator.t('common:commonCorrectAnswerWithAlternates', { lng: model.language })) {\n model.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: nextModel.language });\n }\n\n this.setState({ showCorrect: false });\n }\n\n toggleShowCorrect = () =>\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n this.props.onShowCorrectToggle();\n });\n\n getPositionDirection = (choicePosition) => {\n let flexDirection;\n\n switch (choicePosition) {\n case 'left':\n flexDirection = 'row-reverse';\n break;\n case 'right':\n flexDirection = 'row';\n break;\n case 'below':\n flexDirection = 'column';\n break;\n default:\n // above\n flexDirection = 'column-reverse';\n break;\n }\n\n return flexDirection;\n };\n\n existAlternateResponse = (correctResponse) =>\n correctResponse?.some((correctRes) => correctRes.alternateResponses?.length > 0);\n\n render() {\n const { classes, model, session } = this.props;\n const { showCorrect, showMaxChoiceAlert } = this.state;\n const { choicesPosition, note, showNote, env, language, maxChoicesPerCategory } = model;\n const { mode, role } = env || {};\n const choicePosition = choicesPosition || 'above';\n\n const style = {\n flexDirection: this.getPositionDirection(choicePosition),\n };\n\n const { categories, choices, correct } = buildState(\n model.categories,\n model.choices,\n showCorrect ? model.correctResponse : session.answers,\n model.correctResponse,\n );\n\n log('[render] disabled: ', model.disabled);\n\n const { rowLabels, categoriesPerRow, correctResponse } = model;\n const nbOfRows = (categories && Math.ceil(categories.length / categoriesPerRow)) || 0;\n const existAlternate = this.existAlternateResponse(correctResponse) || false;\n const displayNote =\n (showCorrect || (mode === 'view' && role === 'instructor')) && showNote && note && existAlternate;\n const alertMessage = translator.t('translation:categorize:limitMaxChoicesPerCategory', { lng: model.language, maxChoicesPerCategory });\n\n return (\n <div className={classes.mainContainer}>\n {model.teacherInstructions && hasText(model.teacherInstructions) && (\n <React.Fragment>\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n </React.Fragment>\n )}\n\n {model.prompt && removeHTMLTags(model.prompt) && <PreviewPrompt prompt={model.prompt} />}\n\n <CorrectAnswerToggle\n show={showCorrect || correct === false}\n toggled={showCorrect}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n\n <div className={classes.categorize} style={style}>\n <div style={{ display: 'flex', flex: 1 }}>\n <Categories\n model={model}\n disabled={model.disabled}\n categories={categories}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n rowLabels={(rowLabels || []).slice(0, nbOfRows)}\n />\n </div>\n <Choices\n disabled={model.disabled}\n model={model}\n choices={choices}\n choicePosition={choicePosition}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n />\n </div>\n\n {displayNote && (\n <div\n className={classes.note}\n dangerouslySetInnerHTML={{\n __html: note,\n }}\n />\n )}\n\n {model.rationale && hasText(model.rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }} className={classes.collapsible}>\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n )}\n\n {model.correctness && model.feedback && !showCorrect && (\n <Feedback correctness={model.correctness} feedback={model.feedback} />\n )}\n <AlertDialog\n title={'Warning'}\n text={alertMessage}\n open={showMaxChoiceAlert}\n onClose={() => this.setState({ showMaxChoiceAlert: false })}\n >\n </AlertDialog>\n </div>\n );\n }\n}\n\nclass CategorizeProvider extends React.Component {\n constructor(props) {\n super(props);\n this.uid = uid.generateId();\n }\n\n render() {\n return (\n <uid.Provider value={this.uid}>\n <Categorize {...this.props} />\n </uid.Provider>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n note: {\n marginBottom: theme.spacing.unit * 2,\n },\n categorize: {\n marginBottom: theme.spacing.unit,\n display: 'flex',\n flexDirection: 'column',\n },\n collapsible: {\n paddingBottom: theme.spacing.unit * 2,\n },\n});\n\nexport default withDragContext(withStyles(styles)(CategorizeProvider));\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "8.0.2-next.
|
|
7
|
+
"version": "8.0.2-next.45+89d4b74dd",
|
|
8
8
|
"description": "",
|
|
9
9
|
"author": "pie framework developers",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@material-ui/core": "^3.9.2",
|
|
13
13
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
14
|
-
"@pie-lib/pie-toolbox": "1.0
|
|
14
|
+
"@pie-lib/pie-toolbox": "1.1.0",
|
|
15
15
|
"classnames": "^2.2.5",
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
17
|
"lodash": "^4.17.15",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"react-dnd": "^14.0.5",
|
|
21
21
|
"react-dom": "^16.8.1"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "89d4b74dd113d9d9213a7023a3857fb78c45bc10",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postpublish": "../../scripts/postpublish"
|
|
26
26
|
},
|