@pie-element/explicit-constructed-response 6.12.6 → 6.12.7

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/lib/main.js CHANGED
@@ -27,11 +27,7 @@ var _react = _interopRequireDefault(require("react"));
27
27
 
28
28
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
29
 
30
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
31
-
32
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
33
-
34
- var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
30
+ var _lodash = require("lodash");
35
31
 
36
32
  var _correctAnswerToggle = require("@pie-lib/pie-toolbox/correct-answer-toggle");
37
33
 
@@ -73,7 +69,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
73
69
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getChangeSession", function (maxLengthPerChoice) {
74
70
  return maxLengthPerChoice && maxLengthPerChoice.every(function (val, i, arr) {
75
71
  return val === arr[0] && val === 1;
76
- }) ? _this.props.onChange : (0, _debounce["default"])(_this.props.onChange, 1500, {
72
+ }) ? _this.props.onChange : (0, _lodash.debounce)(_this.props.onChange, 1500, {
77
73
  maxWait: 1500
78
74
  });
79
75
  });
@@ -101,7 +97,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
101
97
  language = _this$props.language;
102
98
  var note = this.props.note;
103
99
 
104
- if ((0, _isEmpty["default"])(nextProps.feedback)) {
100
+ if ((0, _lodash.isEmpty)(nextProps.feedback)) {
105
101
  this.setState({
106
102
  showCorrectAnswer: false
107
103
  });
@@ -113,7 +109,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
113
109
  });
114
110
  }
115
111
 
116
- if (maxLengthPerChoice && !(0, _isEqual["default"])(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {
112
+ if (maxLengthPerChoice && !(0, _lodash.isEqual)(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {
117
113
  this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);
118
114
  } // check if the note is the default one for prev language and change to the default one for new language
119
115
  // this check is necessary in order to diferanciate between default and authour defined note
@@ -135,25 +131,21 @@ var Main = /*#__PURE__*/function (_React$Component) {
135
131
  showCorrectAnswer = _this$state.showCorrectAnswer,
136
132
  value = _this$state.value;
137
133
  var _this$props2 = this.props,
134
+ alwaysShowCorrect = _this$props2.alwaysShowCorrect,
135
+ animationsDisabled = _this$props2.animationsDisabled,
138
136
  classes = _this$props2.classes,
139
137
  mode = _this$props2.mode,
140
- prompt = _this$props2.prompt,
141
- rationale = _this$props2.rationale,
142
- teacherInstructions = _this$props2.teacherInstructions,
143
- note = _this$props2.note,
144
- showNote = _this$props2.showNote,
145
- env = _this$props2.env,
146
- animationsDisabled = _this$props2.animationsDisabled,
147
- alwaysShowCorrect = _this$props2.alwaysShowCorrect,
138
+ displayType = _this$props2.displayType,
139
+ role = _this$props2.role,
140
+ language = _this$props2.language,
148
141
  maxLengthPerChoice = _this$props2.maxLengthPerChoice,
149
142
  maxLengthPerChoiceEnabled = _this$props2.maxLengthPerChoiceEnabled,
150
- displayType = _this$props2.displayType,
143
+ note = _this$props2.note,
151
144
  playerSpellCheckEnabled = _this$props2.playerSpellCheckEnabled,
152
- language = _this$props2.language;
153
-
154
- var _ref = env || {},
155
- role = _ref.role;
156
-
145
+ prompt = _this$props2.prompt,
146
+ rationale = _this$props2.rationale,
147
+ showNote = _this$props2.showNote,
148
+ teacherInstructions = _this$props2.teacherInstructions;
157
149
  var displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;
158
150
  var mainClasses = (0, _classnames["default"])([classes.mainContainer, (0, _defineProperty2["default"])({}, classes.noBorderColor, alwaysShowCorrect)]);
159
151
 
@@ -214,26 +206,26 @@ var Main = /*#__PURE__*/function (_React$Component) {
214
206
 
215
207
  exports.Main = Main;
216
208
  (0, _defineProperty2["default"])(Main, "propTypes", {
209
+ alwaysShowCorrect: _propTypes["default"].bool,
210
+ animationsDisabled: _propTypes["default"].bool,
217
211
  classes: _propTypes["default"].object.isRequired,
218
- prompt: _propTypes["default"].string,
219
- note: _propTypes["default"].string,
220
- showNote: _propTypes["default"].bool,
221
- env: _propTypes["default"].object,
222
- rationale: _propTypes["default"].string,
223
212
  disabled: _propTypes["default"].bool,
224
213
  displayType: _propTypes["default"].string,
225
- markup: _propTypes["default"].string,
226
- mode: _propTypes["default"].string,
227
- teacherInstructions: _propTypes["default"].string,
228
- value: _propTypes["default"].object,
229
214
  feedback: _propTypes["default"].object,
230
- onChange: _propTypes["default"].func,
231
- alwaysShowCorrect: _propTypes["default"].bool,
232
- animationsDisabled: _propTypes["default"].bool,
215
+ language: _propTypes["default"].string,
216
+ markup: _propTypes["default"].string,
233
217
  maxLengthPerChoice: _propTypes["default"].array,
234
218
  maxLengthPerChoiceEnabled: _propTypes["default"].bool,
219
+ mode: _propTypes["default"].string,
220
+ note: _propTypes["default"].string,
221
+ onChange: _propTypes["default"].func,
235
222
  playerSpellCheckEnabled: _propTypes["default"].bool,
236
- language: _propTypes["default"].string
223
+ prompt: _propTypes["default"].string,
224
+ rationale: _propTypes["default"].string,
225
+ role: _propTypes["default"].string,
226
+ showNote: _propTypes["default"].bool,
227
+ teacherInstructions: _propTypes["default"].string,
228
+ value: _propTypes["default"].object
237
229
  });
238
230
  (0, _defineProperty2["default"])(Main, "defaultProps", {
239
231
  value: {}
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","classes","mode","prompt","rationale","teacherInstructions","showNote","env","animationsDisabled","maxLengthPerChoiceEnabled","displayType","playerSpellCheckEnabled","role","displayNote","mainClasses","mainContainer","noBorderColor","teacherInstructionsDiv","rationaleDiv","display","srOnly","collapsible","hidden","visible","toggleShowCorrect","__html","React","Component","PropTypes","object","isRequired","string","bool","disabled","markup","func","array","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;;;;;;;;;;;;;;;8FA4BH;AACNC,MAAAA,iBAAiB,EAAE,MAAKC,KAAL,CAAWC,iBAAX,IAAgC,KAD7C;AAENC,MAAAA,KAAK,EAAE,MAAKF,KAAL,CAAWE;AAFZ,K;yGAMW,UAACC,kBAAD;AAAA,aACjBA,kBAAkB,IAAIA,kBAAkB,CAACC,KAAnB,CAAyB,UAACC,GAAD,EAAMC,CAAN,EAASC,GAAT;AAAA,eAAiBF,GAAG,KAAKE,GAAG,CAAC,CAAD,CAAX,IAAkBF,GAAG,KAAK,CAA3C;AAAA,OAAzB,CAAtB,GACI,MAAKL,KAAL,CAAWQ,QADf,GAEI,0BAAS,MAAKR,KAAL,CAAWQ,QAApB,EAA8B,IAA9B,EAAoC;AAAEC,QAAAA,OAAO,EAAE;AAAX,OAApC,CAHa;AAAA,K;0GA8BC,YAAM;AACxB,YAAKC,QAAL,CAAc;AAAEX,QAAAA,iBAAiB,EAAE,CAAC,MAAKY,KAAL,CAAWZ;AAAjC,OAAd;AACD,K;sGAEe,MAAKa,gBAAL,CAAsB,MAAKZ,KAAL,CAAWG,kBAAjC,C;iGAEL,UAACD,KAAD,EAAW;AACpB,YAAKQ,QAAL,CAAc;AAAER,QAAAA,KAAK,EAALA;AAAF,OAAd;;AAEA,YAAKW,aAAL,CAAmBX,KAAnB;AACD,K;;;;;;WAnCD,0CAAiCY,SAAjC,EAA4C;AAC1C,wBAAyC,KAAKd,KAA9C;AAAA,UAAQG,kBAAR,eAAQA,kBAAR;AAAA,UAA4BY,QAA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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,EAAmB1D,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 } 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 classes: PropTypes.object.isRequired,\n prompt: PropTypes.string,\n note: PropTypes.string,\n showNote: PropTypes.bool,\n env: PropTypes.object,\n rationale: PropTypes.string,\n disabled: PropTypes.bool,\n displayType: PropTypes.string,\n markup: PropTypes.string,\n mode: PropTypes.string,\n teacherInstructions: PropTypes.string,\n value: PropTypes.object,\n feedback: PropTypes.object,\n onChange: PropTypes.func,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n maxLengthPerChoice: PropTypes.array,\n maxLengthPerChoiceEnabled: PropTypes.bool,\n playerSpellCheckEnabled: PropTypes.bool,\n language: PropTypes.string,\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 (note && language && language !== nextProps.language &&\n note === translator.t('common:commonCorrectAnswerWithAlternates', { lng: language })) {\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 classes,\n mode,\n prompt,\n rationale,\n teacherInstructions,\n note,\n showNote,\n env,\n animationsDisabled,\n alwaysShowCorrect,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType,\n playerSpellCheckEnabled,\n language\n } = this.props;\n\n const { role } = env || {};\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 <div 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 />\n\n {displayNote && (\n <div\n className={classNames(classes.note, 'note')}\n dangerouslySetInnerHTML={{ __html: note }}\n />\n )}\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 </div>\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","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","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;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;IAEaE,I;;;;;;;;;;;;;;;8FA4BH;AACNC,MAAAA,iBAAiB,EAAE,MAAKC,KAAL,CAAWC,iBAAX,IAAgC,KAD7C;AAENC,MAAAA,KAAK,EAAE,MAAKF,KAAL,CAAWE;AAFZ,K;yGAMW,UAACC,kBAAD;AAAA,aACjBA,kBAAkB,IAAIA,kBAAkB,CAACC,KAAnB,CAAyB,UAACC,GAAD,EAAMC,CAAN,EAASC,GAAT;AAAA,eAAiBF,GAAG,KAAKE,GAAG,CAAC,CAAD,CAAX,IAAkBF,GAAG,KAAK,CAA3C;AAAA,OAAzB,CAAtB,GACI,MAAKL,KAAL,CAAWQ,QADf,GAEI,sBAAS,MAAKR,KAAL,CAAWQ,QAApB,EAA8B,IAA9B,EAAoC;AAAEC,QAAAA,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GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBvB,IAAAA,aAAa,EAAE;AACbwB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADM;AAEbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFJ,KADU;AAKzBC,IAAAA,aAAa,EAAE;AACbxB,MAAAA,OAAO,EAAE;AADI,KALU;AAQzByB,IAAAA,YAAY,EAAE;AACZzB,MAAAA,OAAO,EAAE;AADG,KARW;AAWzBrB,IAAAA,IAAI,EAAE;AACJ+C,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,EAAmBzD,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { debounce, isEmpty, isEqual } from 'lodash';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { ConstructedResponse } from '@pie-lib/pie-toolbox/mask-markup';\nimport { color, Collapsible, hasText, PreviewPrompt } 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 };\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 } = this.props;\n\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 <div 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 />\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 </div>\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/lib/print.js CHANGED
@@ -46,12 +46,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
46
46
  var log = (0, _debug["default"])('pie-element:explicit-constructed-response:print');
47
47
 
48
48
  var preparePrintModel = function preparePrintModel(model, opts) {
49
- var instr = opts.role === 'instructor';
49
+ var isInstructor = opts.role === 'instructor';
50
50
  model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
51
- model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
52
- model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;
53
- model.alwaysShowCorrect = instr;
54
- model.mode = instr ? 'evaluate' : model.mode;
51
+ model.teacherInstructions = isInstructor && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
52
+ model.rationale = isInstructor && model.rationaleEnabled !== false ? model.rationale : undefined;
53
+ model.alwaysShowCorrect = isInstructor;
54
+ model.mode = isInstructor ? 'evaluate' : model.mode;
55
55
  model.disabled = true;
56
56
  model.animationsDisabled = true;
57
57
  return model;
package/lib/print.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","rationale","rationaleEnabled","alwaysShowCorrect","mode","disabled","animationsDisabled","ExplicitConstructedResponsePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","onChange","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iDAAN,CAAZ;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GACEL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SADpF;AAEAN,EAAAA,KAAK,CAACS,SAAN,GAAkBP,KAAK,IAAIF,KAAK,CAACU,gBAAN,KAA2B,KAApC,GAA4CV,KAAK,CAACS,SAAlD,GAA8DH,SAAhF;AAEAN,EAAAA,KAAK,CAACW,iBAAN,GAA0BT,KAA1B;AACAF,EAAAA,KAAK,CAACY,IAAN,GAAaV,KAAK,GAAG,UAAH,GAAgBF,KAAK,CAACY,IAAxC;AAEAZ,EAAAA,KAAK,CAACa,QAAN,GAAiB,IAAjB;AACAb,EAAAA,KAAK,CAACc,kBAAN,GAA2B,IAA3B;AAEA,SAAOd,KAAP;AACD,CAfD;;IAiBqBe,gC;;;;;AACnB,8CAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,QAAL,GAAgB,IAAhB;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,EAAhB;AACA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAME,UAAU,GAAGrB,iBAAiB,CAAC,MAAKkB,MAAN,EAAc,MAAKD,QAAnB,CAApC;;AAEA,YAAMK,OAAO,GACX,MAAKL,QAAL,iBACAM,kBAAMC,aAAN,CAAoBC,gBAApB,kCACKJ,UADL;AAEEK,UAAAA,QAAQ,EAAE,oBAAM,CAAE;AAFpB,WAFF;;AAOAC,6BAASC,MAAT,CAAgBN,OAAhB,kDAA+B,YAAM;AACnCvB,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAdD,MAcO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KAnBc,EAoBf,EApBe,EAqBf;AAAE8B,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KArBe,CAAjB;AALY;AA4Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKd,QAAL,GAAgBc,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKd,MAAL,GAAcc,CAAd;;AACA,WAAKZ,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAvCsCa,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport debug from 'debug';\n\nconst log = debug('pie-element:explicit-constructed-response:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;\n\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExplicitConstructedResponsePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n ...printModel,\n onChange: () => {},\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
1
+ {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","isInstructor","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","rationale","rationaleEnabled","alwaysShowCorrect","mode","disabled","animationsDisabled","ExplicitConstructedResponsePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","onChange","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iDAAN,CAAZ;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,YAAY,GAAGD,IAAI,CAACE,IAAL,KAAc,YAAnC;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GACEL,YAAY,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAArD,GAA6DR,KAAK,CAACO,mBAAnE,GAAyFD,SAD3F;AAEAN,EAAAA,KAAK,CAACS,SAAN,GAAkBP,YAAY,IAAIF,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AAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAzCsCa,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport debug from 'debug';\n\nconst log = debug('pie-element:explicit-constructed-response:print');\n\nconst preparePrintModel = (model, opts) => {\n const isInstructor = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n isInstructor && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.rationale = isInstructor && model.rationaleEnabled !== false ? model.rationale : undefined;\n model.alwaysShowCorrect = isInstructor;\n model.mode = isInstructor ? 'evaluate' : model.mode;\n model.disabled = true;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExplicitConstructedResponsePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n ...printModel,\n onChange: () => {},\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.10.4/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.11.0/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@4.12.0/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) {
@@ -16739,53 +16739,19 @@ var defaults = {};
16739
16739
  exports["default"] = void 0;
16740
16740
  var _default = {
16741
16741
  model: {
16742
- disabled: false,
16743
- mode: 'gather',
16744
- prompt: 'Use the inputs to complete the sentence',
16745
- shuffle: true,
16746
- markup: '<p>The {{0}} jumped {{1}} the {{2}}</p>',
16747
- toolbarEditorPosition: 'bottom',
16742
+ choices: {},
16748
16743
  displayType: 'block',
16749
- spellCheckEnabled: true,
16750
- playerSpellCheckEnabled: true,
16751
- choices: {
16752
- 0: [{
16753
- label: 'cow',
16754
- value: '0'
16755
- }, {
16756
- label: 'cattle',
16757
- value: '1'
16758
- }, {
16759
- label: 'calf',
16760
- value: '2',
16761
- correct: false
16762
- }],
16763
- 1: [{
16764
- label: 'over',
16765
- value: '0'
16766
- }, {
16767
- label: 'past',
16768
- value: '1'
16769
- }, {
16770
- label: 'beyond',
16771
- value: '2'
16772
- }],
16773
- 2: [{
16774
- label: 'moon',
16775
- value: '0'
16776
- }, {
16777
- label: 'satellite',
16778
- value: '2'
16779
- }, {
16780
- label: 'house ',
16781
- value: '3'
16782
- }]
16783
- },
16744
+ markup: '',
16784
16745
  maxLengthPerChoiceEnabled: true,
16785
- rationaleEnabled: true,
16746
+ playerSpellCheckEnabled: true,
16747
+ prompt: '',
16786
16748
  promptEnabled: true,
16749
+ rationale: '',
16750
+ rationaleEnabled: true,
16751
+ spellCheckEnabled: true,
16752
+ studentInstructionsEnabled: true,
16787
16753
  teacherInstructionsEnabled: true,
16788
- studentInstructionsEnabled: true
16754
+ toolbarEditorPosition: 'bottom'
16789
16755
  },
16790
16756
  configuration: {
16791
16757
  baseInputConfiguration: {