@pie-element/explicit-constructed-response 7.3.5-next.8 → 7.3.6-next.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 +15 -0
- package/configure/CHANGELOG.md +13 -0
- package/configure/lib/alternateSection.js +1 -1
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/ecr-toolbar.js +1 -1
- package/configure/lib/ecr-toolbar.js.map +1 -1
- package/configure/lib/markupUtils.js +8 -1
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/package.json +2 -2
- package/controller/CHANGELOG.md +12 -0
- package/controller/lib/index.js +6 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/lib/main.js +4 -10
- package/lib/main.js.map +1 -1
- package/module/configure.js +10 -5
- package/module/controller.js +12 -3
- package/module/element.js +18 -22
- package/module/index.html +1 -1
- package/module/manifest.json +3 -3
- package/module/print.html +1 -1
- package/module/print.js +18 -22
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.3.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@7.3.4...@pie-element/explicit-constructed-response@7.3.5) (2025-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4820, PD-4766 ([7ccdb40](https://github.com/pie-framework/pie-elements/commit/7ccdb405614f1c310efe530d97c46fe324c0a669))
|
|
12
|
+
* **ECR:** Adjust values in evaluate when answers include special characters PD-4821 ([4348d10](https://github.com/pie-framework/pie-elements/commit/4348d10eb8dc1b42ac999ddd6139f3c1070276ba))
|
|
13
|
+
* **ECR:** revert snapshots PD-4821 ([b3eccf2](https://github.com/pie-framework/pie-elements/commit/b3eccf2b70ff5611b626f720988333014a365c87))
|
|
14
|
+
* **ECR:** show in correct answers HTML reserved characters PD-4821 ([2a72db3](https://github.com/pie-framework/pie-elements/commit/2a72db3fc996b0f39b921a4b2a3594963e27dc9d))
|
|
15
|
+
* **explicit-constructed-response:** get rid of local state as it should be updated based on session value PD-4695 ([96e5383](https://github.com/pie-framework/pie-elements/commit/96e53833da65d0d1c648adf5a21fec60780ef575))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
## [7.3.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@7.3.3...@pie-element/explicit-constructed-response@7.3.4) (2025-02-19)
|
|
7
22
|
|
|
8
23
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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.2.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@7.2.4...@pie-element/explicit-constructed-response-configure@7.2.5) (2025-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4820, PD-4766 ([7ccdb40](https://github.com/pie-framework/pie-elements/commit/7ccdb405614f1c310efe530d97c46fe324c0a669))
|
|
12
|
+
* **ECR:** revert snapshots PD-4821 ([b3eccf2](https://github.com/pie-framework/pie-elements/commit/b3eccf2b70ff5611b626f720988333014a365c87))
|
|
13
|
+
* **ECR:** show in correct answers HTML reserved characters PD-4821 ([2a72db3](https://github.com/pie-framework/pie-elements/commit/2a72db3fc996b0f39b921a4b2a3594963e27dc9d))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [7.2.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@7.2.3...@pie-element/explicit-constructed-response-configure@7.2.4) (2025-02-19)
|
|
7
20
|
|
|
8
21
|
|
|
@@ -356,7 +356,7 @@ var AlternateSection = /*#__PURE__*/function (_React$Component2) {
|
|
|
356
356
|
return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
357
357
|
key: index,
|
|
358
358
|
value: c === null || c === void 0 ? void 0 : c.value
|
|
359
|
-
}, c === null || c === void 0 ? void 0 : c.label);
|
|
359
|
+
}, (0, _markupUtils.decodeHTML)(c === null || c === void 0 ? void 0 : c.label));
|
|
360
360
|
})), choices && choices.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
|
|
361
361
|
className: classes.rightContainer
|
|
362
362
|
}, maxLength && showMaxLength && /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
@@ -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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA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A1CF,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 } 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 {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;AACVC,MAAAA,UAAU,EAAE,YADF;AAEVC,MAAAA,aAAa,EAAE,QAFL;AAGVC,MAAAA,OAAO,EAAE,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AAAA,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"}
|
|
@@ -70,7 +70,7 @@ var ECRToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
70
70
|
value = _this$props.value,
|
|
71
71
|
onToolbarDone = _this$props.onToolbarDone,
|
|
72
72
|
onChangeResponse = _this$props.onChangeResponse;
|
|
73
|
-
var sanitizedMarkup = (0, _markupUtils.stripHtmlTags)(markup);
|
|
73
|
+
var sanitizedMarkup = (0, _markupUtils.decodeHTML)((0, _markupUtils.stripHtmlTags)(markup));
|
|
74
74
|
|
|
75
75
|
_this.setState({
|
|
76
76
|
markup: sanitizedMarkup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["findSlateNode","key","window","document","querySelector","ECRToolbar","markup","toolbarStyle","props","node","value","onToolbarDone","onChangeResponse","sanitizedMarkup","setState","updatedData","data","toJSON","change","setNodeByKey","nextText","getNextText","moveFocusTo","moveAnchorTo","respAreaMarkup","event","clickedInside","correctChoice","choice","domNode","domNodeRect","getBoundingClientRect","editor","closest","editorRect","top","left","label","position","height","width","classes","maxLengthPerChoiceEnabled","pluginProps","spellCheck","state","inputProps","maxLength","preventDone","onRespAreaChange","val","onDone","e","relatedTarget","onBlur","onKeyDown","language","minWidth","isHidden","characters","disabled","React","Component","PropTypes","object","func","isRequired","shape","bool","StyledECRToolbar","theme","backgroundColor","palette","common","white","outline","lineHeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,GAAD,EAAS;AAC7B,SAAOC,MAAM,CAACC,QAAP,CAAgBC,aAAhB,CAA8B,gBAAgBH,GAAhB,GAAsB,IAApD,CAAP;AACD,CAFD;;IAIaI,U;;;;;;;;;;;;;;;8FAmBD;AACJC,MAAAA,MAAM,EAAE,EADJ;AAEJC,MAAAA,YAAY,EAAE;AAFV,K;+FA+BC,UAACD,MAAD,EAAY;AACjB,wBAAyD,MAAKE,KAA9D;AAA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AyBC,QAA1B;AAFF;AA7BjB,SAiCQd,UAjCR,EADJ,CADJ;AAuCH;;;EA5H2Be,kBAAMC,S;;;iCAAzBzD,U,eACQ;AACjBsB,EAAAA,aAAa,EAAEoC,sBAAUC,MADR;AAEjBvB,EAAAA,OAAO,EAAEsB,sBAAUC,MAFF;AAGjBvD,EAAAA,IAAI,EAAEsD,sBAAUC,MAHC;AAIjBb,EAAAA,MAAM,EAAEY,sBAAUE,IAJD;AAKjBrD,EAAAA,gBAAgB,EAAEmD,sBAAUE,IAAV,CAAeC,UALhB;AAMjBvD,EAAAA,aAAa,EAAEoD,sBAAUE,IAAV,CAAeC,UANb;AAOjBxD,EAAAA,KAAK,EAAEqD,sBAAUI,KAAV,CAAgB;AACrBjD,IAAAA,MAAM,EAAE6C,sBAAUE,IAAV,CAAeC,UADF;AAErB/D,IAAAA,QAAQ,EAAE4D,sBAAUI,KAAV,CAAgB;AACxB9C,MAAAA,WAAW,EAAE0C,sBAAUE,IAAV,CAAeC;AADJ,KAAhB;AAFW,GAAhB,CAPU;AAajBxB,EAAAA,yBAAyB,EAAEqB,sBAAUK,IAbpB;AAcjBzB,EAAAA,WAAW,EAAEoB,sBAAUC,MAdN;AAejBpB,EAAAA,UAAU,EAAEmB,sBAAUK;AAfL,C;AA8HrB,IAAMC,gBAAgB,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AAC5ChE,IAAAA,MAAM,EAAE;AACJiE,MAAAA,eAAe,EAAED,KAAK,CAACE,OAAN,CAAcC,MAAd,CAAqBC,KADlC;AAEJC,MAAAA,OAAO,EAAE,MAFL;AAGJC,MAAAA,UAAU,EAAE;AAHR;AADoC,GAAZ;AAAA,CAAX,EAMrBvE,UANqB,CAAzB;eAQegE,gB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\nimport { stripHtmlTags } from './markupUtils';\n\nconst findSlateNode = (key) => {\n return window.document.querySelector('[data-key=\"' + key + '\"]');\n};\n\nexport class ECRToolbar extends React.Component {\n static propTypes = {\n correctChoice: PropTypes.object,\n classes: PropTypes.object,\n node: PropTypes.object,\n onDone: PropTypes.func,\n onChangeResponse: PropTypes.func.isRequired,\n onToolbarDone: PropTypes.func.isRequired,\n value: PropTypes.shape({\n change: PropTypes.func.isRequired,\n document: PropTypes.shape({\n getNextText: PropTypes.func.isRequired,\n }),\n }),\n maxLengthPerChoiceEnabled: PropTypes.bool,\n pluginProps: PropTypes.object,\n spellCheck: PropTypes.bool,\n };\n\n state = {\n markup: '',\n toolbarStyle: {},\n };\n\n componentDidMount() {\n const { correctChoice, node } = this.props;\n const choice = correctChoice || {};\n\n const domNode = findSlateNode(node.key);\n\n if (domNode) {\n //eslint-disable-next-line\n const domNodeRect = domNode.getBoundingClientRect();\n const editor = domNode.closest('[data-slate-editor]');\n const editorRect = editor.getBoundingClientRect();\n const top = domNodeRect.top - editorRect.top;\n const left = domNodeRect.left - editorRect.left;\n\n this.setState({\n markup: choice.label,\n toolbarStyle: {\n position: 'absolute',\n top: `${top + domNodeRect.height + 17}px`,\n left: `${left + 20}px`,\n width: `${domNodeRect.width - 4}px`,\n },\n });\n }\n }\n\n onDone = (markup) => {\n const { node, value, onToolbarDone, onChangeResponse } = this.props;\n const sanitizedMarkup = stripHtmlTags(markup);\n this.setState({ markup: sanitizedMarkup });\n\n const updatedData = { ...node.data.toJSON(), value: sanitizedMarkup };\n const change = value.change().setNodeByKey(node.key, { data: updatedData });\n const nextText = value.document.getNextText(node.key);\n\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n onToolbarDone(change, true);\n onChangeResponse(sanitizedMarkup);\n };\n\n onRespAreaChange = (respAreaMarkup) => {\n this.setState({ respAreaMarkup });\n };\n\n onKeyDown = (event) => {\n if (event.key === 'Enter') {\n return false;\n }\n };\n\n onBlur = () => {\n if (this.clickedInside) {\n this.clickedInside = false;\n }\n };\n\n render() {\n const { classes, maxLengthPerChoiceEnabled, pluginProps, spellCheck } = this.props;\n const { markup, toolbarStyle } = this.state;\n const inputProps = maxLengthPerChoiceEnabled ? {} : { maxLength: 25 };\n\n return (\n <div style={toolbarStyle}>\n <EditableHtml\n autoFocus={true}\n className={classes.markup}\n disableUnderline\n onChange={(respAreaMarkup) => {\n if (this.preventDone) {\n return;\n }\n this.onRespAreaChange(respAreaMarkup);\n }}\n onDone={(val) => {\n if (this.preventDone) {\n return;\n }\n this.onDone(val);\n }}\n onBlur={(e) => {\n this.preventDone = e.relatedTarget && e.relatedTarget.closest('.insert-character-dialog');\n this.onBlur(e);\n }}\n onKeyDown={this.onKeyDown}\n markup={markup || ''}\n activePlugins={['languageCharacters']}\n pluginProps={pluginProps}\n languageCharactersProps={[{ language: 'spanish' }]}\n minHeight={'15px'}\n maxHeight={'15px'}\n spellCheck={spellCheck}\n autoWidthToolbar\n toolbarOpts={{\n minWidth: 'auto',\n isHidden: !!pluginProps?.characters?.disabled\n }}\n {...inputProps}\n />\n </div>\n );\n }\n}\n\nconst StyledECRToolbar = withStyles((theme) => ({\n markup: {\n backgroundColor: theme.palette.common.white,\n outline: 'none',\n lineHeight: '15px'\n },\n}))(ECRToolbar);\n\nexport default StyledECRToolbar;\n"],"file":"ecr-toolbar.js"}
|
|
1
|
+
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["findSlateNode","key","window","document","querySelector","ECRToolbar","markup","toolbarStyle","props","node","value","onToolbarDone","onChangeResponse","sanitizedMarkup","setState","updatedData","data","toJSON","change","setNodeByKey","nextText","getNextText","moveFocusTo","moveAnchorTo","respAreaMarkup","event","clickedInside","correctChoice","choice","domNode","domNodeRect","getBoundingClientRect","editor","closest","editorRect","top","left","label","position","height","width","classes","maxLengthPerChoiceEnabled","pluginProps","spellCheck","state","inputProps","maxLength","preventDone","onRespAreaChange","val","onDone","e","relatedTarget","onBlur","onKeyDown","language","minWidth","isHidden","characters","disabled","React","Component","PropTypes","object","func","isRequired","shape","b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B,sBAAUK;AAfL,C;AA8HrB,IAAMC,gBAAgB,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AAC5ChE,IAAAA,MAAM,EAAE;AACJiE,MAAAA,eAAe,EAAED,KAAK,CAACE,OAAN,CAAcC,MAAd,CAAqBC,KADlC;AAEJC,MAAAA,OAAO,EAAE,MAFL;AAGJC,MAAAA,UAAU,EAAE;AAHR;AADoC,GAAZ;AAAA,CAAX,EAMrBvE,UANqB,CAAzB;eAQegE,gB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { EditableHtml } from '@pie-lib/pie-toolbox/editable-html';\nimport { stripHtmlTags, decodeHTML } from './markupUtils';\n\nconst findSlateNode = (key) => {\n return window.document.querySelector('[data-key=\"' + key + '\"]');\n};\n\nexport class ECRToolbar extends React.Component {\n static propTypes = {\n correctChoice: PropTypes.object,\n classes: PropTypes.object,\n node: PropTypes.object,\n onDone: PropTypes.func,\n onChangeResponse: PropTypes.func.isRequired,\n onToolbarDone: PropTypes.func.isRequired,\n value: PropTypes.shape({\n change: PropTypes.func.isRequired,\n document: PropTypes.shape({\n getNextText: PropTypes.func.isRequired,\n }),\n }),\n maxLengthPerChoiceEnabled: PropTypes.bool,\n pluginProps: PropTypes.object,\n spellCheck: PropTypes.bool,\n };\n\n state = {\n markup: '',\n toolbarStyle: {},\n };\n\n componentDidMount() {\n const { correctChoice, node } = this.props;\n const choice = correctChoice || {};\n\n const domNode = findSlateNode(node.key);\n\n if (domNode) {\n //eslint-disable-next-line\n const domNodeRect = domNode.getBoundingClientRect();\n const editor = domNode.closest('[data-slate-editor]');\n const editorRect = editor.getBoundingClientRect();\n const top = domNodeRect.top - editorRect.top;\n const left = domNodeRect.left - editorRect.left;\n\n this.setState({\n markup: choice.label,\n toolbarStyle: {\n position: 'absolute',\n top: `${top + domNodeRect.height + 17}px`,\n left: `${left + 20}px`,\n width: `${domNodeRect.width - 4}px`,\n },\n });\n }\n }\n\n onDone = (markup) => {\n const { node, value, onToolbarDone, onChangeResponse } = this.props;\n const sanitizedMarkup = decodeHTML(stripHtmlTags(markup));\n this.setState({ markup: sanitizedMarkup });\n\n const updatedData = { ...node.data.toJSON(), value: sanitizedMarkup };\n const change = value.change().setNodeByKey(node.key, { data: updatedData });\n const nextText = value.document.getNextText(node.key);\n\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n onToolbarDone(change, true);\n onChangeResponse(sanitizedMarkup);\n };\n\n onRespAreaChange = (respAreaMarkup) => {\n this.setState({ respAreaMarkup });\n };\n\n onKeyDown = (event) => {\n if (event.key === 'Enter') {\n return false;\n }\n };\n\n onBlur = () => {\n if (this.clickedInside) {\n this.clickedInside = false;\n }\n };\n\n render() {\n const { classes, maxLengthPerChoiceEnabled, pluginProps, spellCheck } = this.props;\n const { markup, toolbarStyle } = this.state;\n const inputProps = maxLengthPerChoiceEnabled ? {} : { maxLength: 25 };\n\n return (\n <div style={toolbarStyle}>\n <EditableHtml\n autoFocus={true}\n className={classes.markup}\n disableUnderline\n onChange={(respAreaMarkup) => {\n if (this.preventDone) {\n return;\n }\n this.onRespAreaChange(respAreaMarkup);\n }}\n onDone={(val) => {\n if (this.preventDone) {\n return;\n }\n this.onDone(val);\n }}\n onBlur={(e) => {\n this.preventDone = e.relatedTarget && e.relatedTarget.closest('.insert-character-dialog');\n this.onBlur(e);\n }}\n onKeyDown={this.onKeyDown}\n markup={markup || ''}\n activePlugins={['languageCharacters']}\n pluginProps={pluginProps}\n languageCharactersProps={[{ language: 'spanish' }]}\n minHeight={'15px'}\n maxHeight={'15px'}\n spellCheck={spellCheck}\n autoWidthToolbar\n toolbarOpts={{\n minWidth: 'auto',\n isHidden: !!pluginProps?.characters?.disabled\n }}\n {...inputProps}\n />\n </div>\n );\n }\n}\n\nconst StyledECRToolbar = withStyles((theme) => ({\n markup: {\n backgroundColor: theme.palette.common.white,\n outline: 'none',\n lineHeight: '15px'\n },\n}))(ECRToolbar);\n\nexport default StyledECRToolbar;\n"],"file":"ecr-toolbar.js"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.stripHtmlTags = exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.createSlateMarkup = void 0;
|
|
8
|
+
exports.stripHtmlTags = exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.decodeHTML = exports.createSlateMarkup = void 0;
|
|
9
9
|
|
|
10
10
|
var _escape = _interopRequireDefault(require("lodash/escape"));
|
|
11
11
|
|
|
@@ -84,4 +84,11 @@ var stripHtmlTags = function stripHtmlTags(markup) {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
exports.stripHtmlTags = stripHtmlTags;
|
|
87
|
+
|
|
88
|
+
var decodeHTML = function decodeHTML(html) {
|
|
89
|
+
var doc = new DOMParser().parseFromString(html, 'text/html');
|
|
90
|
+
return doc.body.textContent || '';
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
exports.decodeHTML = decodeHTML;
|
|
87
94
|
//# sourceMappingURL=markupUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/markupUtils.js"],"names":["tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label","getAdjustedLength","length","stripHtmlTags"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA,IAAMA,QAAQ,GAAG,+BAAjB,C,CACA;;AACA,IAAMC,QAAQ,GAAG,sCAAjB,C,CACA;;AACA,IAAMC,kBAAkB,GAAG,IAAIC,MAAJ,kBACfH,QADe,uBACMC,QADN,yBAC6BD,QAD7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,EAAQC,CAAR,EAAc;AAC5C,QAAMC,KAAK,GAAGH,OAAO,CAACE,CAAD,CAAP,CAAW,CAAX,EAAcC,KAAd,IAAuB,EAArC;AAEA,oFAAsED,CAAtE,6BAAwF,wBAAOC,KAAP,CAAxF;AACD,GAJM,CAAP;AAKD,CAZM,C,CAcP;;;;;AACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,MAAD,EAAY;AAC3C,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,SAAOA,MAAM,GAAG,CAAhB;AACD,CAdM;;;;AAgBA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACzB,MAAD,EAAY;AACvC,MAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAO,EAAP;AACD;;AACD,SAAOA,MAAM,CAACC,OAAP,CAAe,iBAAf,EAAkC,EAAlC,CAAP;AACD,CALM","sourcesContent":["import escape from 'lodash/escape';\n\n// do not remove \\t from \\times, \\triangle, \\tan, \\theta or \\therefore\nconst tSymbols = 'imes|riangle|an|heta|herefore';\n// do not remove \\n from \\nthroot, \\nparallel, \\ncong, \\napprox, \\neq, \\ne or \\nsim\nconst nSymbols = 'throot|parallel|cong|approx|eq|e|sim';\n// match all \\t and \\n that are not part of math symbols that starts with \\t or \\n\nconst matchTabAndNewLine = new RegExp(\n `(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))|(\\\\\\\\t(?!${tSymbols}))|(\\\\\\\\n(?!${nSymbols}))`,\n 'g',\n);\n\nexport const removeUnwantedCharacters = (markup) =>\n markup.replace(matchTabAndNewLine, '').replace(/\\\\\"/g, '\"').replace(/\\\\\\//g, '/');\n\nconst createElementFromHTML = (htmlString = '') => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport const processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup || '');\n const slateMarkup = createElementFromHTML(newMarkup || '');\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]').forEach((s) => {\n s.replaceWith(`{{${index++}}}`);\n });\n\n return slateMarkup.innerHTML;\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices) => {\n if (!markup) {\n return '';\n }\n\n const newMarkup = removeUnwantedCharacters(markup);\n\n return newMarkup.replace(REGEX, (match, g) => {\n const label = choices[g][0].label || '';\n\n return `<span data-type=\"explicit_constructed_response\" data-index=\"${g}\" data-value=\"${escape(label)}\"></span>`;\n });\n};\n\n// also used in controller/src/index.js\nexport const 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 stripHtmlTags = (markup) => {\n if (typeof markup !== 'string') {\n return '';\n }\n return markup.replace(/<\\/?[^>]+(>|$)/g, \"\");\n};"],"file":"markupUtils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/markupUtils.js"],"names":["tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label","getAdjustedLength","length","stripHtmlTags","decodeHTML","html","doc","DOMParser","parseFromString","body","textContent"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA,IAAMA,QAAQ,GAAG,+BAAjB,C,CACA;;AACA,IAAMC,QAAQ,GAAG,sCAAjB,C,CACA;;AACA,IAAMC,kBAAkB,GAAG,IAAIC,MAAJ,kBACfH,QADe,uBACMC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B,EAAyB,UAACG,KAAD,EAAQC,CAAR,EAAc;AAC5C,QAAMC,KAAK,GAAGH,OAAO,CAACE,CAAD,CAAP,CAAW,CAAX,EAAcC,KAAd,IAAuB,EAArC;AAEA,oFAAsED,CAAtE,6BAAwF,wBAAOC,KAAP,CAAxF;AACD,GAJM,CAAP;AAKD,CAZM,C,CAcP;;;;;AACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,MAAD,EAAY;AAC3C,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,SAAOA,MAAM,GAAG,CAAhB;AACD,CAdM;;;;AAgBA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACzB,MAAD,EAAY;AACvC,MAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAO,EAAP;AACD;;AACD,SAAOA,MAAM,CAACC,OAAP,CAAe,iBAAf,EAAkC,EAAlC,CAAP;AACD,CALM;;;;AAOA,IAAMyB,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAU;AAClC,MAAMC,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCH,IAAhC,EAAsC,WAAtC,CAAZ;AACA,SAAOC,GAAG,CAACG,IAAJ,CAASC,WAAT,IAAwB,EAA/B;AACD,CAHM","sourcesContent":["import escape from 'lodash/escape';\n\n// do not remove \\t from \\times, \\triangle, \\tan, \\theta or \\therefore\nconst tSymbols = 'imes|riangle|an|heta|herefore';\n// do not remove \\n from \\nthroot, \\nparallel, \\ncong, \\napprox, \\neq, \\ne or \\nsim\nconst nSymbols = 'throot|parallel|cong|approx|eq|e|sim';\n// match all \\t and \\n that are not part of math symbols that starts with \\t or \\n\nconst matchTabAndNewLine = new RegExp(\n `(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))|(\\\\\\\\t(?!${tSymbols}))|(\\\\\\\\n(?!${nSymbols}))`,\n 'g',\n);\n\nexport const removeUnwantedCharacters = (markup) =>\n markup.replace(matchTabAndNewLine, '').replace(/\\\\\"/g, '\"').replace(/\\\\\\//g, '/');\n\nconst createElementFromHTML = (htmlString = '') => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport const processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup || '');\n const slateMarkup = createElementFromHTML(newMarkup || '');\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]').forEach((s) => {\n s.replaceWith(`{{${index++}}}`);\n });\n\n return slateMarkup.innerHTML;\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices) => {\n if (!markup) {\n return '';\n }\n\n const newMarkup = removeUnwantedCharacters(markup);\n\n return newMarkup.replace(REGEX, (match, g) => {\n const label = choices[g][0].label || '';\n\n return `<span data-type=\"explicit_constructed_response\" data-index=\"${g}\" data-value=\"${escape(label)}\"></span>`;\n });\n};\n\n// also used in controller/src/index.js\nexport const 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 stripHtmlTags = (markup) => {\n if (typeof markup !== 'string') {\n return '';\n }\n return markup.replace(/<\\/?[^>]+(>|$)/g, \"\");\n};\n\nexport const decodeHTML = (html) => {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n};"],"file":"markupUtils.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-configure",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.5",
|
|
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.9.
|
|
11
|
+
"@pie-lib/pie-toolbox": "2.9.5",
|
|
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.1.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@5.1.15...@pie-element/explicit-constructed-response-controller@5.1.16) (2025-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update pie-lib/pie-toolbox PD-4820, PD-4766 ([7ccdb40](https://github.com/pie-framework/pie-elements/commit/7ccdb405614f1c310efe530d97c46fe324c0a669))
|
|
12
|
+
* **ECR:** Adjust values in evaluate when answers include special characters PD-4821 ([4348d10](https://github.com/pie-framework/pie-elements/commit/4348d10eb8dc1b42ac999ddd6139f3c1070276ba))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [5.1.15](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@5.1.14...@pie-element/explicit-constructed-response-controller@5.1.15) (2025-02-19)
|
|
7
19
|
|
|
8
20
|
|
package/controller/lib/index.js
CHANGED
|
@@ -215,7 +215,7 @@ function model(question, session, env) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
var prepareVal = function prepareVal(html) {
|
|
218
|
-
return getInnerText(html).trim();
|
|
218
|
+
return decodeHTML(getInnerText(html).trim());
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
exports.prepareVal = prepareVal;
|
|
@@ -305,6 +305,11 @@ var getInnerText = function getInnerText(html) {
|
|
|
305
305
|
// Polyfill for replaceAll using replace and a global regex
|
|
306
306
|
return html.replace(/<[^>]*>/g, '');
|
|
307
307
|
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
var decodeHTML = function decodeHTML(html) {
|
|
311
|
+
var doc = new DOMParser().parseFromString(html, 'text/html');
|
|
312
|
+
return doc.body.textContent || '';
|
|
308
313
|
}; // remove all html tags except img and iframe
|
|
309
314
|
|
|
310
315
|
|
|
@@ -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","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;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EO,IAAIW,iBAAiB,GAAG,CAAxB,EAA2B;AAChCT,IAAAA,MAAM,CAACvB,aAAP,GAAuB,mDAAvB;AACD;;AAED,MAAI,CAAC,yBAAQsB,gBAAR,CAAL,EAAgC;AAC9BC,IAAAA,MAAM,CAAC3E,OAAP,GAAiB0E,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 { 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 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\n// remove all html tags except img and iframe\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/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","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","doc","DOMParser","parseFromString","body","textContent","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","nbOfResponseAreas"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;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;A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,OAAP,GAAiBgF,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 { 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) => {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n};\n\n// remove all html tags except img and iframe\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/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.1.
|
|
4
|
+
"version": "5.1.16",
|
|
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.9.
|
|
11
|
+
"@pie-lib/pie-toolbox": "2.9.5",
|
|
12
12
|
"debug": "^3.1.0",
|
|
13
13
|
"lodash": "^4.17.15",
|
|
14
14
|
"type-of": "^2.0.1"
|
package/lib/main.js
CHANGED
|
@@ -67,8 +67,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
67
67
|
|
|
68
68
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
69
69
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
70
|
-
showCorrectAnswer: _this.props.alwaysShowCorrect || false
|
|
71
|
-
value: _this.props.value
|
|
70
|
+
showCorrectAnswer: _this.props.alwaysShowCorrect || false
|
|
72
71
|
});
|
|
73
72
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getChangeSession", function (maxLengthPerChoice) {
|
|
74
73
|
return maxLengthPerChoice && maxLengthPerChoice.every(function (val, i, arr) {
|
|
@@ -84,10 +83,6 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
84
83
|
});
|
|
85
84
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeSession", _this.getChangeSession(_this.props.maxLengthPerChoice));
|
|
86
85
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (value) {
|
|
87
|
-
_this.setState({
|
|
88
|
-
value: value
|
|
89
|
-
});
|
|
90
|
-
|
|
91
86
|
_this.changeSession(value);
|
|
92
87
|
});
|
|
93
88
|
return _this;
|
|
@@ -131,9 +126,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
131
126
|
}, {
|
|
132
127
|
key: "render",
|
|
133
128
|
value: function render() {
|
|
134
|
-
var
|
|
135
|
-
showCorrectAnswer = _this$state.showCorrectAnswer,
|
|
136
|
-
value = _this$state.value;
|
|
129
|
+
var showCorrectAnswer = this.state.showCorrectAnswer;
|
|
137
130
|
var _this$props2 = this.props,
|
|
138
131
|
alwaysShowCorrect = _this$props2.alwaysShowCorrect,
|
|
139
132
|
animationsDisabled = _this$props2.animationsDisabled,
|
|
@@ -151,7 +144,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
151
144
|
showNote = _this$props2.showNote,
|
|
152
145
|
teacherInstructions = _this$props2.teacherInstructions,
|
|
153
146
|
responseAreaInputConfiguration = _this$props2.responseAreaInputConfiguration,
|
|
154
|
-
model = _this$props2.model
|
|
147
|
+
model = _this$props2.model,
|
|
148
|
+
value = _this$props2.value;
|
|
155
149
|
|
|
156
150
|
var _ref = model || {},
|
|
157
151
|
extraCSSRules = _ref.extraCSSRules;
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.js"],"names":["translator","Translator","Main","showCorrectAnswer","props","alwaysShowCorrect","value","maxLengthPerChoice","every","val","i","arr","onChange","maxWait","setState","state","getChangeSession","changeSession","nextProps","language","note","feedback","t","lng","animationsDisabled","classes","mode","displayType","role","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","prompt","rationale","showNote","teacherInstructions","responseAreaInputConfiguration","model","extraCSSRules","displayNote","mainClasses","mainContainer","noBorderColor","teacherInstructionsDiv","rationaleDiv","display","srOnly","collapsible","hidden","visible","toggleShowCorrect","__html","React","Component","PropTypes","bool","object","isRequired","disabled","string","markup","array","func","styles","theme","color","text","backgroundColor","background","inlineDisplay","blockDisplay","marginBottom","spacing","unit","borderColor","position","left","top","width","height","overflow"],"mappings":";;;;;;;;;;;;;;;;;;;;;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A,OAAO,EAAE;AADG,KARW;AAWzBxB,IAAAA,IAAI,EAAE;AACJkD,MAAAA,YAAY,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAAd,GAAqB;AAD/B,KAXmB;AAczB1B,IAAAA,WAAW,EAAE;AACXwB,MAAAA,YAAY,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAAd,GAAqB;AADxB,KAdY;AAiBzB/B,IAAAA,aAAa,EAAE;AACb,aAAO;AACLgC,QAAAA,WAAW,YAAKT,gBAAMC,IAAN,EAAL;AADN;AADM,KAjBU;AAsBzBpB,IAAAA,MAAM,EAAE;AACN6B,MAAAA,QAAQ,EAAE,UADJ;AAENC,MAAAA,IAAI,EAAE,UAFA;AAGNC,MAAAA,GAAG,EAAE,MAHC;AAINC,MAAAA,KAAK,EAAE,KAJD;AAKNC,MAAAA,MAAM,EAAE,KALF;AAMNC,MAAAA,QAAQ,EAAE;AANJ;AAtBiB,GAAZ;AAAA,CAAf;;eAgCe,wBAAWjB,MAAX,EAAmB5D,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport isEmpty from 'lodash/isEmpty';\nimport isEqual from 'lodash/isEqual';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { ConstructedResponse } from '@pie-lib/pie-toolbox/mask-markup';\nimport { color, Collapsible, hasText, PreviewPrompt, UiLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\n\nexport class Main extends React.Component {\n static propTypes = {\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n disabled: PropTypes.bool,\n displayType: PropTypes.string,\n feedback: PropTypes.object,\n language: PropTypes.string,\n markup: PropTypes.string,\n maxLengthPerChoice: PropTypes.array,\n maxLengthPerChoiceEnabled: PropTypes.bool,\n mode: PropTypes.string,\n note: PropTypes.string,\n onChange: PropTypes.func,\n playerSpellCheckEnabled: PropTypes.bool,\n prompt: PropTypes.string,\n rationale: PropTypes.string,\n role: PropTypes.string,\n showNote: PropTypes.bool,\n teacherInstructions: PropTypes.string,\n value: PropTypes.object,\n responseAreaInputConfiguration: PropTypes.object,\n model: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n value: {},\n };\n\n state = {\n showCorrectAnswer: this.props.alwaysShowCorrect || false,\n value: this.props.value,\n };\n\n // if for all responses max length is 1, call onChange for each keystroke\n getChangeSession = (maxLengthPerChoice) =>\n maxLengthPerChoice && maxLengthPerChoice.every((val, i, arr) => val === arr[0] && val === 1)\n ? this.props.onChange\n : debounce(this.props.onChange, 1500, { maxWait: 1500 });\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { maxLengthPerChoice, language } = this.props;\n let { note } = this.props;\n\n if (isEmpty(nextProps.feedback)) {\n this.setState({ showCorrectAnswer: false });\n }\n\n if (nextProps.alwaysShowCorrect) {\n this.setState({ showCorrectAnswer: true });\n }\n\n if (maxLengthPerChoice && !isEqual(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {\n this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);\n }\n\n // check if the note is the default one for prev language and change to the default one for new language\n // this check is necessary in order to diferanciate between default and authour defined note\n // and only change between languages for default ones\n if (\n note &&\n language &&\n language !== nextProps.language &&\n note === translator.t('common:commonCorrectAnswerWithAlternates', { lng: language })\n ) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: nextProps.language });\n }\n }\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n changeSession = this.getChangeSession(this.props.maxLengthPerChoice);\n\n onChange = (value) => {\n this.setState({ value });\n\n this.changeSession(value);\n };\n\n render() {\n const { showCorrectAnswer, value } = this.state;\n const {\n alwaysShowCorrect,\n animationsDisabled,\n classes,\n mode,\n displayType,\n role,\n language,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled,\n prompt,\n rationale,\n showNote,\n teacherInstructions,\n responseAreaInputConfiguration,\n model,\n } = this.props;\n\n const { extraCSSRules } = model || {};\n const displayNote = (showCorrectAnswer || (mode === 'view' && role === 'instructor')) && showNote && note;\n const mainClasses = classNames([\n classes.mainContainer,\n {\n [classes.noBorderColor]: alwaysShowCorrect,\n },\n ]);\n\n const teacherInstructionsDiv = (\n <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />\n );\n\n const rationaleDiv = <PreviewPrompt prompt={rationale} />;\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={mainClasses} style={{ display: `${displayType}` }}>\n {mode === 'gather' && <h2 className={classes.srOnly}>Fill in the Blank Question</h2>}\n\n {teacherInstructions && hasText(teacherInstructions) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? (\n <Collapsible labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}>\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n {prompt && <PreviewPrompt prompt={prompt} />}\n\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={mode === 'evaluate'}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n )}\n\n <ConstructedResponse\n {...this.props}\n onChange={this.onChange}\n showCorrectAnswer={showCorrectAnswer}\n value={value}\n maxLength={maxLengthPerChoice}\n adjustedLimit={maxLengthPerChoiceEnabled}\n spellCheck={playerSpellCheckEnabled}\n pluginProps={responseAreaInputConfiguration}\n />\n\n {displayNote && <div className={classNames(classes.note, 'note')} dangerouslySetInnerHTML={{ __html: note }} />}\n\n {rationale && hasText(rationale) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>{rationaleDiv}</Collapsible>\n ) : (\n rationaleDiv\n )}\n </div>\n )}\n </UiLayout>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n inlineDisplay: {\n display: 'inline-block',\n },\n blockDisplay: {\n display: 'block',\n },\n note: {\n marginBottom: theme.spacing.unit * 2,\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n noBorderColor: {\n '& *': {\n borderColor: `${color.text()} !important`,\n },\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
|
|
1
|
+
{"version":3,"sources":["../src/main.js"],"names":["translator","Translator","Main","showCorrectAnswer","props","alwaysShowCorrect","maxLengthPerChoice","every","val","i","arr","onChange","maxWait","setState","state","getChangeSession","value","changeSession","nextProps","language","note","feedback","t","lng","animationsDisabled","classes","mode","displayType","role","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","prompt","rationale","showNote","teacherInstructions","responseAreaInputConfiguration","model","extraCSSRules","displayNote","mainClasses","mainContainer","noBorderColor","teacherInstructionsDiv","rationaleDiv","display","srOnly","collapsible","hidden","visible","toggleShowCorrect","__html","React","Component","PropTypes","bool","object","isRequired","disabled","string","markup","array","func","styles","theme","color","text","backgroundColor","background","inlineDisplay","blockDisplay","marginBottom","spacing","unit","borderColor","position","left","top","width","height","overflow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;IAEaE,I;;;;;;;;;;;;;;;8FA8BH;AACNC,MAAAA,iBAAiB,EAAE,MAAKC,KAAL,CAAWC,iBAAX,IAAgC;AAD7C,K;yGAKW,UAACC,kBAAD;AAAA,aACjBA,kBAAkB,IAAIA,kBAAkB,CAACC,K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,IAAI,EAAE,UAFA;AAGNC,MAAAA,GAAG,EAAE,MAHC;AAINC,MAAAA,KAAK,EAAE,KAJD;AAKNC,MAAAA,MAAM,EAAE,KALF;AAMNC,MAAAA,QAAQ,EAAE;AANJ;AAtBiB,GAAZ;AAAA,CAAf;;eAgCe,wBAAWjB,MAAX,EAAmB5D,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport isEmpty from 'lodash/isEmpty';\nimport isEqual from 'lodash/isEqual';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { ConstructedResponse } from '@pie-lib/pie-toolbox/mask-markup';\nimport { color, Collapsible, hasText, PreviewPrompt, UiLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\n\nexport class Main extends React.Component {\n static propTypes = {\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n disabled: PropTypes.bool,\n displayType: PropTypes.string,\n feedback: PropTypes.object,\n language: PropTypes.string,\n markup: PropTypes.string,\n maxLengthPerChoice: PropTypes.array,\n maxLengthPerChoiceEnabled: PropTypes.bool,\n mode: PropTypes.string,\n note: PropTypes.string,\n onChange: PropTypes.func,\n playerSpellCheckEnabled: PropTypes.bool,\n prompt: PropTypes.string,\n rationale: PropTypes.string,\n role: PropTypes.string,\n showNote: PropTypes.bool,\n teacherInstructions: PropTypes.string,\n value: PropTypes.object,\n responseAreaInputConfiguration: PropTypes.object,\n model: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n value: {},\n };\n\n state = {\n showCorrectAnswer: this.props.alwaysShowCorrect || false,\n };\n\n // if for all responses max length is 1, call onChange for each keystroke\n getChangeSession = (maxLengthPerChoice) =>\n maxLengthPerChoice && maxLengthPerChoice.every((val, i, arr) => val === arr[0] && val === 1)\n ? this.props.onChange\n : debounce(this.props.onChange, 1500, { maxWait: 1500 });\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { maxLengthPerChoice, language } = this.props;\n let { note } = this.props;\n\n if (isEmpty(nextProps.feedback)) {\n this.setState({ showCorrectAnswer: false });\n }\n\n if (nextProps.alwaysShowCorrect) {\n this.setState({ showCorrectAnswer: true });\n }\n\n if (maxLengthPerChoice && !isEqual(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {\n this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);\n }\n\n // check if the note is the default one for prev language and change to the default one for new language\n // this check is necessary in order to diferanciate between default and authour defined note\n // and only change between languages for default ones\n if (\n note &&\n language &&\n language !== nextProps.language &&\n note === translator.t('common:commonCorrectAnswerWithAlternates', { lng: language })\n ) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: nextProps.language });\n }\n }\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n changeSession = this.getChangeSession(this.props.maxLengthPerChoice);\n\n onChange = (value) => {\n this.changeSession(value);\n };\n\n render() {\n const { showCorrectAnswer } = this.state;\n const {\n alwaysShowCorrect,\n animationsDisabled,\n classes,\n mode,\n displayType,\n role,\n language,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled,\n prompt,\n rationale,\n showNote,\n teacherInstructions,\n responseAreaInputConfiguration,\n model,\n value,\n } = this.props;\n\n const { extraCSSRules } = model || {};\n const displayNote = (showCorrectAnswer || (mode === 'view' && role === 'instructor')) && showNote && note;\n const mainClasses = classNames([\n classes.mainContainer,\n {\n [classes.noBorderColor]: alwaysShowCorrect,\n },\n ]);\n\n const teacherInstructionsDiv = (\n <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />\n );\n\n const rationaleDiv = <PreviewPrompt prompt={rationale} />;\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={mainClasses} style={{ display: `${displayType}` }}>\n {mode === 'gather' && <h2 className={classes.srOnly}>Fill in the Blank Question</h2>}\n\n {teacherInstructions && hasText(teacherInstructions) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? (\n <Collapsible labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}>\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n {prompt && <PreviewPrompt prompt={prompt} />}\n\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={mode === 'evaluate'}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={language}\n />\n )}\n\n <ConstructedResponse\n {...this.props}\n onChange={this.onChange}\n showCorrectAnswer={showCorrectAnswer}\n value={value}\n maxLength={maxLengthPerChoice}\n adjustedLimit={maxLengthPerChoiceEnabled}\n spellCheck={playerSpellCheckEnabled}\n pluginProps={responseAreaInputConfiguration}\n />\n\n {displayNote && <div className={classNames(classes.note, 'note')} dangerouslySetInnerHTML={{ __html: note }} />}\n\n {rationale && hasText(rationale) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>{rationaleDiv}</Collapsible>\n ) : (\n rationaleDiv\n )}\n </div>\n )}\n </UiLayout>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n inlineDisplay: {\n display: 'inline-block',\n },\n blockDisplay: {\n display: 'block',\n },\n note: {\n marginBottom: theme.spacing.unit * 2,\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n noBorderColor: {\n '& *': {\n borderColor: `${color.text()} !important`,\n },\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
|
package/module/configure.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.3.4/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@5.10.4/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;
|
|
@@ -8852,7 +8852,7 @@ var _interopRequireDefault$G = interopRequireDefault.exports;
|
|
|
8852
8852
|
Object.defineProperty(markupUtils, "__esModule", {
|
|
8853
8853
|
value: true
|
|
8854
8854
|
});
|
|
8855
|
-
markupUtils.stripHtmlTags = markupUtils.removeUnwantedCharacters = markupUtils.processMarkup = markupUtils.getAdjustedLength = markupUtils.createSlateMarkup = void 0;
|
|
8855
|
+
markupUtils.stripHtmlTags = markupUtils.removeUnwantedCharacters = markupUtils.processMarkup = markupUtils.getAdjustedLength = markupUtils.decodeHTML = markupUtils.createSlateMarkup = void 0;
|
|
8856
8856
|
var _escape = _interopRequireDefault$G(require$$1$6);
|
|
8857
8857
|
var tSymbols = 'imes|riangle|an|heta|herefore';
|
|
8858
8858
|
var nSymbols = 'throot|parallel|cong|approx|eq|e|sim';
|
|
@@ -8909,6 +8909,11 @@ var stripHtmlTags = function stripHtmlTags(markup) {
|
|
|
8909
8909
|
return markup.replace(/<\/?[^>]+(>|$)/g, "");
|
|
8910
8910
|
};
|
|
8911
8911
|
markupUtils.stripHtmlTags = stripHtmlTags;
|
|
8912
|
+
var decodeHTML = function decodeHTML(html) {
|
|
8913
|
+
var doc = new DOMParser().parseFromString(html, 'text/html');
|
|
8914
|
+
return doc.body.textContent || '';
|
|
8915
|
+
};
|
|
8916
|
+
markupUtils.decodeHTML = decodeHTML;
|
|
8912
8917
|
const require$$9$d = _dll_react;
|
|
8913
8918
|
const require$$10$e = _dll_prop_types;
|
|
8914
8919
|
const require$$12$9 = _dll_pie_lib__pie_toolbox_editable_html;
|
|
@@ -8995,7 +9000,7 @@ const require$$12$9 = _dll_pie_lib__pie_toolbox_editable_html;
|
|
|
8995
9000
|
});
|
|
8996
9001
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDone", function (markup) {
|
|
8997
9002
|
var _this$props = _this.props, node = _this$props.node, value = _this$props.value, onToolbarDone = _this$props.onToolbarDone, onChangeResponse = _this$props.onChangeResponse;
|
|
8998
|
-
var sanitizedMarkup = (0, _markupUtils.stripHtmlTags)(markup);
|
|
9003
|
+
var sanitizedMarkup = (0, _markupUtils.decodeHTML)((0, _markupUtils.stripHtmlTags)(markup));
|
|
8999
9004
|
_this.setState({
|
|
9000
9005
|
markup: sanitizedMarkup
|
|
9001
9006
|
});
|
|
@@ -15951,7 +15956,7 @@ const require$$24 = _dll_pie_lib__pie_toolbox_editable_html;
|
|
|
15951
15956
|
return _react["default"].createElement(_MenuItem["default"], {
|
|
15952
15957
|
key: index,
|
|
15953
15958
|
value: c === null || c === void 0 ? void 0 : c.value
|
|
15954
|
-
}, c === null || c === void 0 ? void 0 : c.label);
|
|
15959
|
+
}, (0, _markupUtils.decodeHTML)(c === null || c === void 0 ? void 0 : c.label));
|
|
15955
15960
|
})), choices && choices.length > 0 && _react["default"].createElement("div", {
|
|
15956
15961
|
className: classes.rightContainer
|
|
15957
15962
|
}, maxLength && showMaxLength && _react["default"].createElement(_TextField["default"], {
|
package/module/controller.js
CHANGED
|
@@ -21418,16 +21418,20 @@ persistence.compact = compact;
|
|
|
21418
21418
|
|
|
21419
21419
|
var getShuffledChoices = function getShuffledChoices(choices, session, updateSession, choiceKey) {
|
|
21420
21420
|
return new Promise(function (resolve) {
|
|
21421
|
+
var _session$data;
|
|
21422
|
+
|
|
21421
21423
|
log('updateSession type: ', (0, _typeof2["default"])(updateSession));
|
|
21422
21424
|
log('session: ', session);
|
|
21423
|
-
var currentShuffled = compact((session ||
|
|
21425
|
+
var currentShuffled = compact((session === null || session === void 0 ? void 0 : (_session$data = session.data) === null || _session$data === void 0 ? void 0 : _session$data.shuffledValues) || (session === null || session === void 0 ? void 0 : session.shuffledValues) || []);
|
|
21424
21426
|
|
|
21425
21427
|
if (!session) {
|
|
21426
21428
|
// eslint-disable-next-line quotes
|
|
21427
21429
|
warn("unable to save shuffled choices because there's no session.");
|
|
21428
21430
|
resolve(undefined);
|
|
21429
21431
|
} else if (!(0, _isEmpty["default"])(currentShuffled)) {
|
|
21430
|
-
|
|
21432
|
+
var _session$data2;
|
|
21433
|
+
|
|
21434
|
+
debug('use shuffledValues to sort the choices...', (_session$data2 = session.data) === null || _session$data2 === void 0 ? void 0 : _session$data2.shuffledValues);
|
|
21431
21435
|
resolve(compact(currentShuffled.map(function (v) {
|
|
21432
21436
|
return choices.find(function (c) {
|
|
21433
21437
|
return c[choiceKey] === v;
|
|
@@ -24822,7 +24826,7 @@ function model(question, session, env) {
|
|
|
24822
24826
|
}
|
|
24823
24827
|
|
|
24824
24828
|
const prepareVal = (html) => {
|
|
24825
|
-
return getInnerText(html).trim();
|
|
24829
|
+
return decodeHTML(getInnerText(html).trim());
|
|
24826
24830
|
};
|
|
24827
24831
|
|
|
24828
24832
|
const getScore = (config, session) => {
|
|
@@ -24904,6 +24908,11 @@ const getInnerText = (html) => {
|
|
|
24904
24908
|
}
|
|
24905
24909
|
};
|
|
24906
24910
|
|
|
24911
|
+
const decodeHTML = (html) => {
|
|
24912
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
24913
|
+
return doc.body.textContent || '';
|
|
24914
|
+
};
|
|
24915
|
+
|
|
24907
24916
|
// remove all html tags except img and iframe
|
|
24908
24917
|
const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
24909
24918
|
|
package/module/element.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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@3.3.
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.
|
|
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@3.3.4/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@5.10.4/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) {
|
|
@@ -143496,7 +143496,7 @@ const require$$4$1d = _dll_react;
|
|
|
143496
143496
|
},
|
|
143497
143497
|
ica: {
|
|
143498
143498
|
backgroundColor: _renderUi.color.background(),
|
|
143499
|
-
border: ("1px solid ").concat(_renderUi.color.
|
|
143499
|
+
border: ("1px solid ").concat(_renderUi.color.borderDark()),
|
|
143500
143500
|
display: 'flex',
|
|
143501
143501
|
alignItems: 'center',
|
|
143502
143502
|
justifyContent: 'center',
|
|
@@ -184512,8 +184512,7 @@ class Main extends React$1.Component {
|
|
|
184512
184512
|
}
|
|
184513
184513
|
__init() {
|
|
184514
184514
|
this.state = {
|
|
184515
|
-
showCorrectAnswer: this.props.alwaysShowCorrect || false
|
|
184516
|
-
value: this.props.value
|
|
184515
|
+
showCorrectAnswer: this.props.alwaysShowCorrect || false
|
|
184517
184516
|
};
|
|
184518
184517
|
}
|
|
184519
184518
|
__init2() {
|
|
@@ -184557,15 +184556,12 @@ class Main extends React$1.Component {
|
|
|
184557
184556
|
}
|
|
184558
184557
|
__init5() {
|
|
184559
184558
|
this.onChange = value => {
|
|
184560
|
-
this.setState({
|
|
184561
|
-
value
|
|
184562
|
-
});
|
|
184563
184559
|
this.changeSession(value);
|
|
184564
184560
|
};
|
|
184565
184561
|
}
|
|
184566
184562
|
render() {
|
|
184567
|
-
const {showCorrectAnswer
|
|
184568
|
-
const {alwaysShowCorrect, animationsDisabled, classes, mode, displayType, role, language, maxLengthPerChoice, maxLengthPerChoiceEnabled, note, playerSpellCheckEnabled, prompt, rationale, showNote, teacherInstructions, responseAreaInputConfiguration, model} = this.props;
|
|
184563
|
+
const {showCorrectAnswer} = this.state;
|
|
184564
|
+
const {alwaysShowCorrect, animationsDisabled, classes, mode, displayType, role, language, maxLengthPerChoice, maxLengthPerChoiceEnabled, note, playerSpellCheckEnabled, prompt, rationale, showNote, teacherInstructions, responseAreaInputConfiguration, model, value} = this.props;
|
|
184569
184565
|
const {extraCSSRules} = model || ({});
|
|
184570
184566
|
const displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;
|
|
184571
184567
|
const mainClasses = classNames([classes.mainContainer, {
|
|
@@ -184577,7 +184573,7 @@ class Main extends React$1.Component {
|
|
|
184577
184573
|
__self: this,
|
|
184578
184574
|
__source: {
|
|
184579
184575
|
fileName: _jsxFileName,
|
|
184580
|
-
lineNumber:
|
|
184576
|
+
lineNumber: 127
|
|
184581
184577
|
}
|
|
184582
184578
|
});
|
|
184583
184579
|
const rationaleDiv = React$1.createElement(PreviewPrompt, {
|
|
@@ -184585,7 +184581,7 @@ class Main extends React$1.Component {
|
|
|
184585
184581
|
__self: this,
|
|
184586
184582
|
__source: {
|
|
184587
184583
|
fileName: _jsxFileName,
|
|
184588
|
-
lineNumber:
|
|
184584
|
+
lineNumber: 130
|
|
184589
184585
|
}
|
|
184590
184586
|
});
|
|
184591
184587
|
return React$1.createElement(UiLayout, {
|
|
@@ -184597,21 +184593,21 @@ class Main extends React$1.Component {
|
|
|
184597
184593
|
__self: this,
|
|
184598
184594
|
__source: {
|
|
184599
184595
|
fileName: _jsxFileName,
|
|
184600
|
-
lineNumber:
|
|
184596
|
+
lineNumber: 133
|
|
184601
184597
|
}
|
|
184602
184598
|
}, mode === 'gather' && React$1.createElement('h2', {
|
|
184603
184599
|
className: classes.srOnly,
|
|
184604
184600
|
__self: this,
|
|
184605
184601
|
__source: {
|
|
184606
184602
|
fileName: _jsxFileName,
|
|
184607
|
-
lineNumber:
|
|
184603
|
+
lineNumber: 134
|
|
184608
184604
|
}
|
|
184609
184605
|
}, "Fill in the Blank Question"), teacherInstructions && hasText(teacherInstructions) && React$1.createElement('div', {
|
|
184610
184606
|
className: classes.collapsible,
|
|
184611
184607
|
__self: this,
|
|
184612
184608
|
__source: {
|
|
184613
184609
|
fileName: _jsxFileName,
|
|
184614
|
-
lineNumber:
|
|
184610
|
+
lineNumber: 137
|
|
184615
184611
|
}
|
|
184616
184612
|
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
184617
184613
|
labels: {
|
|
@@ -184621,14 +184617,14 @@ class Main extends React$1.Component {
|
|
|
184621
184617
|
__self: this,
|
|
184622
184618
|
__source: {
|
|
184623
184619
|
fileName: _jsxFileName,
|
|
184624
|
-
lineNumber:
|
|
184620
|
+
lineNumber: 139
|
|
184625
184621
|
}
|
|
184626
184622
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), prompt && React$1.createElement(PreviewPrompt, {
|
|
184627
184623
|
prompt: prompt,
|
|
184628
184624
|
__self: this,
|
|
184629
184625
|
__source: {
|
|
184630
184626
|
fileName: _jsxFileName,
|
|
184631
|
-
lineNumber:
|
|
184627
|
+
lineNumber: 148
|
|
184632
184628
|
}
|
|
184633
184629
|
}), !alwaysShowCorrect && React$1.createElement(CorrectAnswerToggle, {
|
|
184634
184630
|
show: mode === 'evaluate',
|
|
@@ -184638,7 +184634,7 @@ class Main extends React$1.Component {
|
|
|
184638
184634
|
__self: this,
|
|
184639
184635
|
__source: {
|
|
184640
184636
|
fileName: _jsxFileName,
|
|
184641
|
-
lineNumber:
|
|
184637
|
+
lineNumber: 151
|
|
184642
184638
|
}
|
|
184643
184639
|
}), React$1.createElement(maskMarkup$1.ConstructedResponse, {
|
|
184644
184640
|
...this.props,
|
|
@@ -184652,7 +184648,7 @@ class Main extends React$1.Component {
|
|
|
184652
184648
|
__self: this,
|
|
184653
184649
|
__source: {
|
|
184654
184650
|
fileName: _jsxFileName,
|
|
184655
|
-
lineNumber:
|
|
184651
|
+
lineNumber: 159
|
|
184656
184652
|
}
|
|
184657
184653
|
}), displayNote && React$1.createElement('div', {
|
|
184658
184654
|
className: classNames(classes.note, 'note'),
|
|
@@ -184662,14 +184658,14 @@ class Main extends React$1.Component {
|
|
|
184662
184658
|
__self: this,
|
|
184663
184659
|
__source: {
|
|
184664
184660
|
fileName: _jsxFileName,
|
|
184665
|
-
lineNumber:
|
|
184661
|
+
lineNumber: 170
|
|
184666
184662
|
}
|
|
184667
184663
|
}), rationale && hasText(rationale) && React$1.createElement('div', {
|
|
184668
184664
|
className: classes.collapsible,
|
|
184669
184665
|
__self: this,
|
|
184670
184666
|
__source: {
|
|
184671
184667
|
fileName: _jsxFileName,
|
|
184672
|
-
lineNumber:
|
|
184668
|
+
lineNumber: 173
|
|
184673
184669
|
}
|
|
184674
184670
|
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
184675
184671
|
labels: {
|
|
@@ -184679,7 +184675,7 @@ class Main extends React$1.Component {
|
|
|
184679
184675
|
__self: this,
|
|
184680
184676
|
__source: {
|
|
184681
184677
|
fileName: _jsxFileName,
|
|
184682
|
-
lineNumber:
|
|
184678
|
+
lineNumber: 175
|
|
184683
184679
|
}
|
|
184684
184680
|
}, rationaleDiv) : rationaleDiv));
|
|
184685
184681
|
}
|
package/module/index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<!doctype html>
|
|
3
3
|
<html>
|
|
4
4
|
<head>
|
|
5
|
-
<title>@pie-element/explicit-constructed-response@7.3.
|
|
5
|
+
<title>@pie-element/explicit-constructed-response@7.3.5</title>
|
|
6
6
|
<script
|
|
7
7
|
type="module"
|
|
8
8
|
src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
package/module/manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.5",
|
|
4
4
|
"modules": [
|
|
5
5
|
{
|
|
6
6
|
"name": "@pie-lib/pie-toolbox-math-rendering-module",
|
|
7
|
-
"version": "3.3.
|
|
7
|
+
"version": "3.3.4"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"name": "@pie-lib/pie-toolbox-module",
|
|
11
|
-
"version": "5.10.
|
|
11
|
+
"version": "5.10.4"
|
|
12
12
|
}
|
|
13
13
|
]
|
|
14
14
|
}
|
package/module/print.html
CHANGED
package/module/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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@3.3.
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@5.10.
|
|
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@3.3.4/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@5.10.4/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) {
|
|
@@ -143459,7 +143459,7 @@ const require$$4$1d = _dll_react;
|
|
|
143459
143459
|
},
|
|
143460
143460
|
ica: {
|
|
143461
143461
|
backgroundColor: _renderUi.color.background(),
|
|
143462
|
-
border: ("1px solid ").concat(_renderUi.color.
|
|
143462
|
+
border: ("1px solid ").concat(_renderUi.color.borderDark()),
|
|
143463
143463
|
display: 'flex',
|
|
143464
143464
|
alignItems: 'center',
|
|
143465
143465
|
justifyContent: 'center',
|
|
@@ -184475,8 +184475,7 @@ class Main extends React$1.Component {
|
|
|
184475
184475
|
}
|
|
184476
184476
|
__init() {
|
|
184477
184477
|
this.state = {
|
|
184478
|
-
showCorrectAnswer: this.props.alwaysShowCorrect || false
|
|
184479
|
-
value: this.props.value
|
|
184478
|
+
showCorrectAnswer: this.props.alwaysShowCorrect || false
|
|
184480
184479
|
};
|
|
184481
184480
|
}
|
|
184482
184481
|
__init2() {
|
|
@@ -184520,15 +184519,12 @@ class Main extends React$1.Component {
|
|
|
184520
184519
|
}
|
|
184521
184520
|
__init5() {
|
|
184522
184521
|
this.onChange = value => {
|
|
184523
|
-
this.setState({
|
|
184524
|
-
value
|
|
184525
|
-
});
|
|
184526
184522
|
this.changeSession(value);
|
|
184527
184523
|
};
|
|
184528
184524
|
}
|
|
184529
184525
|
render() {
|
|
184530
|
-
const {showCorrectAnswer
|
|
184531
|
-
const {alwaysShowCorrect, animationsDisabled, classes, mode, displayType, role, language, maxLengthPerChoice, maxLengthPerChoiceEnabled, note, playerSpellCheckEnabled, prompt, rationale, showNote, teacherInstructions, responseAreaInputConfiguration, model} = this.props;
|
|
184526
|
+
const {showCorrectAnswer} = this.state;
|
|
184527
|
+
const {alwaysShowCorrect, animationsDisabled, classes, mode, displayType, role, language, maxLengthPerChoice, maxLengthPerChoiceEnabled, note, playerSpellCheckEnabled, prompt, rationale, showNote, teacherInstructions, responseAreaInputConfiguration, model, value} = this.props;
|
|
184532
184528
|
const {extraCSSRules} = model || ({});
|
|
184533
184529
|
const displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;
|
|
184534
184530
|
const mainClasses = classNames([classes.mainContainer, {
|
|
@@ -184540,7 +184536,7 @@ class Main extends React$1.Component {
|
|
|
184540
184536
|
__self: this,
|
|
184541
184537
|
__source: {
|
|
184542
184538
|
fileName: _jsxFileName,
|
|
184543
|
-
lineNumber:
|
|
184539
|
+
lineNumber: 127
|
|
184544
184540
|
}
|
|
184545
184541
|
});
|
|
184546
184542
|
const rationaleDiv = React$1.createElement(PreviewPrompt, {
|
|
@@ -184548,7 +184544,7 @@ class Main extends React$1.Component {
|
|
|
184548
184544
|
__self: this,
|
|
184549
184545
|
__source: {
|
|
184550
184546
|
fileName: _jsxFileName,
|
|
184551
|
-
lineNumber:
|
|
184547
|
+
lineNumber: 130
|
|
184552
184548
|
}
|
|
184553
184549
|
});
|
|
184554
184550
|
return React$1.createElement(UiLayout, {
|
|
@@ -184560,21 +184556,21 @@ class Main extends React$1.Component {
|
|
|
184560
184556
|
__self: this,
|
|
184561
184557
|
__source: {
|
|
184562
184558
|
fileName: _jsxFileName,
|
|
184563
|
-
lineNumber:
|
|
184559
|
+
lineNumber: 133
|
|
184564
184560
|
}
|
|
184565
184561
|
}, mode === 'gather' && React$1.createElement('h2', {
|
|
184566
184562
|
className: classes.srOnly,
|
|
184567
184563
|
__self: this,
|
|
184568
184564
|
__source: {
|
|
184569
184565
|
fileName: _jsxFileName,
|
|
184570
|
-
lineNumber:
|
|
184566
|
+
lineNumber: 134
|
|
184571
184567
|
}
|
|
184572
184568
|
}, "Fill in the Blank Question"), teacherInstructions && hasText(teacherInstructions) && React$1.createElement('div', {
|
|
184573
184569
|
className: classes.collapsible,
|
|
184574
184570
|
__self: this,
|
|
184575
184571
|
__source: {
|
|
184576
184572
|
fileName: _jsxFileName,
|
|
184577
|
-
lineNumber:
|
|
184573
|
+
lineNumber: 137
|
|
184578
184574
|
}
|
|
184579
184575
|
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
184580
184576
|
labels: {
|
|
@@ -184584,14 +184580,14 @@ class Main extends React$1.Component {
|
|
|
184584
184580
|
__self: this,
|
|
184585
184581
|
__source: {
|
|
184586
184582
|
fileName: _jsxFileName,
|
|
184587
|
-
lineNumber:
|
|
184583
|
+
lineNumber: 139
|
|
184588
184584
|
}
|
|
184589
184585
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), prompt && React$1.createElement(PreviewPrompt, {
|
|
184590
184586
|
prompt: prompt,
|
|
184591
184587
|
__self: this,
|
|
184592
184588
|
__source: {
|
|
184593
184589
|
fileName: _jsxFileName,
|
|
184594
|
-
lineNumber:
|
|
184590
|
+
lineNumber: 148
|
|
184595
184591
|
}
|
|
184596
184592
|
}), !alwaysShowCorrect && React$1.createElement(CorrectAnswerToggle, {
|
|
184597
184593
|
show: mode === 'evaluate',
|
|
@@ -184601,7 +184597,7 @@ class Main extends React$1.Component {
|
|
|
184601
184597
|
__self: this,
|
|
184602
184598
|
__source: {
|
|
184603
184599
|
fileName: _jsxFileName,
|
|
184604
|
-
lineNumber:
|
|
184600
|
+
lineNumber: 151
|
|
184605
184601
|
}
|
|
184606
184602
|
}), React$1.createElement(maskMarkup$1.ConstructedResponse, {
|
|
184607
184603
|
...this.props,
|
|
@@ -184615,7 +184611,7 @@ class Main extends React$1.Component {
|
|
|
184615
184611
|
__self: this,
|
|
184616
184612
|
__source: {
|
|
184617
184613
|
fileName: _jsxFileName,
|
|
184618
|
-
lineNumber:
|
|
184614
|
+
lineNumber: 159
|
|
184619
184615
|
}
|
|
184620
184616
|
}), displayNote && React$1.createElement('div', {
|
|
184621
184617
|
className: classNames(classes.note, 'note'),
|
|
@@ -184625,14 +184621,14 @@ class Main extends React$1.Component {
|
|
|
184625
184621
|
__self: this,
|
|
184626
184622
|
__source: {
|
|
184627
184623
|
fileName: _jsxFileName,
|
|
184628
|
-
lineNumber:
|
|
184624
|
+
lineNumber: 170
|
|
184629
184625
|
}
|
|
184630
184626
|
}), rationale && hasText(rationale) && React$1.createElement('div', {
|
|
184631
184627
|
className: classes.collapsible,
|
|
184632
184628
|
__self: this,
|
|
184633
184629
|
__source: {
|
|
184634
184630
|
fileName: _jsxFileName,
|
|
184635
|
-
lineNumber:
|
|
184631
|
+
lineNumber: 173
|
|
184636
184632
|
}
|
|
184637
184633
|
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
184638
184634
|
labels: {
|
|
@@ -184642,7 +184638,7 @@ class Main extends React$1.Component {
|
|
|
184642
184638
|
__self: this,
|
|
184643
184639
|
__source: {
|
|
184644
184640
|
fileName: _jsxFileName,
|
|
184645
|
-
lineNumber:
|
|
184641
|
+
lineNumber: 175
|
|
184646
184642
|
}
|
|
184647
184643
|
}, rationaleDiv) : rationaleDiv));
|
|
184648
184644
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "7.3.
|
|
7
|
+
"version": "7.3.6-next.0+8c6e2183d",
|
|
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.9.
|
|
15
|
+
"@pie-lib/pie-toolbox": "2.9.5",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"lodash": "^4.17.10",
|
|
18
18
|
"prop-types": "^15.6.1",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "8c6e2183d3f8e9cd80c59ea408629a79ad31b46c",
|
|
25
25
|
"main": "lib/index.js",
|
|
26
26
|
"module": "src/index.js",
|
|
27
27
|
"exports": {
|