@pie-element/explicit-constructed-response 7.1.5-next.3 → 7.2.1-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 +24 -0
- package/configure/CHANGELOG.md +22 -0
- package/configure/lib/alternateResponses.js +8 -4
- package/configure/lib/alternateResponses.js.map +1 -1
- package/configure/lib/alternateSection.js +27 -15
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/defaults.js +13 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/ecr-toolbar.js +81 -37
- package/configure/lib/ecr-toolbar.js.map +1 -1
- package/configure/lib/index.js +18 -1
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +13 -4
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +11 -1
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/package.json +2 -2
- package/controller/CHANGELOG.md +18 -0
- package/controller/lib/index.js +3 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +16 -0
- package/docs/config-schema.json.md +12 -0
- package/docs/pie-schema.json +6 -0
- package/docs/pie-schema.json.md +6 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +14 -4
- package/lib/main.js.map +1 -1
- package/module/configure.js +860 -776
- package/module/controller.js +2 -0
- package/module/element.js +38353 -4643
- package/module/index.html +1 -1
- package/module/manifest.json +3 -3
- package/module/print.html +1 -1
- package/module/print.js +38347 -4638
- package/package.json +3 -3
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.0
|
|
4
|
+
"version": "5.1.0",
|
|
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.0
|
|
11
|
+
"@pie-lib/pie-toolbox": "2.1.0",
|
|
12
12
|
"debug": "^3.1.0",
|
|
13
13
|
"lodash": "^4.17.15",
|
|
14
14
|
"type-of": "^2.0.1"
|
package/docs/config-schema.json
CHANGED
|
@@ -1614,6 +1614,22 @@
|
|
|
1614
1614
|
],
|
|
1615
1615
|
"title": "languageChoices"
|
|
1616
1616
|
},
|
|
1617
|
+
"spanishInput": {
|
|
1618
|
+
"title": "ConfigureProp",
|
|
1619
|
+
"type": "object",
|
|
1620
|
+
"properties": {
|
|
1621
|
+
"settings": {
|
|
1622
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
1623
|
+
"type": "boolean",
|
|
1624
|
+
"title": "settings"
|
|
1625
|
+
},
|
|
1626
|
+
"label": {
|
|
1627
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
1628
|
+
"type": "string",
|
|
1629
|
+
"title": "label"
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
},
|
|
1617
1633
|
"showPrompt": {
|
|
1618
1634
|
"description": "Determines whether prompt field will be displayed or not",
|
|
1619
1635
|
"default": true,
|
|
@@ -1187,6 +1187,18 @@ Value of the language option
|
|
|
1187
1187
|
|
|
1188
1188
|
Label of the language option
|
|
1189
1189
|
|
|
1190
|
+
# `spanishInput` (object)
|
|
1191
|
+
|
|
1192
|
+
Properties of the `spanishInput` object:
|
|
1193
|
+
|
|
1194
|
+
## `settings` (boolean)
|
|
1195
|
+
|
|
1196
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
1197
|
+
|
|
1198
|
+
## `label` (string)
|
|
1199
|
+
|
|
1200
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
1201
|
+
|
|
1190
1202
|
# `showPrompt` (boolean)
|
|
1191
1203
|
|
|
1192
1204
|
Determines whether prompt field will be displayed or not
|
package/docs/pie-schema.json
CHANGED
|
@@ -141,6 +141,12 @@
|
|
|
141
141
|
"type": "string",
|
|
142
142
|
"title": "language"
|
|
143
143
|
},
|
|
144
|
+
"spanishInputEnabled": {
|
|
145
|
+
"description": "Whether a control to allow insertion of spanish characters should be displayed",
|
|
146
|
+
"default": true,
|
|
147
|
+
"type": "boolean",
|
|
148
|
+
"title": "spanishInputEnabled"
|
|
149
|
+
},
|
|
144
150
|
"id": {
|
|
145
151
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
146
152
|
"type": "string",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -98,6 +98,12 @@ Indicates if Rubric is enabled
|
|
|
98
98
|
Indicates the language of the component
|
|
99
99
|
Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
|
|
100
100
|
|
|
101
|
+
# `spanishInputEnabled` (boolean)
|
|
102
|
+
|
|
103
|
+
Whether a control to allow insertion of spanish characters should be displayed
|
|
104
|
+
|
|
105
|
+
Default: `true`
|
|
106
|
+
|
|
101
107
|
# `id` (string, required)
|
|
102
108
|
|
|
103
109
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
package/lib/index.js
CHANGED
|
@@ -69,7 +69,8 @@ var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
|
|
|
69
69
|
role: _this._model.role,
|
|
70
70
|
showNote: _this._model.showNote,
|
|
71
71
|
teacherInstructions: _this._model.teacherInstructions,
|
|
72
|
-
value: _this._session.value
|
|
72
|
+
value: _this._session.value,
|
|
73
|
+
responseAreaInputConfiguration: _this._model.responseAreaInputConfiguration
|
|
73
74
|
});
|
|
74
75
|
|
|
75
76
|
_reactDom["default"].render(elem, (0, _assertThisInitialized2["default"])(_this), function () {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","choices","disabled","displayType","feedback","language","markup","maxLengthPerChoice","maxLengthPerChoiceEnabled","mode","note","onChange","changeSession","playerSpellCheckEnabled","prompt","rationale","role","showNote","teacherInstructions","value","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","lang","slice","setAttribute","m","ModelSetEvent","setLangAttribute","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGA+BJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,OAAO,EAAE,MAAKN,MAAL,CAAYM,OADc;AAEnCC,UAAAA,QAAQ,EAAE,MAAKP,MAAL,CAAYO,QAFa;AAGnCC,UAAAA,WAAW,EAAE,MAAKR,MAAL,CAAYQ,WAHU;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,QAAQ,EAAE,MAAKV,MAAL,CAAYU,QALa;AAMnCC,UAAAA,MAAM,EAAE,MAAKX,MAAL,CAAYW,MANe;AAOnCC,UAAAA,kBAAkB,EAAE,MAAKZ,MAAL,CAAYY,kBAPG;AAQnCC,UAAAA,yBAAyB,EAAE,MAAKb,MAAL,CAAYa,yBARJ;AASnCC,UAAAA,IAAI,EAAE,MAAKd,MAAL,CAAYc,IATiB;AAUnCC,UAAAA,IAAI,EAAE,MAAKf,MAAL,CAAYe,IAViB;AAWnCC,UAAAA,QAAQ,EAAE,MAAKC,aAXoB;AAYnCC,UAAAA,uBAAuB,EAAE,MAAKlB,MAAL,CAAYkB,uBAZF;AAanCC,UAAAA,MAAM,EAAE,MAAKnB,MAAL,CAAYmB,MAbe;AAcnCC,UAAAA,SAAS,EAAE,MAAKpB,MAAL,CAAYoB,SAdY;AAenCC,UAAAA,IAAI,EAAE,MAAKrB,MAAL,CAAYqB,IAfiB;AAgBnCC,UAAAA,QAAQ,EAAE,MAAKtB,MAAL,CAAYsB,QAhBa;AAiBnCC,UAAAA,mBAAmB,EAAE,MAAKvB,MAAL,CAAYuB,mBAjBE;AAkBnCC,UAAAA,KAAK,EAAE,MAAKvB,QAAL,CAAcuB;
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","choices","disabled","displayType","feedback","language","markup","maxLengthPerChoice","maxLengthPerChoiceEnabled","mode","note","onChange","changeSession","playerSpellCheckEnabled","prompt","rationale","role","showNote","teacherInstructions","value","responseAreaInputConfiguration","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","lang","slice","setAttribute","m","ModelSetEvent","setLangAttribute","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGA+BJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,OAAO,EAAE,MAAKN,MAAL,CAAYM,OADc;AAEnCC,UAAAA,QAAQ,EAAE,MAAKP,MAAL,CAAYO,QAFa;AAGnCC,UAAAA,WAAW,EAAE,MAAKR,MAAL,CAAYQ,WAHU;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,QAAQ,EAAE,MAAKV,MAAL,CAAYU,QALa;AAMnCC,UAAAA,MAAM,EAAE,MAAKX,MAAL,CAAYW,MANe;AAOnCC,UAAAA,kBAAkB,EAAE,MAAKZ,MAAL,CAAYY,kBAPG;AAQnCC,UAAAA,yBAAyB,EAAE,MAAKb,MAAL,CAAYa,yB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AAKV,MAAL,CAAYU,QAAzD,GAAoE,EAArF;AACA,UAAMyB,IAAI,GAAGzB,QAAQ,GAAGA,QAAQ,CAAC0B,KAAT,CAAe,CAAf,EAAkB,CAAlB,CAAH,GAA0B,IAA/C;AACA,WAAKC,YAAL,CAAkB,MAAlB,EAA0BF,IAA1B;AACD;;;SAED,aAAUG,CAAV,EAAa;AACX,WAAKtC,MAAL,GAAcsC,CAAd;AACA,WAAKV,aAAL,CACE,IAAIW,8BAAJ,CAAkB,KAAKT,OAAL,CAAaC,WAAb,EAAlB,EAA8C,KAAKC,OAAL,IAAgB,CAAC,CAAC,KAAKA,OAAL,CAAaR,KAA7E,EAAoF,CAAC,CAAC,KAAKxB,MAA3F,CADF;AAGA,WAAKwC,gBAAL;;AAEA,WAAKN,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAKjC,QAAZ;AACD,K;SAPD,aAAYwC,CAAZ,EAAe;AACb,WAAKxC,QAAL,GAAgBwC,CAAhB;;AACA,WAAKP,OAAL;AACD;;;WA8CD,6BAAoB;AAClB,WAAKG,YAAL,CAAkB,YAAlB,EAAgC,4BAAhC;AACA,WAAKA,YAAL,CAAkB,MAAlB,EAA0B,QAA1B;;AAEA,WAAKH,OAAL;AACD;;;kDA7EyCQ,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\n\nimport Main from './main';\n\nexport default class InlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n this.setLangAttribute();\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n choices: this._model.choices,\n disabled: this._model.disabled,\n displayType: this._model.displayType,\n feedback: this._model.feedback,\n language: this._model.language,\n markup: this._model.markup,\n maxLengthPerChoice: this._model.maxLengthPerChoice,\n maxLengthPerChoiceEnabled: this._model.maxLengthPerChoiceEnabled,\n mode: this._model.mode,\n note: this._model.note,\n onChange: this.changeSession,\n playerSpellCheckEnabled: this._model.playerSpellCheckEnabled,\n prompt: this._model.prompt,\n rationale: this._model.rationale,\n role: this._model.role,\n showNote: this._model.showNote,\n teacherInstructions: this._model.teacherInstructions,\n value: this._session.value,\n responseAreaInputConfiguration: this._model.responseAreaInputConfiguration,\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Fill in the Blank Question');\n this.setAttribute('role', 'region');\n\n this._render();\n }\n}\n"],"file":"index.js"}
|
package/lib/main.js
CHANGED
|
@@ -149,7 +149,13 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
149
149
|
prompt = _this$props2.prompt,
|
|
150
150
|
rationale = _this$props2.rationale,
|
|
151
151
|
showNote = _this$props2.showNote,
|
|
152
|
-
teacherInstructions = _this$props2.teacherInstructions
|
|
152
|
+
teacherInstructions = _this$props2.teacherInstructions,
|
|
153
|
+
responseAreaInputConfiguration = _this$props2.responseAreaInputConfiguration,
|
|
154
|
+
model = _this$props2.model;
|
|
155
|
+
|
|
156
|
+
var _ref = model || {},
|
|
157
|
+
extraCSSRules = _ref.extraCSSRules;
|
|
158
|
+
|
|
153
159
|
var displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;
|
|
154
160
|
var mainClasses = (0, _classnames["default"])([classes.mainContainer, (0, _defineProperty2["default"])({}, classes.noBorderColor, alwaysShowCorrect)]);
|
|
155
161
|
|
|
@@ -162,7 +168,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
162
168
|
prompt: rationale
|
|
163
169
|
});
|
|
164
170
|
|
|
165
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
171
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.UiLayout, {
|
|
172
|
+
extraCSSRules: extraCSSRules,
|
|
166
173
|
className: mainClasses,
|
|
167
174
|
style: {
|
|
168
175
|
display: "".concat(displayType)
|
|
@@ -189,7 +196,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
189
196
|
value: value,
|
|
190
197
|
maxLength: maxLengthPerChoice,
|
|
191
198
|
adjustedLimit: maxLengthPerChoiceEnabled,
|
|
192
|
-
spellCheck: playerSpellCheckEnabled
|
|
199
|
+
spellCheck: playerSpellCheckEnabled,
|
|
200
|
+
pluginProps: responseAreaInputConfiguration
|
|
193
201
|
})), displayNote && /*#__PURE__*/_react["default"].createElement("div", {
|
|
194
202
|
className: (0, _classnames["default"])(classes.note, 'note'),
|
|
195
203
|
dangerouslySetInnerHTML: {
|
|
@@ -229,7 +237,9 @@ exports.Main = Main;
|
|
|
229
237
|
role: _propTypes["default"].string,
|
|
230
238
|
showNote: _propTypes["default"].bool,
|
|
231
239
|
teacherInstructions: _propTypes["default"].string,
|
|
232
|
-
value: _propTypes["default"].object
|
|
240
|
+
value: _propTypes["default"].object,
|
|
241
|
+
responseAreaInputConfiguration: _propTypes["default"].object,
|
|
242
|
+
model: _propTypes["default"].object.isRequired
|
|
233
243
|
});
|
|
234
244
|
(0, _defineProperty2["default"])(Main, "defaultProps", {
|
|
235
245
|
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","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;;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;0GAkCC,YAAM;AACxB,YAAKC,QAAL,CAAc;AAAEX,QAAAA,iBAAiB,EAAE,CAAC,MAAKY,KAAL,CAAWZ;AAAjC,OAAd;AACD,K;sGAEe,MAAKa,gBAAL,CAAsB,MAAKZ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,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 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 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"}
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;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,KAD7C;AAENC,MAAAA,KAAK,EAAE,MAAKF,KAAL,CAAWE;AAFZ,K;yGAMW,UAACC,kBAAD;AAAA,aACjBA,kBAAkB,IAAIA,kBAAkB,CAACC,KAAnB,CAAyB,UA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AM,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"}
|