@pie-element/explicit-constructed-response 7.6.6-next.8 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/configure/CHANGELOG.md +17 -0
- package/configure/lib/alternateSection.js +3 -3
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/main.js +3 -3
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +2 -2
- package/controller/CHANGELOG.md +12 -0
- package/controller/lib/index.js +7 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/module/configure.js +7 -7
- package/module/controller.js +12 -1
- package/module/element.js +48 -10
- package/module/manifest.json +1 -1
- package/module/print.js +48 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@7.6.5...@pie-element/explicit-constructed-response@7.7.0) (2025-09-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4579, PD-4430 ([277d2a6](https://github.com/pie-framework/pie-elements/commit/277d2a6bad2fc884ab9d980f71774ba9eca8dbb5))
|
|
12
|
+
* **explicit-constructed-response:** fix max length logic to work with special characters PD-5168 ([9a37527](https://github.com/pie-framework/pie-elements/commit/9a37527ef21a30bf06d1ca4d2513ba8954a676b7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add tests to PD-5168 ([10d9ff1](https://github.com/pie-framework/pie-elements/commit/10d9ff1fc6d42558d5504f107a29b7774becd5c8))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [7.6.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@7.6.4...@pie-element/explicit-constructed-response@7.6.5) (2025-08-15)
|
|
7
24
|
|
|
8
25
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.6.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@7.5.5...@pie-element/explicit-constructed-response-configure@7.6.0) (2025-09-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4579, PD-4430 ([277d2a6](https://github.com/pie-framework/pie-elements/commit/277d2a6bad2fc884ab9d980f71774ba9eca8dbb5))
|
|
12
|
+
* **explicit-constructed-response:** fix max length logic to work with special characters PD-5168 ([9a37527](https://github.com/pie-framework/pie-elements/commit/9a37527ef21a30bf06d1ca4d2513ba8954a676b7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add tests to PD-5168 ([10d9ff1](https://github.com/pie-framework/pie-elements/commit/10d9ff1fc6d42558d5504f107a29b7774becd5c8))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [7.5.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@7.5.4...@pie-element/explicit-constructed-response-configure@7.5.5) (2025-08-15)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -273,9 +273,9 @@ var AlternateSection = /*#__PURE__*/function (_React$Component2) {
|
|
|
273
273
|
maxLength = _this2$props2.maxLength,
|
|
274
274
|
choices = _this2$props2.choices;
|
|
275
275
|
var labelLengthsArr = choices.map(function (choice) {
|
|
276
|
-
return (choice.label || '').length;
|
|
276
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
277
277
|
});
|
|
278
|
-
labelLengthsArr[index] = value.length;
|
|
278
|
+
labelLengthsArr[index] = (0, _markupUtils.decodeHTML)(value).length;
|
|
279
279
|
var newLength = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
280
280
|
choiceChanged(_objectSpread(_objectSpread({}, choice), {}, {
|
|
281
281
|
label: value
|
|
@@ -297,7 +297,7 @@ var AlternateSection = /*#__PURE__*/function (_React$Component2) {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
var labelLengthsArr = choices.map(function (choice) {
|
|
300
|
-
return (choice.label || '').length;
|
|
300
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
301
301
|
});
|
|
302
302
|
return Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
303
303
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/alternateSection.jsx"],"names":["styles","theme","design","marginBottom","spacing","unit","altChoices","alignItems","flexDirection","display","paddingTop","width","choice","flex","marginRight","deleteBtn","fill","palette","grey","selectContainer","justifyContent","rightContainer","lengthField","errorText","fontSize","typography","color","error","main","inputError","border","borderRadius","Choice","value","props","markup","onChange","e","strippedValue","setState","updateText","nextProps","state","classes","onDelete","spellCheck","showMaxLength","pluginProps","inputProps","maxLength","language","minWidth","isHidden","characters","disabled","React","Component","PropTypes","object","string","func","isRequired","bool","AlternateSection","choices","onSelect","selectChoices","target","find","c","length","label","map","parseInt","filter","id","isNaN","index","choiceChanged","lengthChanged","labelLengthsArr","newLength","Math","max","choiceRemoved","event","numberValue","minLength","getChoicesMaxLength","updateChoicesIfNeeded","errors","select","handleSelect","min","changeLength","addButton","onAddChoice","val","onChoiceChanged","onRemoveChoice","array","number","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;A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a,EAAE/B,aARjB;AASE,UAAA,WAAW,EAAEC;AATf,UAFJ;AAAA,OADF,CAFJ,CA1CF,CADF;AAgED;;;EAnLmCQ,kBAAMC,S;;;iCAA/BO,gB,eACQ;AACjBC,EAAAA,OAAO,EAAEP,sBAAU2C,KADF;AAEjBlC,EAAAA,aAAa,EAAET,sBAAU2C,KAAV,CAAgBvC,UAFd;AAGjBlB,EAAAA,OAAO,EAAEc,sBAAUC,MAAV,CAAiBG,UAHT;AAIjB6B,EAAAA,MAAM,EAAEjC,sBAAUC,MAJD;AAKjBO,EAAAA,QAAQ,EAAER,sBAAUG,IAAV,CAAeC,UALR;AAMjBiB,EAAAA,aAAa,EAAErB,sBAAUG,IAAV,CAAeC,UANb;AAOjBkB,EAAAA,aAAa,EAAEtB,sBAAUG,IAPR;AAQjBwB,EAAAA,aAAa,EAAE3B,sBAAUG,IAAV,CAAeC,UARb;AASjB5B,EAAAA,KAAK,EAAEwB,sBAAUE,MATA;AAUjBV,EAAAA,SAAS,EAAEQ,sBAAU4C,MAVJ;AAWjBvD,EAAAA,aAAa,EAAEW,sBAAUK,IAXR;AAYjBjB,EAAAA,UAAU,EAAEY,sBAAUK,IAZL;AAajBf,EAAAA,WAAW,EAAEU,sBAAUC;AAbN,C;AAqLrB,IAAM4C,MAAM,GAAG,wBAAWtG,MAAX,EAAmB+D,gBAAnB,CAAf;eAEeuC,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport isEqual from 'lodash/isEqual';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport Button from '@material-ui/core/Button';\nimport Delete from '@material-ui/icons/Delete';\nimport IconButton from '@material-ui/core/IconButton';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport TextField from '@material-ui/core/TextField';\nimport { withStyles } from '@material-ui/core/styles';\nimport max from 'lodash/max';\nimport classnames from 'classnames';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\nimport { stripHtmlTags, getAdjustedLength, decodeHTML } from './markupUtils';\n\nconst styles = (theme) => ({\n design: {\n marginBottom: theme.spacing.unit / 2,\n },\n altChoices: {\n alignItems: 'flex-start',\n flexDirection: 'column',\n display: 'flex',\n paddingTop: theme.spacing.unit * 2.5,\n '& > *': {\n marginBottom: theme.spacing.unit * 2.5,\n width: '100%',\n },\n },\n choice: {\n flex: '1',\n marginRight: theme.spacing.unit * 2.5,\n },\n deleteBtn: {\n fill: theme.palette.grey[600],\n },\n selectContainer: {\n alignItems: 'flex-end',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n },\n rightContainer: {\n alignItems: 'center',\n display: 'flex',\n },\n lengthField: {\n width: '230px',\n marginRight: theme.spacing.unit * 2.5,\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit / 2,\n },\n inputError: {\n border: `2px solid ${theme.palette.error.main}`,\n borderRadius: '6px',\n },\n});\n\nexport class Choice extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n error: PropTypes.string,\n markup: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n value: PropTypes.string,\n spellCheck: PropTypes.bool,\n showMaxLength: PropTypes.bool,\n pluginProps: PropTypes.object\n };\n\n state = {\n value: this.props.markup,\n };\n\n updateText = debounce(this.props.onChange, 300);\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (nextProps.markup) {\n this.setState({ value: nextProps.markup });\n }\n }\n\n onChange = (e) => {\n const strippedValue = stripHtmlTags(e);\n this.setState({ value: strippedValue });\n this.updateText(strippedValue);\n };\n\n render() {\n const { value } = this.state;\n const { classes, onDelete, spellCheck, error, showMaxLength, pluginProps } = this.props;\n const inputProps = showMaxLength ? {} : { maxLength: 25 };\n\n return (\n <React.Fragment>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n }}\n >\n <EditableHtml\n className={classnames(classes.choice, error && classes.inputError)}\n disableUnderline\n onChange={this.onChange}\n markup={value || ''}\n activePlugins={['languageCharacters']}\n pluginProps={pluginProps}\n languageCharactersProps={[{ language: 'spanish' }]}\n spellCheck={spellCheck}\n autoWidthToolbar\n toolbarOpts={{\n minWidth: 'auto',\n isHidden: !!pluginProps?.characters?.disabled\n }}\n {...inputProps}\n />\n <IconButton aria-label=\"delete\" className={classes.deleteBtn} onClick={onDelete}>\n <Delete />\n </IconButton>\n </div>\n {error && <div className={classes.errorText}>{error}</div>}\n </React.Fragment>\n );\n }\n}\n\nexport class AlternateSection extends React.Component {\n static propTypes = {\n choices: PropTypes.array,\n selectChoices: PropTypes.array.isRequired,\n classes: PropTypes.object.isRequired,\n errors: PropTypes.object,\n onSelect: PropTypes.func.isRequired,\n choiceChanged: PropTypes.func.isRequired,\n lengthChanged: PropTypes.func,\n choiceRemoved: PropTypes.func.isRequired,\n value: PropTypes.string,\n maxLength: PropTypes.number,\n showMaxLength: PropTypes.bool,\n spellCheck: PropTypes.bool,\n pluginProps: PropTypes.object\n };\n\n state = {};\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.updateChoicesIfNeeded(nextProps);\n }\n\n componentDidMount() {\n this.updateChoicesIfNeeded(this.props);\n }\n\n updateChoicesIfNeeded = (props) => {\n if (\n !this.state.choices ||\n !isEqual(props.choices, this.state.choices) ||\n !isEqual(props.choices, this.props.choices)\n ) {\n this.setState({\n choices: props.choices,\n });\n }\n };\n\n handleSelect = (e) => {\n const { onSelect, selectChoices } = this.props;\n const { value } = e.target;\n\n onSelect(selectChoices.find((c) => c.value === value));\n };\n\n onAddChoice = () => {\n const { choices } = this.state;\n\n if (choices.length && choices[choices.length - 1].label !== '') {\n const value = max(choices.map((c) => parseInt(c.value)).filter((id) => !isNaN(id))) || 0;\n\n this.setState({\n choices: [\n ...choices,\n {\n value: `${value + 1}`,\n label: '',\n },\n ],\n });\n }\n };\n\n onChoiceChanged = (choice, value, index) => {\n const { choiceChanged, lengthChanged, maxLength, choices } = this.props;\n\n const labelLengthsArr = choices.map((choice) => (choice.label || '').length);\n labelLengthsArr[index] = value.length;\n\n const newLength = Math.max(...labelLengthsArr);\n\n choiceChanged({\n ...choice,\n label: value,\n });\n\n if (newLength > maxLength || newLength + 10 <= maxLength) {\n lengthChanged(getAdjustedLength(newLength));\n }\n };\n\n onRemoveChoice = (choice) => {\n const { choiceRemoved } = this.props;\n\n choiceRemoved(choice.value);\n };\n\n getChoicesMaxLength = () => {\n const { choices } = this.state;\n\n if (!choices) {\n return 1;\n }\n\n const labelLengthsArr = choices.map((choice) => (choice.label || '').length);\n\n return Math.max(...labelLengthsArr);\n };\n\n changeLength = (event) => {\n const { lengthChanged } = this.props;\n const numberValue = parseInt(event.target.value, 10);\n const minLength = this.getChoicesMaxLength();\n\n if (numberValue && numberValue >= minLength && numberValue <= minLength + 10) {\n lengthChanged(numberValue);\n }\n };\n\n render() {\n const { classes, selectChoices, maxLength, showMaxLength, value, spellCheck, errors, pluginProps } = this.props;\n const { choices } = this.state;\n const minLength = this.getChoicesMaxLength();\n\n return (\n <div className={classes.design}>\n <div className={classes.selectContainer}>\n <Select\n className={classes.select}\n displayEmpty\n onChange={this.handleSelect}\n value={value || ''}\n readOnly={showMaxLength}\n >\n <MenuItem value=\"\">\n <em>{value ? 'Remove selection' : 'Select a response'}</em>\n </MenuItem>\n {selectChoices.map((c, index) => (\n <MenuItem key={index} value={c?.value}>\n {decodeHTML(c?.label)}\n </MenuItem>\n ))}\n </Select>\n\n {choices && choices.length > 0 && (\n <div className={classes.rightContainer}>\n {maxLength && showMaxLength && (\n <TextField\n className={classes.lengthField}\n label=\"Maximum length (characters)\"\n type=\"number\"\n inputProps={{\n min: minLength,\n max: minLength + 10,\n }}\n value={maxLength}\n onChange={this.changeLength}\n />\n )}\n <Button className={classes.addButton} variant=\"contained\" color=\"primary\" onClick={this.onAddChoice}>\n Add\n </Button>\n </div>\n )}\n </div>\n {errors && errors[0] && <div className={classes.errorText}>{errors[0]}</div>}\n\n <div className={classes.altChoices}>\n {choices &&\n choices.map(\n (c, index) =>\n index > 0 && (\n <Choice\n key={index}\n classes={classes}\n markup={c.label}\n onChange={(val) => this.onChoiceChanged(c, val, index)}\n onDelete={() => this.onRemoveChoice(c)}\n spellCheck={spellCheck}\n error={errors && errors[index]}\n showMaxLength={showMaxLength}\n pluginProps={pluginProps}\n />\n ),\n )}\n </div>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(AlternateSection);\n\nexport default Styled;\n"],"file":"alternateSection.js"}
|
|
1
|
+
{"version":3,"sources":["../src/alternateSection.jsx"],"names":["styles","theme","design","marginBottom","spacing","unit","altChoices","alignItems","flexDirection","display","paddingTop","width","choice","flex","marginRight","deleteBtn","fill","palette","grey","selectContainer","justifyContent","rightContainer","lengthField","errorText","fontSize","typography","color","error","main","inputError","border","borderRadius","Choice","value","props","markup","onChange","e","strippedValue","setState","updateText","nextProps","state","classes","onDelete","spellCheck","showMaxLength","pluginProps","inputProps","maxLength","language","minWidth","isHidden","characters","disabled","React","Component","PropTypes","object","string","func","isRequired","bool","AlternateSection","choices","onSelect","selectChoices","target","find","c","length","label","map","parseInt","filter","id","isNaN","index","choiceChanged","lengthChanged","labelLengthsArr","newLength","Math","max","choiceRemoved","event","numberValue","minLength","getChoicesMaxLength","updateChoicesIfNeeded","errors","select","handleSelect","min","changeLength","addButton","onAddChoice","val","onChoiceChanged","onRemoveChoice","array","number","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,MAAM,EAAE;AACNC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB;AAD7B,KADiB;AAIzBC,IAAAA,UAAU,EAAE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EAAAA,OAAO,EAAEc,sBAAUC,MAAV,CAAiBG,UAHT;AAIjB6B,EAAAA,MAAM,EAAEjC,sBAAUC,MAJD;AAKjBO,EAAAA,QAAQ,EAAER,sBAAUG,IAAV,CAAeC,UALR;AAMjBiB,EAAAA,aAAa,EAAErB,sBAAUG,IAAV,CAAeC,UANb;AAOjBkB,EAAAA,aAAa,EAAEtB,sBAAUG,IAPR;AAQjBwB,EAAAA,aAAa,EAAE3B,sBAAUG,IAAV,CAAeC,UARb;AASjB5B,EAAAA,KAAK,EAAEwB,sBAAUE,MATA;AAUjBV,EAAAA,SAAS,EAAEQ,sBAAU4C,MAVJ;AAWjBvD,EAAAA,aAAa,EAAEW,sBAAUK,IAXR;AAYjBjB,EAAAA,UAAU,EAAEY,sBAAUK,IAZL;AAajBf,EAAAA,WAAW,EAAEU,sBAAUC;AAbN,C;AAqLrB,IAAM4C,MAAM,GAAG,wBAAWtG,MAAX,EAAmB+D,gBAAnB,CAAf;eAEeuC,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport isEqual from 'lodash/isEqual';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport Button from '@material-ui/core/Button';\nimport Delete from '@material-ui/icons/Delete';\nimport IconButton from '@material-ui/core/IconButton';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport TextField from '@material-ui/core/TextField';\nimport { withStyles } from '@material-ui/core/styles';\nimport max from 'lodash/max';\nimport classnames from 'classnames';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\nimport { stripHtmlTags, getAdjustedLength, decodeHTML } from './markupUtils';\n\nconst styles = (theme) => ({\n design: {\n marginBottom: theme.spacing.unit / 2,\n },\n altChoices: {\n alignItems: 'flex-start',\n flexDirection: 'column',\n display: 'flex',\n paddingTop: theme.spacing.unit * 2.5,\n '& > *': {\n marginBottom: theme.spacing.unit * 2.5,\n width: '100%',\n },\n },\n choice: {\n flex: '1',\n marginRight: theme.spacing.unit * 2.5,\n },\n deleteBtn: {\n fill: theme.palette.grey[600],\n },\n selectContainer: {\n alignItems: 'flex-end',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n },\n rightContainer: {\n alignItems: 'center',\n display: 'flex',\n },\n lengthField: {\n width: '230px',\n marginRight: theme.spacing.unit * 2.5,\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit / 2,\n },\n inputError: {\n border: `2px solid ${theme.palette.error.main}`,\n borderRadius: '6px',\n },\n});\n\nexport class Choice extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n error: PropTypes.string,\n markup: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n value: PropTypes.string,\n spellCheck: PropTypes.bool,\n showMaxLength: PropTypes.bool,\n pluginProps: PropTypes.object\n };\n\n state = {\n value: this.props.markup,\n };\n\n updateText = debounce(this.props.onChange, 300);\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (nextProps.markup) {\n this.setState({ value: nextProps.markup });\n }\n }\n\n onChange = (e) => {\n const strippedValue = stripHtmlTags(e);\n this.setState({ value: strippedValue });\n this.updateText(strippedValue);\n };\n\n render() {\n const { value } = this.state;\n const { classes, onDelete, spellCheck, error, showMaxLength, pluginProps } = this.props;\n const inputProps = showMaxLength ? {} : { maxLength: 25 };\n\n return (\n <React.Fragment>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n }}\n >\n <EditableHtml\n className={classnames(classes.choice, error && classes.inputError)}\n disableUnderline\n onChange={this.onChange}\n markup={value || ''}\n activePlugins={['languageCharacters']}\n pluginProps={pluginProps}\n languageCharactersProps={[{ language: 'spanish' }]}\n spellCheck={spellCheck}\n autoWidthToolbar\n toolbarOpts={{\n minWidth: 'auto',\n isHidden: !!pluginProps?.characters?.disabled\n }}\n {...inputProps}\n />\n <IconButton aria-label=\"delete\" className={classes.deleteBtn} onClick={onDelete}>\n <Delete />\n </IconButton>\n </div>\n {error && <div className={classes.errorText}>{error}</div>}\n </React.Fragment>\n );\n }\n}\n\nexport class AlternateSection extends React.Component {\n static propTypes = {\n choices: PropTypes.array,\n selectChoices: PropTypes.array.isRequired,\n classes: PropTypes.object.isRequired,\n errors: PropTypes.object,\n onSelect: PropTypes.func.isRequired,\n choiceChanged: PropTypes.func.isRequired,\n lengthChanged: PropTypes.func,\n choiceRemoved: PropTypes.func.isRequired,\n value: PropTypes.string,\n maxLength: PropTypes.number,\n showMaxLength: PropTypes.bool,\n spellCheck: PropTypes.bool,\n pluginProps: PropTypes.object\n };\n\n state = {};\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.updateChoicesIfNeeded(nextProps);\n }\n\n componentDidMount() {\n this.updateChoicesIfNeeded(this.props);\n }\n\n updateChoicesIfNeeded = (props) => {\n if (\n !this.state.choices ||\n !isEqual(props.choices, this.state.choices) ||\n !isEqual(props.choices, this.props.choices)\n ) {\n this.setState({\n choices: props.choices,\n });\n }\n };\n\n handleSelect = (e) => {\n const { onSelect, selectChoices } = this.props;\n const { value } = e.target;\n\n onSelect(selectChoices.find((c) => c.value === value));\n };\n\n onAddChoice = () => {\n const { choices } = this.state;\n\n if (choices.length && choices[choices.length - 1].label !== '') {\n const value = max(choices.map((c) => parseInt(c.value)).filter((id) => !isNaN(id))) || 0;\n\n this.setState({\n choices: [\n ...choices,\n {\n value: `${value + 1}`,\n label: '',\n },\n ],\n });\n }\n };\n\n onChoiceChanged = (choice, value, index) => {\n const { choiceChanged, lengthChanged, maxLength, choices } = this.props;\n\n const labelLengthsArr = choices.map((choice) => decodeHTML(choice.label || '').length);\n labelLengthsArr[index] = decodeHTML(value).length;\n\n const newLength = Math.max(...labelLengthsArr);\n\n choiceChanged({\n ...choice,\n label: value,\n });\n\n if (newLength > maxLength || newLength + 10 <= maxLength) {\n lengthChanged(getAdjustedLength(newLength));\n }\n };\n\n onRemoveChoice = (choice) => {\n const { choiceRemoved } = this.props;\n\n choiceRemoved(choice.value);\n };\n\n getChoicesMaxLength = () => {\n const { choices } = this.state;\n\n if (!choices) {\n return 1;\n }\n\n const labelLengthsArr = choices.map((choice) => decodeHTML(choice.label || '').length);\n\n return Math.max(...labelLengthsArr);\n };\n\n changeLength = (event) => {\n const { lengthChanged } = this.props;\n const numberValue = parseInt(event.target.value, 10);\n const minLength = this.getChoicesMaxLength();\n\n if (numberValue && numberValue >= minLength && numberValue <= minLength + 10) {\n lengthChanged(numberValue);\n }\n };\n\n render() {\n const { classes, selectChoices, maxLength, showMaxLength, value, spellCheck, errors, pluginProps } = this.props;\n const { choices } = this.state;\n const minLength = this.getChoicesMaxLength();\n\n return (\n <div className={classes.design}>\n <div className={classes.selectContainer}>\n <Select\n className={classes.select}\n displayEmpty\n onChange={this.handleSelect}\n value={value || ''}\n readOnly={showMaxLength}\n >\n <MenuItem value=\"\">\n <em>{value ? 'Remove selection' : 'Select a response'}</em>\n </MenuItem>\n {selectChoices.map((c, index) => (\n <MenuItem key={index} value={c?.value}>\n {decodeHTML(c?.label)}\n </MenuItem>\n ))}\n </Select>\n\n {choices && choices.length > 0 && (\n <div className={classes.rightContainer}>\n {maxLength && showMaxLength && (\n <TextField\n className={classes.lengthField}\n label=\"Maximum length (characters)\"\n type=\"number\"\n inputProps={{\n min: minLength,\n max: minLength + 10,\n }}\n value={maxLength}\n onChange={this.changeLength}\n />\n )}\n <Button className={classes.addButton} variant=\"contained\" color=\"primary\" onClick={this.onAddChoice}>\n Add\n </Button>\n </div>\n )}\n </div>\n {errors && errors[0] && <div className={classes.errorText}>{errors[0]}</div>}\n\n <div className={classes.altChoices}>\n {choices &&\n choices.map(\n (c, index) =>\n index > 0 && (\n <Choice\n key={index}\n classes={classes}\n markup={c.label}\n onChange={(val) => this.onChoiceChanged(c, val, index)}\n onDelete={() => this.onRemoveChoice(c)}\n spellCheck={spellCheck}\n error={errors && errors[index]}\n showMaxLength={showMaxLength}\n pluginProps={pluginProps}\n />\n ),\n )}\n </div>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(AlternateSection);\n\nexport default Styled;\n"],"file":"alternateSection.js"}
|
package/configure/lib/main.js
CHANGED
|
@@ -186,7 +186,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
186
186
|
onModelChanged = _this$props3.onModelChanged;
|
|
187
187
|
var choices = model.choices;
|
|
188
188
|
var maxLengthPerChoice = model.maxLengthPerChoice;
|
|
189
|
-
var newValLength = (newVal || '').length;
|
|
189
|
+
var newValLength = (0, _markupUtils.decodeHTML)(newVal || '').length;
|
|
190
190
|
|
|
191
191
|
if (!choices[index]) {
|
|
192
192
|
choices[index] = [{
|
|
@@ -309,8 +309,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
309
309
|
}); // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
|
|
310
310
|
|
|
311
311
|
Object.values(choices).forEach(function (choice, index) {
|
|
312
|
-
var labelLengthsArr =
|
|
313
|
-
return (choice.label || '').length;
|
|
312
|
+
var labelLengthsArr = choice.map(function (choice) {
|
|
313
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
314
314
|
});
|
|
315
315
|
var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
316
316
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","choiceConfiguration","paddingBottom","switchElement","justifyContent","margin","addButton","text","fontSize","typography","tooltip","whiteSpace","maxWidth","errorText","color","palette","error","main","flexContainer","display","alignItems","responseHeader","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","spanishButton","responseAreaInputConfiguration","errors","extraCSSRules","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreasError","responseAreas","teacherInstructionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","onModelChange","Settings","Properties","onTeacherInstructionsChanged","inputConfiguration","onPromptChanged","marginLeft","ALL_PLUGINS","type","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,MAAR,GAAoCC,kBAApC,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAAoCD,kBAApC,CAAgBC,KAAhB;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAAuBE,QAAvB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;A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CAACrE;AAAxB,SAAoCqG,cAApC,CAjBrB,CA5IJ,CADF;AAmKD;;;EAtauBoC,kBAAMC,S;;;iCAAnBzH,I,eACQ;AACjBqD,EAAAA,aAAa,EAAEqE,sBAAUC,MAAV,CAAiBC,UADf;AAEjBxH,EAAAA,KAAK,EAAEsH,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB3H,EAAAA,cAAc,EAAEuH,sBAAUK,IAAV,CAAeH,UAJd;AAKjBtE,EAAAA,sBAAsB,EAAEoE,sBAAUK,IAAV,CAAeH,UALtB;AAMjBxE,EAAAA,OAAO,EAAEsE,sBAAUC,MAAV,CAAiBC,UANT;AAOjBrE,EAAAA,YAAY,EAAEmE,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjBpE,EAAAA,kBAAkB,EAAEkE,sBAAUC;AAXb,C;AAwarB,IAAMO,MAAM,GAAG,wBAAWzK,MAAX,EAAmBuC,IAAnB,CAAf;eAEekI,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport { EditableHtml, ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\nimport classnames from 'classnames';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n text: {\n fontSize: theme.typography.fontSize + 2,\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,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n },\n responseHeader: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit,\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n template = {},\n settingsPanelDisabled,\n spellCheck = {},\n editSource = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n spanishButton = {},\n responseAreaInputConfiguration = {},\n } = configuration || {};\n const {\n errors,\n extraCSSRules,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const {\n choices: choicesErrors = {},\n prompt: promptError,\n rationale: rationaleError,\n responseAreas: responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n 'responseAreaInputConfiguration.inputConfiguration.characters.disabled': spanishButton.settings && toggle(spanishButton.label,true),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n 'editSource.enabled': editSource?.settings && toggle(editSource.label, true),\n\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\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 autoWidthToolbar\n />\n {teacherInstructionsError && <div className={classes.errorText}>{teacherInstructionsError}</div>}\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n autoWidthToolbar\n />\n {promptError && <div className={classes.errorText}>{promptError}</div>}\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text} component=\"div\">\n Define Template, Choices, and Correct Responses\n </Typography>\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: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(template?.inputConfiguration)}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.get('index')] || [])[0];\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.get('index'), newVal)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n autoWidthToolbar\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classnames(classes.text, classes.responseHeader)}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\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 autoWidthToolbar\n />\n {rationaleError && <div className={classes.errorText}>{rationaleError}</div>}\n </InputContainer>\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","choiceConfiguration","paddingBottom","switchElement","justifyContent","margin","addButton","text","fontSize","typography","tooltip","whiteSpace","maxWidth","errorText","color","palette","error","main","flexContainer","display","alignItems","responseHeader","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","spanishButton","responseAreaInputConfiguration","errors","extraCSSRules","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreasError","responseAreas","teacherInstructionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","onModelChange","Settings","Properties","onTeacherInstructionsChanged","inputConfiguration","onPromptChanged","marginLeft","ALL_PLUGINS","type","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,MAAR,GAAoCC,kBAApC,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAAoCD,kBAApC,CAAgBC,KAAhB;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAAuBE,QAAvB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,UAAU,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFrB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADW;AAMzBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENL,MAA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AAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB3H,EAAAA,cAAc,EAAEuH,sBAAUK,IAAV,CAAeH,UAJd;AAKjBtE,EAAAA,sBAAsB,EAAEoE,sBAAUK,IAAV,CAAeH,UALtB;AAMjBxE,EAAAA,OAAO,EAAEsE,sBAAUC,MAAV,CAAiBC,UANT;AAOjBrE,EAAAA,YAAY,EAAEmE,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjBpE,EAAAA,kBAAkB,EAAEkE,sBAAUC;AAXb,C;AAwarB,IAAMO,MAAM,GAAG,wBAAWzK,MAAX,EAAmBuC,IAAnB,CAAf;eAEekI,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport { EditableHtml, ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { decodeHTML, getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\nimport classnames from 'classnames';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n text: {\n fontSize: theme.typography.fontSize + 2,\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,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n },\n responseHeader: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit,\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = choice.map((choice) => decodeHTML(choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = decodeHTML(newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n template = {},\n settingsPanelDisabled,\n spellCheck = {},\n editSource = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n spanishButton = {},\n responseAreaInputConfiguration = {},\n } = configuration || {};\n const {\n errors,\n extraCSSRules,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const {\n choices: choicesErrors = {},\n prompt: promptError,\n rationale: rationaleError,\n responseAreas: responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n 'responseAreaInputConfiguration.inputConfiguration.characters.disabled': spanishButton.settings && toggle(spanishButton.label,true),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n 'editSource.enabled': editSource?.settings && toggle(editSource.label, true),\n\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\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 autoWidthToolbar\n />\n {teacherInstructionsError && <div className={classes.errorText}>{teacherInstructionsError}</div>}\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n autoWidthToolbar\n />\n {promptError && <div className={classes.errorText}>{promptError}</div>}\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text} component=\"div\">\n Define Template, Choices, and Correct Responses\n </Typography>\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: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(template?.inputConfiguration)}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.get('index')] || [])[0];\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.get('index'), newVal)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n autoWidthToolbar\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classnames(classes.text, classes.responseHeader)}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\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 autoWidthToolbar\n />\n {rationaleError && <div className={classes.errorText}>{rationaleError}</div>}\n </InputContainer>\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-configure",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"modue": "src/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@material-ui/core": "^3.9.2",
|
|
9
9
|
"@material-ui/icons": "^3.0.1",
|
|
10
10
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
11
|
-
"@pie-lib/pie-toolbox": "2.23.
|
|
11
|
+
"@pie-lib/pie-toolbox": "2.23.3",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"debug": "^3.1.0",
|
|
14
14
|
"lodash": "^4.17.15",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.3.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@5.3.5...@pie-element/explicit-constructed-response-controller@5.3.6) (2025-09-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4579, PD-4430 ([277d2a6](https://github.com/pie-framework/pie-elements/commit/277d2a6bad2fc884ab9d980f71774ba9eca8dbb5))
|
|
12
|
+
* **explicit-constructed-response:** fix max length logic to work with special characters PD-5168 ([9a37527](https://github.com/pie-framework/pie-elements/commit/9a37527ef21a30bf06d1ca4d2513ba8954a676b7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [5.3.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@5.3.4...@pie-element/explicit-constructed-response-controller@5.3.5) (2025-08-15)
|
|
7
19
|
|
|
8
20
|
|
package/controller/lib/index.js
CHANGED
|
@@ -93,6 +93,12 @@ var getAdjustedLength = function getAdjustedLength(length) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
return length + 5;
|
|
96
|
+
}; // we can't use the dom parser here because it is not available in the node environment
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
var decodeHtmlEntities = function decodeHtmlEntities(str) {
|
|
100
|
+
if (!str) return '';
|
|
101
|
+
return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'|'/g, '\'').replace(/&/g, '&');
|
|
96
102
|
};
|
|
97
103
|
|
|
98
104
|
var normalize = function normalize(question) {
|
|
@@ -165,7 +171,7 @@ function model(question, session, env) {
|
|
|
165
171
|
|
|
166
172
|
Object.values(choices).forEach(function (choice, index) {
|
|
167
173
|
var labelLengthsArr = (choice || []).map(function (choice) {
|
|
168
|
-
return (choice.label || '').length;
|
|
174
|
+
return decodeHtmlEntities(choice.label || '').length;
|
|
169
175
|
});
|
|
170
176
|
var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
171
177
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","defaults","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","prepareChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","some","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","displayType","role","markup","playerSpellCheckEnabled","prompt","promptEnabled","rationale","responseCorrect","getScore","undefined","teacherInstructions","responseAreaInputConfiguration","extraCSSRules","rationaleEnabled","teacherInstructionsEnabled","html","decodeHTML","getInnerText","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","replaceAll","replace","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","nbOfResponseAreas"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAOC,eAAP;AAAA,SAA2B,UAACC,MAAD,EAAY;AAClE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,IAAI,KAAK,UAAb,EAAyB;AACvBG,MAAAA,GAAG,CAACG,OAAJ,GAAc,IAAd;AAEA,UAAMC,YAAY,GAAIL,MAAM,CAACM,QAAP,IAAmBN,MAAM,CAACM,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,UAAIF,YAAY,KAAK,SAArB,EAAgC;AAC9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yBF,MAAzB,CAAeE,KAAf;;AAEA,UAAIA,KAAK,KAAK,EAAV,IAAgBA,KAAK,KAAK,aAA9B,EAA6C;AAC3CmG,QAAAA,aAAa,CAAClG,KAAD,CAAb,GAAuB,8BAAvB;AACD,OAFD,MAEO;AACL,YAAMmG,eAAe,GAAGH,eAAe,CAACI,KAAhB,CAAsB7E,KAAK,GAAG,CAA9B,EAAiCc,IAAjC,CAAsC,UAACJ,CAAD;AAAA,iBAAOA,CAAC,CAAClC,KAAF,KAAYA,KAAnB;AAAA,SAAtC,CAAxB;;AAEA,YAAIoG,eAAJ,EAAqB;AACnBD,UAAAA,aAAa,CAAClG,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,KAZD;;AAcA,QAAI,CAAC,yBAAQkG,aAAR,CAAL,EAA6B;AAC3BP,MAAAA,gBAAgB,CAACvE,GAAD,CAAhB,GAAwB8E,aAAxB;AACD;AACF,GArBD;AAuBA,MAAMG,iBAAiB,GAAG,CAAClD,MAAM,CAACmB,KAAP,CAAa,gBAAb,KAAkC,EAAnC,EAAuC/D,MAAjE;;AAEA,MAAI8F,iBAAiB,GAAGX,gBAAxB,EAA0C;AACxCE,IAAAA,MAAM,CAACvB,aAAP,0BAAuCqB,gBAAvC;AACD,GAFD,MAEO,IAAIW,iBAAiB,GAAG,CAAxB,EAA2B;AAChCT,IAAAA,MAAM,CAACvB,aAAP,GAAuB,mDAAvB;AACD;;AAED,MAAI,CAAC,yBAAQsB,gBAAR,CAAL,EAAgC;AAC9BC,IAAAA,MAAM,CAAC5E,OAAP,GAAiB2E,gBAAjB;AACD;;AAED,SAAOC,MAAP;AACD,CAhDM","sourcesContent":["import debug from 'debug';\nimport map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport { decode } from 'he';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport Translator from '@pie-lib/pie-toolbox/translator';\nimport defaults from './defaults';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without\n // the \"value\" property like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback);\n const choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, prepareChoiceFn);\n\n return obj;\n },\n {},\n );\n\n const { value = {} } = session || {};\n const feedback =\n env.mode === 'evaluate'\n ? reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val =\n !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n )\n : {};\n\n // check if at least one choice has an alternate\n const showNote = Object.values(choices).some((choice) => choice?.length > 1);\n const note =\n normalizedQuestion.note ||\n translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n choices,\n disabled: env.mode !== 'gather',\n displayType: normalizedQuestion.displayType,\n mode: env.mode,\n role: env.role,\n feedback,\n language: normalizedQuestion.language,\n markup: normalizedQuestion.markup,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt,\n rationale: defaults.rationale,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n showNote,\n teacherInstructions: defaults.teacherInstructions,\n responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : defaults.teacherInstructions;\n }\n\n resolve(out);\n });\n}\n\nexport const prepareVal = (html) => {\n return decodeHTML(getInnerText(html).trim());\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.+?)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({ id: '1', value });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\n// const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\nconst getInnerText = (html) => {\n if (typeof html !== 'string') {\n return '';\n }\n if (typeof html.replaceAll === 'function') {\n return html.replaceAll(/<[^>]*>/g, '');\n } else {\n // Polyfill for replaceAll using replace and a global regex\n return html.replace(/<[^>]*>/g, '');\n }\n};\n\nconst decodeHTML = (html) => decode(html);\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreas = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choices = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","decodeHtmlEntities","str","replace","normalize","question","defaults","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","prepareChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","some","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","displayType","role","markup","playerSpellCheckEnabled","prompt","promptEnabled","rationale","responseCorrect","getScore","undefined","teacherInstructions","responseAreaInputConfiguration","extraCSSRules","rationaleEnabled","teacherInstructionsEnabled","html","decodeHTML","getInnerText","trim","config","responseAreas","match","maxScore","correctCount","total","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","replaceAll","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","nbOfResponseAreas"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA,IAAME,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAOC,eAAP;AAAA,SAA2B,UAACC,MAAD,EAAY;AAClE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,IAAI,KAAK,UAAb,EAAyB;AACvBG,MAAAA,GAAG,CAACG,OAAJ,GAAc,IAAd;AAEA,UAAMC,YAAY,GAAIL,MAAM,CAACM,QAAP,IAAmBN,MAAM,CAACM,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,UAAIF,YAAY,KAAK,SAArB,EAAgC;AAC9BJ,QAAAA,GAAG,CAACK,QAAJ,GAAeP,eAAe,CAAC,SAAD,CAA9B;AACD,OAFD,MAEO,IAAIM,YAAY,KAAK,QAArB,EAA+B;AACpCJ,QAAAA,GAAG,CAACK,QAAJ,GAAeN,MAAM,CAACM,QAAP,CAAgBH,KAA/B;AACD;AACF;;AAED,WAAOF,GAAP;AACD,GAnB4B;AAAA,CAAtB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CAAwB,UAACzB,MAAD,EAAS6B,KAAT,EAAmB;AACzC,UAAQ1B,KAAR,GAAyBH,MAAzB,CAAQG,KAAR;AAAA,UAAeD,KAAf,GAAyBF,MAAzB,CAAeE,KAAf;;AAEA,UAAIA,KAAK,KAAK,EAAV,IAAgBA,KAAK,KAAK,aAA9B,EAA6C;AAC3CoG,QAAAA,aAAa,CAACnG,KAAD,CAAb,GAAuB,8BAAvB;AACD,OAFD,MAEO;AACL,YAAMoG,eAAe,GAAGH,eAAe,CAACI,KAAhB,CAAsB3E,KAAK,GAAG,CAA9B,EAAiCc,IAAjC,CAAsC,UAACJ,CAAD;AAAA,iBAAOA,CAAC,CAACrC,KAAF,KAAYA,KAAnB;AAAA,SAAtC,CAAxB;;AAEA,YAAIqG,eAAJ,EAAqB;AACnBD,UAAAA,aAAa,CAACnG,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;AACF,KAZD;;AAcA,QAAI,CAAC,yBAAQmG,aAAR,CAAL,EAA6B;AAC3BP,MAAAA,gBAAgB,CAACrE,GAAD,CAAhB,GAAwB4E,aAAxB;AACD;AACF,GArBD;AAuBA,MAAMG,iBAAiB,GAAG,CAAChD,MAAM,CAACmB,KAAP,CAAa,gBAAb,KAAkC,EAAnC,EAAuClE,MAAjE;;AAEA,MAAI+F,iBAAiB,GAAGX,gBAAxB,EAA0C;AACxCE,IAAAA,MAAM,CAACrB,aAAP,0BAAuCmB,gBAAvC;AACD,GAFD,MAEO,IAAIW,iBAAiB,GAAG,CAAxB,EAA2B;AAChCT,IAAAA,MAAM,CAACrB,aAAP,GAAuB,mDAAvB;AACD;;AAED,MAAI,CAAC,yBAAQoB,gBAAR,CAAL,EAAgC;AAC9BC,IAAAA,MAAM,CAAC1E,OAAP,GAAiByE,gBAAjB;AACD;;AAED,SAAOC,MAAP;AACD,CAhDM","sourcesContent":["import debug from 'debug';\nimport map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport { decode } from 'he';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport Translator from '@pie-lib/pie-toolbox/translator';\nimport defaults from './defaults';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\n// we can't use the dom parser here because it is not available in the node environment\nconst decodeHtmlEntities = (str) => {\n if (!str) return '';\n return str\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'|'/g, '\\'')\n .replace(/&/g, '&');\n};\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without\n // the \"value\" property like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback);\n const choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, prepareChoiceFn);\n\n return obj;\n },\n {},\n );\n\n const { value = {} } = session || {};\n const feedback =\n env.mode === 'evaluate'\n ? reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val =\n !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n )\n : {};\n\n // check if at least one choice has an alternate\n const showNote = Object.values(choices).some((choice) => choice?.length > 1);\n const note =\n normalizedQuestion.note ||\n translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => decodeHtmlEntities(choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n choices,\n disabled: env.mode !== 'gather',\n displayType: normalizedQuestion.displayType,\n mode: env.mode,\n role: env.role,\n feedback,\n language: normalizedQuestion.language,\n markup: normalizedQuestion.markup,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt,\n rationale: defaults.rationale,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n showNote,\n teacherInstructions: defaults.teacherInstructions,\n responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : defaults.teacherInstructions;\n }\n\n resolve(out);\n });\n}\n\nexport const prepareVal = (html) => {\n return decodeHTML(getInnerText(html).trim());\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.+?)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({ id: '1', value });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\n// const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\nconst getInnerText = (html) => {\n if (typeof html !== 'string') {\n return '';\n }\n if (typeof html.replaceAll === 'function') {\n return html.replaceAll(/<[^>]*>/g, '');\n } else {\n // Polyfill for replaceAll using replace and a global regex\n return html.replace(/<[^>]*>/g, '');\n }\n};\n\nconst decodeHTML = (html) => decode(html);\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreas = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choices = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.6",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@pie-lib/pie-toolbox": "2.23.
|
|
11
|
+
"@pie-lib/pie-toolbox": "2.23.3",
|
|
12
12
|
"debug": "^3.1.0",
|
|
13
13
|
"he": "^1.2.0",
|
|
14
14
|
"lodash": "^4.17.15",
|
package/module/configure.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@5.5.2/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.2/module/index.js";
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
function getDefaultExportFromCjs(x) {
|
|
5
5
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -15888,9 +15888,9 @@ const require$$24 = _dll_pie_lib__pie_toolbox_editable_html;
|
|
|
15888
15888
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "onChoiceChanged", function (choice, value, index) {
|
|
15889
15889
|
var _this2$props2 = _this2.props, choiceChanged = _this2$props2.choiceChanged, lengthChanged = _this2$props2.lengthChanged, maxLength = _this2$props2.maxLength, choices = _this2$props2.choices;
|
|
15890
15890
|
var labelLengthsArr = choices.map(function (choice) {
|
|
15891
|
-
return (choice.label || '').length;
|
|
15891
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
15892
15892
|
});
|
|
15893
|
-
labelLengthsArr[index] = value.length;
|
|
15893
|
+
labelLengthsArr[index] = (0, _markupUtils.decodeHTML)(value).length;
|
|
15894
15894
|
var newLength = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
15895
15895
|
choiceChanged(_objectSpread(_objectSpread({}, choice), {}, {
|
|
15896
15896
|
label: value
|
|
@@ -15909,7 +15909,7 @@ const require$$24 = _dll_pie_lib__pie_toolbox_editable_html;
|
|
|
15909
15909
|
return 1;
|
|
15910
15910
|
}
|
|
15911
15911
|
var labelLengthsArr = choices.map(function (choice) {
|
|
15912
|
-
return (choice.label || '').length;
|
|
15912
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
15913
15913
|
});
|
|
15914
15914
|
return Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
15915
15915
|
});
|
|
@@ -16465,7 +16465,7 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
|
|
|
16465
16465
|
var _this$props3 = _this.props, model = _this$props3.model, onModelChanged = _this$props3.onModelChanged;
|
|
16466
16466
|
var choices = model.choices;
|
|
16467
16467
|
var maxLengthPerChoice = model.maxLengthPerChoice;
|
|
16468
|
-
var newValLength = (newVal || '').length;
|
|
16468
|
+
var newValLength = (0, _markupUtils.decodeHTML)(newVal || '').length;
|
|
16469
16469
|
if (!choices[index]) {
|
|
16470
16470
|
choices[index] = [{
|
|
16471
16471
|
label: newVal || '',
|
|
@@ -16559,8 +16559,8 @@ const require$$16 = _dll_pie_lib__pie_toolbox_config_ui;
|
|
|
16559
16559
|
markup: slateMarkup
|
|
16560
16560
|
});
|
|
16561
16561
|
Object.values(choices).forEach(function (choice, index) {
|
|
16562
|
-
var labelLengthsArr =
|
|
16563
|
-
return (choice.label || '').length;
|
|
16562
|
+
var labelLengthsArr = choice.map(function (choice) {
|
|
16563
|
+
return (0, _markupUtils.decodeHTML)(choice.label || '').length;
|
|
16564
16564
|
});
|
|
16565
16565
|
var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
16566
16566
|
if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
|
package/module/controller.js
CHANGED
|
@@ -7814,6 +7814,17 @@ const getAdjustedLength = (length) => {
|
|
|
7814
7814
|
return length + 5;
|
|
7815
7815
|
};
|
|
7816
7816
|
|
|
7817
|
+
// we can't use the dom parser here because it is not available in the node environment
|
|
7818
|
+
const decodeHtmlEntities = (str) => {
|
|
7819
|
+
if (!str) return '';
|
|
7820
|
+
return str
|
|
7821
|
+
.replace(/</g, '<')
|
|
7822
|
+
.replace(/>/g, '>')
|
|
7823
|
+
.replace(/"/g, '"')
|
|
7824
|
+
.replace(/'|'/g, '\'')
|
|
7825
|
+
.replace(/&/g, '&');
|
|
7826
|
+
};
|
|
7827
|
+
|
|
7817
7828
|
const normalize = (question) => ({ ...defaults, ...question });
|
|
7818
7829
|
|
|
7819
7830
|
/**
|
|
@@ -7883,7 +7894,7 @@ function model(question, session, env) {
|
|
|
7883
7894
|
|
|
7884
7895
|
// calculate maxLengthPerChoice array if it is not defined or defined incorrectly
|
|
7885
7896
|
Object.values(choices).forEach((choice, index) => {
|
|
7886
|
-
const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);
|
|
7897
|
+
const labelLengthsArr = (choice || []).map((choice) => decodeHtmlEntities(choice.label || '').length);
|
|
7887
7898
|
const length = Math.max(...labelLengthsArr);
|
|
7888
7899
|
|
|
7889
7900
|
if (
|
package/module/element.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@5.5.2/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.2/module/index.js";
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
m.forEach(function (e) {
|
|
5
5
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
@@ -149762,6 +149762,9 @@ const require$$16$1 = _dll_classnames;
|
|
|
149762
149762
|
(0, _classCallCheck2["default"])(this, BlankContent);
|
|
149763
149763
|
_this = _super.call(this, props);
|
|
149764
149764
|
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2["default"])(_this));
|
|
149765
|
+
_this.state = {
|
|
149766
|
+
hoveredElementSize: null
|
|
149767
|
+
};
|
|
149765
149768
|
return _this;
|
|
149766
149769
|
}
|
|
149767
149770
|
(0, _createClass2["default"])(BlankContent, [{
|
|
@@ -149782,21 +149785,46 @@ const require$$16$1 = _dll_classnames;
|
|
|
149782
149785
|
this.elementRef.className = this.elementRef.contains(event.target) ? classes.selected : '';
|
|
149783
149786
|
}
|
|
149784
149787
|
}
|
|
149788
|
+
}, {
|
|
149789
|
+
key: "getSnapshotBeforeUpdate",
|
|
149790
|
+
value: function getSnapshotBeforeUpdate(prevProps) {
|
|
149791
|
+
if (!prevProps.isOver && this.props.isOver && this.elementRef) {
|
|
149792
|
+
var node = this.elementRef;
|
|
149793
|
+
return {
|
|
149794
|
+
width: node.offsetWidth,
|
|
149795
|
+
height: node.offsetHeight
|
|
149796
|
+
};
|
|
149797
|
+
}
|
|
149798
|
+
return null;
|
|
149799
|
+
}
|
|
149785
149800
|
}, {
|
|
149786
149801
|
key: "componentDidUpdate",
|
|
149787
|
-
value: function componentDidUpdate() {
|
|
149788
|
-
if (this.elementRef) {
|
|
149802
|
+
value: function componentDidUpdate(prevProps, prevState, snapshot) {
|
|
149803
|
+
if (this.elementRef && typeof _mathRendering.renderMath === 'function') {
|
|
149789
149804
|
(0, _mathRendering.renderMath)(this.elementRef);
|
|
149790
149805
|
}
|
|
149806
|
+
if (snapshot && (!this.state.hoveredElementSize || this.state.hoveredElementSize.width !== snapshot.width || this.state.hoveredElementSize.height !== snapshot.height)) {
|
|
149807
|
+
this.setState({
|
|
149808
|
+
hoveredElementSize: snapshot
|
|
149809
|
+
});
|
|
149810
|
+
return;
|
|
149811
|
+
}
|
|
149812
|
+
if (prevProps.isOver && !this.props.isOver && this.state.hoveredElementSize) {
|
|
149813
|
+
this.setState({
|
|
149814
|
+
hoveredElementSize: null
|
|
149815
|
+
});
|
|
149816
|
+
}
|
|
149791
149817
|
}
|
|
149792
149818
|
}, {
|
|
149793
149819
|
key: "render",
|
|
149794
149820
|
value: function render() {
|
|
149795
149821
|
var _this2 = this;
|
|
149796
149822
|
var _this$props = this.props, n = _this$props.n, children = _this$props.children, isDragging = _this$props.isDragging, dragItem = _this$props.dragItem, isOver = _this$props.isOver, value = _this$props.value;
|
|
149823
|
+
var hoveredElementSize = this.state.hoveredElementSize;
|
|
149797
149824
|
var label = dragItem && isOver ? dragItem.value.value : value.value || "\xA0";
|
|
149798
149825
|
var finalLabel = isDragging ? "\xA0" : label;
|
|
149799
149826
|
var hasGrip = finalLabel !== "\xA0";
|
|
149827
|
+
var isPreview = dragItem && isOver;
|
|
149800
149828
|
return _react["default"].createElement("div", {
|
|
149801
149829
|
ref: function ref(_ref) {
|
|
149802
149830
|
return _this2.elementRef = _ref;
|
|
@@ -149805,13 +149833,15 @@ const require$$16$1 = _dll_classnames;
|
|
|
149805
149833
|
display: 'inline-flex',
|
|
149806
149834
|
minWidth: '178px',
|
|
149807
149835
|
minHeight: '36px',
|
|
149808
|
-
background:
|
|
149809
|
-
border:
|
|
149836
|
+
background: isPreview ? ("").concat(_renderUi.color.defaults.BORDER_LIGHT) : ("").concat(_renderUi.color.defaults.WHITE),
|
|
149837
|
+
border: isPreview ? ("1px solid ").concat(_renderUi.color.defaults.BORDER_DARK) : ("1px solid ").concat(_renderUi.color.defaults.BORDER_LIGHT),
|
|
149810
149838
|
boxSizing: 'border-box',
|
|
149811
149839
|
borderRadius: '3px',
|
|
149812
149840
|
overflow: 'hidden',
|
|
149813
149841
|
position: 'relative',
|
|
149814
|
-
padding: '8px 8px 8px 35px'
|
|
149842
|
+
padding: '8px 8px 8px 35px',
|
|
149843
|
+
width: hoveredElementSize ? hoveredElementSize.width : undefined,
|
|
149844
|
+
height: hoveredElementSize ? hoveredElementSize.height : undefined
|
|
149815
149845
|
},
|
|
149816
149846
|
"data-key": n.key,
|
|
149817
149847
|
contentEditable: false
|
|
@@ -149873,7 +149903,9 @@ const require$$16$1 = _dll_classnames;
|
|
|
149873
149903
|
var DropTile = (0, _drag.DropTarget)('drag-in-the-blank-choice', tileTarget, function (connect, monitor) {
|
|
149874
149904
|
return {
|
|
149875
149905
|
connectDropTarget: connect.dropTarget(),
|
|
149876
|
-
isOver: monitor.isOver(
|
|
149906
|
+
isOver: monitor.isOver({
|
|
149907
|
+
shallow: true
|
|
149908
|
+
}),
|
|
149877
149909
|
dragItem: monitor.getItem()
|
|
149878
149910
|
};
|
|
149879
149911
|
})(connectedBlankContent);
|
|
@@ -155560,14 +155592,18 @@ const require$$19 = _dll_classnames;
|
|
|
155560
155592
|
visibility: 'hidden',
|
|
155561
155593
|
top: 0,
|
|
155562
155594
|
left: 0
|
|
155563
|
-
}
|
|
155595
|
+
},
|
|
155596
|
+
tabIndex: -1,
|
|
155597
|
+
"aria-hidden": "true"
|
|
155564
155598
|
}, (choices || []).map(function (c, index) {
|
|
155565
155599
|
return _react["default"].createElement(_MenuItem["default"], {
|
|
155566
155600
|
key: index,
|
|
155567
155601
|
classes: {
|
|
155568
155602
|
root: classes.menuRoot,
|
|
155569
155603
|
selected: classes.selected
|
|
155570
|
-
}
|
|
155604
|
+
},
|
|
155605
|
+
tabIndex: -1,
|
|
155606
|
+
"aria-hidden": "true"
|
|
155571
155607
|
}, _react["default"].createElement("span", {
|
|
155572
155608
|
className: classes.label,
|
|
155573
155609
|
dangerouslySetInnerHTML: {
|
|
@@ -155576,7 +155612,9 @@ const require$$19 = _dll_classnames;
|
|
|
155576
155612
|
}));
|
|
155577
155613
|
})), _react["default"].createElement(_InputLabel["default"], {
|
|
155578
155614
|
className: classes.srOnly,
|
|
155579
|
-
id: labelId
|
|
155615
|
+
id: labelId,
|
|
155616
|
+
tabIndex: -1,
|
|
155617
|
+
"aria-hidden": "true"
|
|
155580
155618
|
}, labelText), _react["default"].createElement(_Button["default"], {
|
|
155581
155619
|
ref: this.buttonRef,
|
|
155582
155620
|
style: _objectSpread(_objectSpread({}, this.state.menuWidth && ({
|
package/module/manifest.json
CHANGED
package/module/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_classnames, _dll_react_dom, _dll_pie_framework__mathquill, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@5.5.2/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@8.5.2/module/index.js";
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
m.forEach(function (e) {
|
|
5
5
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
@@ -149725,6 +149725,9 @@ const require$$16$1 = _dll_classnames;
|
|
|
149725
149725
|
(0, _classCallCheck2["default"])(this, BlankContent);
|
|
149726
149726
|
_this = _super.call(this, props);
|
|
149727
149727
|
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2["default"])(_this));
|
|
149728
|
+
_this.state = {
|
|
149729
|
+
hoveredElementSize: null
|
|
149730
|
+
};
|
|
149728
149731
|
return _this;
|
|
149729
149732
|
}
|
|
149730
149733
|
(0, _createClass2["default"])(BlankContent, [{
|
|
@@ -149745,21 +149748,46 @@ const require$$16$1 = _dll_classnames;
|
|
|
149745
149748
|
this.elementRef.className = this.elementRef.contains(event.target) ? classes.selected : '';
|
|
149746
149749
|
}
|
|
149747
149750
|
}
|
|
149751
|
+
}, {
|
|
149752
|
+
key: "getSnapshotBeforeUpdate",
|
|
149753
|
+
value: function getSnapshotBeforeUpdate(prevProps) {
|
|
149754
|
+
if (!prevProps.isOver && this.props.isOver && this.elementRef) {
|
|
149755
|
+
var node = this.elementRef;
|
|
149756
|
+
return {
|
|
149757
|
+
width: node.offsetWidth,
|
|
149758
|
+
height: node.offsetHeight
|
|
149759
|
+
};
|
|
149760
|
+
}
|
|
149761
|
+
return null;
|
|
149762
|
+
}
|
|
149748
149763
|
}, {
|
|
149749
149764
|
key: "componentDidUpdate",
|
|
149750
|
-
value: function componentDidUpdate() {
|
|
149751
|
-
if (this.elementRef) {
|
|
149765
|
+
value: function componentDidUpdate(prevProps, prevState, snapshot) {
|
|
149766
|
+
if (this.elementRef && typeof _mathRendering.renderMath === 'function') {
|
|
149752
149767
|
(0, _mathRendering.renderMath)(this.elementRef);
|
|
149753
149768
|
}
|
|
149769
|
+
if (snapshot && (!this.state.hoveredElementSize || this.state.hoveredElementSize.width !== snapshot.width || this.state.hoveredElementSize.height !== snapshot.height)) {
|
|
149770
|
+
this.setState({
|
|
149771
|
+
hoveredElementSize: snapshot
|
|
149772
|
+
});
|
|
149773
|
+
return;
|
|
149774
|
+
}
|
|
149775
|
+
if (prevProps.isOver && !this.props.isOver && this.state.hoveredElementSize) {
|
|
149776
|
+
this.setState({
|
|
149777
|
+
hoveredElementSize: null
|
|
149778
|
+
});
|
|
149779
|
+
}
|
|
149754
149780
|
}
|
|
149755
149781
|
}, {
|
|
149756
149782
|
key: "render",
|
|
149757
149783
|
value: function render() {
|
|
149758
149784
|
var _this2 = this;
|
|
149759
149785
|
var _this$props = this.props, n = _this$props.n, children = _this$props.children, isDragging = _this$props.isDragging, dragItem = _this$props.dragItem, isOver = _this$props.isOver, value = _this$props.value;
|
|
149786
|
+
var hoveredElementSize = this.state.hoveredElementSize;
|
|
149760
149787
|
var label = dragItem && isOver ? dragItem.value.value : value.value || "\xA0";
|
|
149761
149788
|
var finalLabel = isDragging ? "\xA0" : label;
|
|
149762
149789
|
var hasGrip = finalLabel !== "\xA0";
|
|
149790
|
+
var isPreview = dragItem && isOver;
|
|
149763
149791
|
return _react["default"].createElement("div", {
|
|
149764
149792
|
ref: function ref(_ref) {
|
|
149765
149793
|
return _this2.elementRef = _ref;
|
|
@@ -149768,13 +149796,15 @@ const require$$16$1 = _dll_classnames;
|
|
|
149768
149796
|
display: 'inline-flex',
|
|
149769
149797
|
minWidth: '178px',
|
|
149770
149798
|
minHeight: '36px',
|
|
149771
|
-
background:
|
|
149772
|
-
border:
|
|
149799
|
+
background: isPreview ? ("").concat(_renderUi.color.defaults.BORDER_LIGHT) : ("").concat(_renderUi.color.defaults.WHITE),
|
|
149800
|
+
border: isPreview ? ("1px solid ").concat(_renderUi.color.defaults.BORDER_DARK) : ("1px solid ").concat(_renderUi.color.defaults.BORDER_LIGHT),
|
|
149773
149801
|
boxSizing: 'border-box',
|
|
149774
149802
|
borderRadius: '3px',
|
|
149775
149803
|
overflow: 'hidden',
|
|
149776
149804
|
position: 'relative',
|
|
149777
|
-
padding: '8px 8px 8px 35px'
|
|
149805
|
+
padding: '8px 8px 8px 35px',
|
|
149806
|
+
width: hoveredElementSize ? hoveredElementSize.width : undefined,
|
|
149807
|
+
height: hoveredElementSize ? hoveredElementSize.height : undefined
|
|
149778
149808
|
},
|
|
149779
149809
|
"data-key": n.key,
|
|
149780
149810
|
contentEditable: false
|
|
@@ -149836,7 +149866,9 @@ const require$$16$1 = _dll_classnames;
|
|
|
149836
149866
|
var DropTile = (0, _drag.DropTarget)('drag-in-the-blank-choice', tileTarget, function (connect, monitor) {
|
|
149837
149867
|
return {
|
|
149838
149868
|
connectDropTarget: connect.dropTarget(),
|
|
149839
|
-
isOver: monitor.isOver(
|
|
149869
|
+
isOver: monitor.isOver({
|
|
149870
|
+
shallow: true
|
|
149871
|
+
}),
|
|
149840
149872
|
dragItem: monitor.getItem()
|
|
149841
149873
|
};
|
|
149842
149874
|
})(connectedBlankContent);
|
|
@@ -155523,14 +155555,18 @@ const require$$19 = _dll_classnames;
|
|
|
155523
155555
|
visibility: 'hidden',
|
|
155524
155556
|
top: 0,
|
|
155525
155557
|
left: 0
|
|
155526
|
-
}
|
|
155558
|
+
},
|
|
155559
|
+
tabIndex: -1,
|
|
155560
|
+
"aria-hidden": "true"
|
|
155527
155561
|
}, (choices || []).map(function (c, index) {
|
|
155528
155562
|
return _react["default"].createElement(_MenuItem["default"], {
|
|
155529
155563
|
key: index,
|
|
155530
155564
|
classes: {
|
|
155531
155565
|
root: classes.menuRoot,
|
|
155532
155566
|
selected: classes.selected
|
|
155533
|
-
}
|
|
155567
|
+
},
|
|
155568
|
+
tabIndex: -1,
|
|
155569
|
+
"aria-hidden": "true"
|
|
155534
155570
|
}, _react["default"].createElement("span", {
|
|
155535
155571
|
className: classes.label,
|
|
155536
155572
|
dangerouslySetInnerHTML: {
|
|
@@ -155539,7 +155575,9 @@ const require$$19 = _dll_classnames;
|
|
|
155539
155575
|
}));
|
|
155540
155576
|
})), _react["default"].createElement(_InputLabel["default"], {
|
|
155541
155577
|
className: classes.srOnly,
|
|
155542
|
-
id: labelId
|
|
155578
|
+
id: labelId,
|
|
155579
|
+
tabIndex: -1,
|
|
155580
|
+
"aria-hidden": "true"
|
|
155543
155581
|
}, labelText), _react["default"].createElement(_Button["default"], {
|
|
155544
155582
|
ref: this.buttonRef,
|
|
155545
155583
|
style: _objectSpread(_objectSpread({}, this.state.menuWidth && ({
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "7.
|
|
7
|
+
"version": "7.7.0",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@material-ui/core": "^3.9.2",
|
|
14
14
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
15
|
-
"@pie-lib/pie-toolbox": "2.23.
|
|
15
|
+
"@pie-lib/pie-toolbox": "2.23.3",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"he": "^1.2.0",
|
|
18
18
|
"lodash": "^4.17.10",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "bef1b851f70ca272ca37ee987d36750f1783781b",
|
|
26
26
|
"main": "lib/index.js",
|
|
27
27
|
"module": "src/index.js",
|
|
28
28
|
"exports": {
|