@pie-element/explicit-constructed-response 3.9.3-next.137 → 3.9.3-next.1370

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.
@@ -38,6 +38,30 @@ Indicates if the item has to be displayed in the Settings Panel
38
38
 
39
39
  Indicates the label for the item that has to be displayed in the Settings Panel
40
40
 
41
+ # `spellCheck` (object)
42
+
43
+ Properties of the `spellCheck` object:
44
+
45
+ ## `settings` (boolean)
46
+
47
+ Indicates if the item has to be displayed in the Settings Panel
48
+
49
+ ## `label` (string)
50
+
51
+ Indicates the label for the item that has to be displayed in the Settings Panel
52
+
53
+ # `playerSpellCheck` (object)
54
+
55
+ Properties of the `playerSpellCheck` object:
56
+
57
+ ## `settings` (boolean)
58
+
59
+ Indicates if the item has to be displayed in the Settings Panel
60
+
61
+ ## `label` (string)
62
+
63
+ Indicates the label for the item that has to be displayed in the Settings Panel
64
+
41
65
  # `autoScoring` (object)
42
66
 
43
67
  Properties of the `autoScoring` object:
@@ -98,6 +122,66 @@ Indicates if the item has to be displayed in the Settings Panel
98
122
 
99
123
  Indicates the label for the item that has to be displayed in the Settings Panel
100
124
 
125
+ # `maxLengthPerChoice` (object)
126
+
127
+ Properties of the `maxLengthPerChoice` object:
128
+
129
+ ## `settings` (boolean)
130
+
131
+ Indicates if the item has to be displayed in the Settings Panel
132
+
133
+ ## `label` (string)
134
+
135
+ Indicates the label for the item that has to be displayed in the Settings Panel
136
+
137
+ # `maxResponseAreas` (number)
138
+
139
+ Maximum number of response areas
140
+
141
+ # `maxImageWidth` (object)
142
+
143
+ Properties of the `maxImageWidth` object:
144
+
145
+ ## `teacherInstructions` (number)
146
+
147
+ Indicates the max dimension for images in teacher instructions
148
+
149
+ ## `prompt` (number)
150
+
151
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
152
+
153
+ ## `rationale` (number)
154
+
155
+ Indicates the max dimension for images in rationale
156
+
157
+ # `maxImageHeight` (object)
158
+
159
+ Properties of the `maxImageHeight` object:
160
+
161
+ ## `teacherInstructions` (number)
162
+
163
+ Indicates the max dimension for images in teacher instructions
164
+
165
+ ## `prompt` (number)
166
+
167
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
168
+
169
+ ## `rationale` (number)
170
+
171
+ Indicates the max dimension for images in rationale
172
+
173
+ # `withRubric` (object)
174
+
175
+ Properties of the `withRubric` object:
176
+
177
+ ## `settings` (boolean)
178
+
179
+ Indicates if the item has to be displayed in the Settings Panel
180
+
181
+ ## `label` (string)
182
+
183
+ Indicates the label for the item that has to be displayed in the Settings Panel
184
+
101
185
  # `showPrompt` (boolean)
102
186
 
103
187
  Determines whether prompt field will be displayed or not
@@ -132,4 +216,20 @@ Indicates if the item has to be displayed in the Settings Panel
132
216
 
133
217
  ### `label` (string)
134
218
 
135
- Indicates the label for the item that has to be displayed in the Settings Panel
219
+ Indicates the label for the item that has to be displayed in the Settings Panel
220
+
221
+ ## `ConfigureMaxImageDimensionsProp` (object)
222
+
223
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
224
+
225
+ ### `teacherInstructions` (number)
226
+
227
+ Indicates the max dimension for images in teacher instructions
228
+
229
+ ### `prompt` (number)
230
+
231
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
232
+
233
+ ### `rationale` (number)
234
+
235
+ Indicates the max dimension for images in rationale
@@ -12,8 +12,10 @@ exports.model = (id, element) => ({
12
12
  1: [choice('over', '0'), choice('past', '1'), choice('beyond', '2')],
13
13
  2: [choice('moon', '0')]
14
14
  },
15
+ maxLengthPerChoice: [7, 10, 4],
15
16
  prompt: 'Complete the sentence',
16
17
  note: 'The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',
17
18
  promptEnabled: true,
18
- toolbarEditorPosition: 'bottom'
19
+ toolbarEditorPosition: 'bottom',
20
+ rubricEnabled: false
19
21
  });
@@ -34,6 +34,11 @@
34
34
  },
35
35
  "title": "choices"
36
36
  },
37
+ "displayType": {
38
+ "description": "The type of display the container of the pie-ui element will be used",
39
+ "type": "string",
40
+ "title": "displayType"
41
+ },
37
42
  "markup": {
38
43
  "description": "The markup for the pie-ui element",
39
44
  "type": "string",
@@ -49,6 +54,16 @@
49
54
  "type": "boolean",
50
55
  "title": "promptEnabled"
51
56
  },
57
+ "spellCheckEnabled": {
58
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
59
+ "type": "boolean",
60
+ "title": "spellCheckEnabled"
61
+ },
62
+ "playerSpellCheckEnabled": {
63
+ "description": "Indicates if spellcheck is enabled for the player. Default value is true",
64
+ "type": "boolean",
65
+ "title": "playerSpellCheckEnabled"
66
+ },
52
67
  "rationale": {
53
68
  "description": "Indicates correct answer rationale",
54
69
  "type": "string",
@@ -108,6 +123,19 @@
108
123
  "type": "string",
109
124
  "title": "toolbarEditorPosition"
110
125
  },
126
+ "maxLengthPerChoice": {
127
+ "description": "Indicates the maximum length for each response area",
128
+ "type": "array",
129
+ "items": {
130
+ "type": "number"
131
+ },
132
+ "title": "maxLengthPerChoice"
133
+ },
134
+ "rubricEnabled": {
135
+ "description": "Indicates if Rubric is enabled",
136
+ "type": "boolean",
137
+ "title": "rubricEnabled"
138
+ },
111
139
  "id": {
112
140
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
113
141
  "type": "string",
@@ -122,12 +150,16 @@
122
150
  "required": [
123
151
  "autoScoring",
124
152
  "choices",
153
+ "displayType",
125
154
  "element",
126
155
  "id",
127
156
  "markup",
157
+ "playerSpellCheckEnabled",
128
158
  "rationale",
129
159
  "rationaleEnabled",
130
160
  "rubric",
161
+ "rubricEnabled",
162
+ "spellCheckEnabled",
131
163
  "studentInstructionsEnabled",
132
164
  "teacherInstructionsEnabled"
133
165
  ],
@@ -148,6 +180,27 @@
148
180
  }
149
181
  }
150
182
  },
183
+ "ConfigureMaxImageDimensionsProp": {
184
+ "title": "ConfigureMaxImageDimensionsProp",
185
+ "type": "object",
186
+ "properties": {
187
+ "teacherInstructions": {
188
+ "description": "Indicates the max dimension for images in teacher instructions",
189
+ "type": "number",
190
+ "title": "teacherInstructions"
191
+ },
192
+ "prompt": {
193
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
194
+ "type": "number",
195
+ "title": "prompt"
196
+ },
197
+ "rationale": {
198
+ "description": "Indicates the max dimension for images in rationale",
199
+ "type": "number",
200
+ "title": "rationale"
201
+ }
202
+ }
203
+ },
151
204
  "Choice": {
152
205
  "title": "Choice",
153
206
  "type": "object",
@@ -7,6 +7,10 @@ The schema defines the following properties:
7
7
  * Object with all the available choices for each response area.
8
8
  * Keys need to be integers from 0 to n - 1 (where n is the number of areas)
9
9
 
10
+ # `displayType` (string, required)
11
+
12
+ The type of display the container of the pie-ui element will be used
13
+
10
14
  # `markup` (string, required)
11
15
 
12
16
  The markup for the pie-ui element
@@ -19,6 +23,14 @@ The item stem for the question
19
23
 
20
24
  Indicates if the prompt is enabled
21
25
 
26
+ # `spellCheckEnabled` (boolean, required)
27
+
28
+ Indicates if spellcheck is enabled for the author. Default value is true
29
+
30
+ # `playerSpellCheckEnabled` (boolean, required)
31
+
32
+ Indicates if spellcheck is enabled for the player. Default value is true
33
+
22
34
  # `rationale` (string, required)
23
35
 
24
36
  Indicates correct answer rationale
@@ -71,6 +83,16 @@ This element must be one of the following enum values:
71
83
 
72
84
  Default: `": 'bottom'"`
73
85
 
86
+ # `maxLengthPerChoice` (array)
87
+
88
+ Indicates the maximum length for each response area
89
+
90
+ The object is an array with all elements of the type `number`.
91
+
92
+ # `rubricEnabled` (boolean, required)
93
+
94
+ Indicates if Rubric is enabled
95
+
74
96
  # `id` (string, required)
75
97
 
76
98
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -97,6 +119,22 @@ Indicates if the item has to be displayed in the Settings Panel
97
119
 
98
120
  Indicates the label for the item that has to be displayed in the Settings Panel
99
121
 
122
+ ## `ConfigureMaxImageDimensionsProp` (object)
123
+
124
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
125
+
126
+ ### `teacherInstructions` (number)
127
+
128
+ Indicates the max dimension for images in teacher instructions
129
+
130
+ ### `prompt` (number)
131
+
132
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
133
+
134
+ ### `rationale` (number)
135
+
136
+ Indicates the max dimension for images in rationale
137
+
100
138
  ## `Choice` (object)
101
139
 
102
140
  Properties of the `Choice` object:
package/lib/index.js CHANGED
@@ -35,7 +35,7 @@ var _main = _interopRequireDefault(require("./main"));
35
35
 
36
36
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
37
37
 
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
39
 
40
40
  var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
41
41
  (0, _inherits2["default"])(InlineDropdown, _HTMLElement);
@@ -60,8 +60,12 @@ var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
60
60
  choices: _this._model.choices,
61
61
  markup: _this._model.markup,
62
62
  mode: _this._model.mode,
63
+ maxLengthPerChoice: _this._model.maxLengthPerChoice,
64
+ maxLengthPerChoiceEnabled: _this._model.maxLengthPerChoiceEnabled,
65
+ playerSpellCheckEnabled: _this._model.playerSpellCheckEnabled,
63
66
  value: _this._session.value,
64
67
  feedback: _this._model.feedback,
68
+ displayType: _this._model.displayType,
65
69
  onChange: _this.changeSession
66
70
  });
67
71
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","note","showNote","env","rationale","disabled","choices","markup","mode","value","feedback","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAIA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGA4BJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,mBAAmB,EAAE,MAAKN,MAAL,CAAYM,mBADE;AAEnCC,UAAAA,MAAM,EAAE,MAAKP,MAAL,CAAYO,MAFe;AAGnCC,UAAAA,IAAI,EAAE,MAAKR,MAAL,CAAYQ,IAHiB;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,GAAG,EAAE,MAAKV,MAAL,CAAYU,GALkB;AAMnCC,UAAAA,SAAS,EAAE,MAAKX,MAAL,CAAYW,SANY;AAOnCC,UAAAA,QAAQ,EAAE,MAAKZ,MAAL,CAAYY,QAPa;AAQnCC,UAAAA,OAAO,EAAE,MAAKb,MAAL,CAAYa,OARc;AASnCC,UAAAA,MAAM,EAAE,MAAKd,MAAL,CAAYc,MATe;AAUnCC,UAAAA,IAAI,EAAE,MAAKf,MAAL,CAAYe,IAViB;AAWnCC,UAAAA,KAAK,EAAE,MAAKf,QAAL,CAAce,KAXc;AAYnCC,UAAAA,QAAQ,EAAE,MAAKjB,MAAL,CAAYiB,QAZa;AAanCC,UAAAA,QAAQ,EAAE,MAAKC;AAboB,SAA1B,CAAX;;AAeAC,6BAASC,MAAT,CAAgBnB,IAAhB,kDAA4B,YAAM;AAChC;AACD,SAFD;AAGD;AACF,KAjDa;AAAA,6GAmDS,YAAM;AAC3B,YAAKoB,aAAL,CACE,IAAIC,oCAAJ,CACE,MAAKC,OAAL,CAAaC,WAAb,EADF,EAEE,MAAKC,OAAL,IAAgB,CAAC,CAAC,MAAKA,OAAL,CAAaV,KAFjC,CADF;AAMD,KA1Da;AAAA,sGA4DE,UAAAA,KAAK,EAAI;AACvB,YAAKU,OAAL,CAAaV,KAAb,GAAqBA,KAArB;;AACA,YAAKW,oBAAL;;AACA,YAAKC,OAAL;AACD,KAhEa;AAEZ,UAAK5B,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAHY;AAIb;;;;SAED,aAAU4B,CAAV,EAAa;AACX,WAAK7B,MAAL,GAAc6B,CAAd;AACA,WAAKP,aAAL,CACE,IAAIQ,8BAAJ,CACE,KAAKN,OAAL,CAAaC,WAAb,EADF,EAEE,KAAKC,OAAL,IAAgB,CAAC,CAAC,KAAKA,OAAL,CAAaV,KAFjC,EAGE,CAAC,CAAC,KAAKhB,MAHT,CADF;;AAQA,WAAK4B,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAK3B,QAAZ;AACD,K;SAPD,aAAY8B,CAAZ,EAAe;AACb,WAAK9B,QAAL,GAAgB8B,CAAhB;;AACA,WAAKH,OAAL;AACD;;;WA4CD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;kDArEyCI,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n ModelSetEvent,\n SessionChangedEvent\n} from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\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 set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n this.session && !!this.session.value,\n !!this._model\n )\n );\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 teacherInstructions: this._model.teacherInstructions,\n prompt: this._model.prompt,\n note: this._model.note,\n showNote: this._model.showNote,\n env: this._model.env,\n rationale: this._model.rationale,\n disabled: this._model.disabled,\n choices: this._model.choices,\n markup: this._model.markup,\n mode: this._model.mode,\n value: this._session.value,\n feedback: this._model.feedback,\n onChange: this.changeSession\n });\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n this.session && !!this.session.value\n )\n );\n };\n\n changeSession = value => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this._render();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","note","showNote","env","rationale","disabled","choices","markup","mode","maxLengthPerChoice","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","value","feedback","displayType","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAIA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGA4BJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA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,KAAK,EAAI;AACvB,YAAKW,OAAL,CAAaX,KAAb,GAAqBA,KAArB;;AACA,YAAKY,oBAAL;;AACA,YAAKC,OAAL;AACD,KArEa;AAEZ,UAAKhC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAHY;AAIb;;;;SAED,aAAUgC,CAAV,EAAa;AACX,WAAKjC,MAAL,GAAciC,CAAd;AACA,WAAKP,aAAL,CACE,IAAIQ,8BAAJ,CACE,KAAKN,OAAL,CAAaC,WAAb,EADF,EAEE,KAAKC,OAAL,IAAgB,CAAC,CAAC,KAAKA,OAAL,CAAaX,KAFjC,EAGE,CAAC,CAAC,KAAKnB,MAHT,CADF;;AAQA,WAAKgC,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAK/B,QAAZ;AACD,K;SAPD,aAAYkC,CAAZ,EAAe;AACb,WAAKlC,QAAL,GAAgBkC,CAAhB;;AACA,WAAKH,OAAL;AACD;;;WAiDD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;kDA1EyCI,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n ModelSetEvent,\n SessionChangedEvent\n} from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\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 set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n this.session && !!this.session.value,\n !!this._model\n )\n );\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 teacherInstructions: this._model.teacherInstructions,\n prompt: this._model.prompt,\n note: this._model.note,\n showNote: this._model.showNote,\n env: this._model.env,\n rationale: this._model.rationale,\n disabled: this._model.disabled,\n choices: this._model.choices,\n markup: this._model.markup,\n mode: this._model.mode,\n maxLengthPerChoice: this._model.maxLengthPerChoice,\n maxLengthPerChoiceEnabled: this._model.maxLengthPerChoiceEnabled,\n playerSpellCheckEnabled: this._model.playerSpellCheckEnabled,\n value: this._session.value,\n feedback: this._model.feedback,\n displayType: this._model.displayType,\n onChange: this.changeSession\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n this.session && !!this.session.value\n )\n );\n };\n\n changeSession = value => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this._render();\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -31,6 +31,8 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
31
31
 
32
32
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
33
33
 
34
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
35
+
34
36
  var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
35
37
 
36
38
  var _maskMarkup = require("@pie-lib/mask-markup");
@@ -39,9 +41,11 @@ var _renderUi = require("@pie-lib/render-ui");
39
41
 
40
42
  var _styles = require("@material-ui/core/styles");
41
43
 
44
+ var _classnames = _interopRequireDefault(require("classnames"));
45
+
42
46
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
43
47
 
44
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
45
49
 
46
50
  var Main = /*#__PURE__*/function (_React$Component) {
47
51
  (0, _inherits2["default"])(Main, _React$Component);
@@ -59,15 +63,22 @@ var Main = /*#__PURE__*/function (_React$Component) {
59
63
 
60
64
  _this = _super.call.apply(_super, [this].concat(args));
61
65
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
62
- showCorrectAnswer: false,
66
+ showCorrectAnswer: _this.props.alwaysShowCorrect || false,
63
67
  value: _this.props.value
64
68
  });
69
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getChangeSession", function (maxLengthPerChoice) {
70
+ return maxLengthPerChoice && maxLengthPerChoice.every(function (val, i, arr) {
71
+ return val === arr[0] && val === 1;
72
+ }) ? _this.props.onChange : (0, _debounce["default"])(_this.props.onChange, 1500, {
73
+ maxWait: 1500
74
+ });
75
+ });
65
76
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleShowCorrect", function () {
66
77
  _this.setState({
67
78
  showCorrectAnswer: !_this.state.showCorrectAnswer
68
79
  });
69
80
  });
70
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeSession", (0, _debounce["default"])(_this.props.onChange, 1500));
81
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeSession", _this.getChangeSession(_this.props.maxLengthPerChoice));
71
82
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (value) {
72
83
  _this.setState({
73
84
  value: value
@@ -81,11 +92,23 @@ var Main = /*#__PURE__*/function (_React$Component) {
81
92
  (0, _createClass2["default"])(Main, [{
82
93
  key: "UNSAFE_componentWillReceiveProps",
83
94
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
95
+ var maxLengthPerChoice = this.props.maxLengthPerChoice;
96
+
84
97
  if ((0, _isEmpty["default"])(nextProps.feedback)) {
85
98
  this.setState({
86
99
  showCorrectAnswer: false
87
100
  });
88
101
  }
102
+
103
+ if (nextProps.alwaysShowCorrect) {
104
+ this.setState({
105
+ showCorrectAnswer: true
106
+ });
107
+ }
108
+
109
+ if (maxLengthPerChoice && !(0, _isEqual["default"])(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {
110
+ this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);
111
+ }
89
112
  }
90
113
  }, {
91
114
  key: "render",
@@ -101,54 +124,67 @@ var Main = /*#__PURE__*/function (_React$Component) {
101
124
  teacherInstructions = _this$props.teacherInstructions,
102
125
  note = _this$props.note,
103
126
  showNote = _this$props.showNote,
104
- env = _this$props.env;
127
+ env = _this$props.env,
128
+ animationsDisabled = _this$props.animationsDisabled,
129
+ alwaysShowCorrect = _this$props.alwaysShowCorrect,
130
+ maxLengthPerChoice = _this$props.maxLengthPerChoice,
131
+ maxLengthPerChoiceEnabled = _this$props.maxLengthPerChoiceEnabled,
132
+ displayType = _this$props.displayType,
133
+ playerSpellCheckEnabled = _this$props.playerSpellCheckEnabled;
105
134
 
106
135
  var _ref = env || {},
107
136
  role = _ref.role;
108
137
 
109
138
  var displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;
139
+ var mainClasses = (0, _classnames["default"])([classes.mainContainer, (0, _defineProperty2["default"])({}, classes.noBorderColor, alwaysShowCorrect)]);
140
+
141
+ var teacherInstructionsDiv = /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
142
+ defaultClassName: "teacher-instructions",
143
+ prompt: teacherInstructions
144
+ });
145
+
146
+ var rationaleDiv = /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
147
+ prompt: rationale
148
+ });
149
+
110
150
  return /*#__PURE__*/_react["default"].createElement("div", {
111
- className: classes.mainContainer
151
+ className: mainClasses,
152
+ style: {
153
+ display: "".concat(displayType)
154
+ }
112
155
  }, teacherInstructions && (0, _renderUi.hasText)(teacherInstructions) && /*#__PURE__*/_react["default"].createElement("div", {
113
156
  className: classes.collapsible
114
- }, /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
157
+ }, !animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
115
158
  labels: {
116
159
  hidden: 'Show Teacher Instructions',
117
160
  visible: 'Hide Teacher Instructions'
118
161
  }
119
- }, /*#__PURE__*/_react["default"].createElement("div", {
120
- dangerouslySetInnerHTML: {
121
- __html: teacherInstructions
122
- }
123
- }))), /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
162
+ }, teacherInstructionsDiv) : teacherInstructionsDiv), !alwaysShowCorrect && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
124
163
  show: mode === 'evaluate',
125
164
  toggled: showCorrectAnswer,
126
165
  onToggle: this.toggleShowCorrect
127
- }), prompt && /*#__PURE__*/_react["default"].createElement("div", {
128
- dangerouslySetInnerHTML: {
129
- __html: prompt
130
- }
166
+ }), prompt && /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
167
+ prompt: prompt
131
168
  }), /*#__PURE__*/_react["default"].createElement(_maskMarkup.ConstructedResponse, (0, _extends2["default"])({}, this.props, {
132
169
  onChange: this.onChange,
133
170
  showCorrectAnswer: showCorrectAnswer,
134
- value: value
171
+ value: value,
172
+ maxLength: maxLengthPerChoice,
173
+ adjustedLimit: maxLengthPerChoiceEnabled,
174
+ spellCheck: playerSpellCheckEnabled
135
175
  })), displayNote && /*#__PURE__*/_react["default"].createElement("div", {
136
- className: classes.note,
176
+ className: (0, _classnames["default"])(classes.note, 'note'),
137
177
  dangerouslySetInnerHTML: {
138
178
  __html: "<strong>Note:</strong> ".concat(note)
139
179
  }
140
180
  }), rationale && (0, _renderUi.hasText)(rationale) && /*#__PURE__*/_react["default"].createElement("div", {
141
181
  className: classes.collapsible
142
- }, /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
182
+ }, !animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
143
183
  labels: {
144
184
  hidden: 'Show Rationale',
145
185
  visible: 'Hide Rationale'
146
186
  }
147
- }, /*#__PURE__*/_react["default"].createElement("div", {
148
- dangerouslySetInnerHTML: {
149
- __html: rationale
150
- }
151
- }))));
187
+ }, rationaleDiv) : rationaleDiv));
152
188
  }
153
189
  }]);
154
190
  return Main;
@@ -168,7 +204,11 @@ exports.Main = Main;
168
204
  teacherInstructions: _propTypes["default"].string,
169
205
  value: _propTypes["default"].object,
170
206
  feedback: _propTypes["default"].object,
171
- onChange: _propTypes["default"].func
207
+ onChange: _propTypes["default"].func,
208
+ alwaysShowCorrect: _propTypes["default"].bool,
209
+ animationsDisabled: _propTypes["default"].bool,
210
+ maxLengthPerChoice: _propTypes["default"].array,
211
+ playerSpellCheckEnabled: _propTypes["default"].bool
172
212
  });
173
213
  (0, _defineProperty2["default"])(Main, "defaultProps", {
174
214
  value: {}
@@ -181,11 +221,22 @@ var styles = function styles(theme) {
181
221
  color: _renderUi.color.text(),
182
222
  backgroundColor: _renderUi.color.background()
183
223
  },
224
+ inlineDisplay: {
225
+ display: 'inline-block'
226
+ },
227
+ blockDisplay: {
228
+ display: 'block'
229
+ },
184
230
  note: {
185
231
  padding: '5px 0'
186
232
  },
187
233
  collapsible: {
188
234
  margin: "".concat(theme.spacing.unit * 2, "px 0")
235
+ },
236
+ noBorderColor: {
237
+ '& *': {
238
+ borderColor: "".concat(_renderUi.color.text(), " !important")
239
+ }
189
240
  }
190
241
  };
191
242
  };
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.js"],"names":["Main","showCorrectAnswer","value","props","setState","state","onChange","changeSession","nextProps","feedback","classes","mode","prompt","rationale","teacherInstructions","note","showNote","env","role","displayNote","mainContainer","collapsible","hidden","visible","__html","toggleShowCorrect","React","Component","PropTypes","object","isRequired","string","bool","disabled","markup","func","styles","theme","padding","spacing","unit","color","text","backgroundColor","background","margin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,I;;;;;;;;;;;;;;;8FAqBH;AACNC,MAAAA,iBAAiB,EAAE,KADb;AAENC,MAAAA,KAAK,EAAE,MAAKC,KAAL,CAAWD;AAFZ,K;0GAWY,YAAM;AACxB,YAAKE,QAAL,CAAc;AAAEH,QAAAA,iBAAiB,EAAE,CAAC,MAAKI,KAAL,CAAWJ;AAAjC,OAAd;AACD,K;sGAEe,0BAAS,MAAKE,KAAL,CAAWG,QAApB,EAA8B,IAA9B,C;iGAEL,UAAAJ,KAAK,EAAI;AAClB,YAAKE,QAAL,CAAc;AAAEF,QAAAA,KAAK,EAALA;AAAF,OAAd;;AAEA,YAAKK,aAAL,CAAmBL,KAAnB;AACD,K;;;;;;WAhBD,0CAAiCM,SAAjC,EAA4C;AAC1C,UAAI,yBAAQA,SAAS,CAACC,QAAlB,CAAJ,EAAiC;AAC/B,aAAKL,QAAL,CAAc;AAAEH,UAAAA,iBAAiB,EAAE;AAArB,SAAd;AACD;AACF;;;WAcD,kBAAS;AAAA,wBAC8B,KAAKI,KADnC;AAAA,UACCJ,iBADD,eACCA,iBADD;AAAA,UACoBC,KADpB,eACoBA,KADpB;AAAA,wBAEgF,KAAKC,KAFrF;AAAA,UAECO,OAFD,eAECA,OAFD;AAAA,UAEUC,IAFV,eAEUA,IAFV;AAAA,UAEgBC,MAFhB,eAEgBA,MAFhB;AAAA,UAEwBC,SAFxB,eAEwBA,SAFxB;AAAA,UAEmCC,mBAFnC,eAEmCA,mBAFnC;AAAA,UAEwDC,IAFxD,eAEwDA,IAFxD;AAAA,UAE8DC,QAF9D,eAE8DA,QAF9D;AAAA,UAEwEC,GAFxE,eAEwEA,GAFxE;;AAAA,iBAGUA,GAAG,IAAI,EAHjB;AAAA,UAG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GAAqB,CAA1B;AADK;AATU,GAAL;AAAA,CAApB;;eAce,wBAAWJ,MAAX,EAAmBpC,IAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport isEmpty from 'lodash/isEmpty';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { ConstructedResponse } from '@pie-lib/mask-markup';\nimport { color, Collapsible, hasText } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\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 markup: PropTypes.string,\n mode: PropTypes.string,\n teacherInstructions: PropTypes.string,\n value: PropTypes.object,\n feedback: PropTypes.object,\n onChange: PropTypes.func\n };\n\n static defaultProps = {\n value: {}\n };\n\n state = {\n showCorrectAnswer: false,\n value: this.props.value\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (isEmpty(nextProps.feedback)) {\n this.setState({ showCorrectAnswer: false });\n }\n }\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n changeSession = debounce(this.props.onChange, 1500);\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 { classes, mode, prompt, rationale, teacherInstructions, note, showNote, env } = this.props;\n const { role } = env || {};\n const displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;\n\n return (\n <div className={classes.mainContainer}>\n {\n teacherInstructions && hasText(teacherInstructions) && (\n <div className={classes.collapsible}>\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n <div dangerouslySetInnerHTML={{ __html: teacherInstructions }}/>\n </Collapsible>\n </div>\n )\n }\n <CorrectAnswerToggle\n show={mode === 'evaluate'}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n />\n {prompt && <div dangerouslySetInnerHTML={{ __html: prompt }}/>}\n <ConstructedResponse\n {...this.props}\n onChange={this.onChange}\n showCorrectAnswer={showCorrectAnswer}\n value={value}\n />\n {displayNote && (\n <div\n className={classes.note}\n dangerouslySetInnerHTML={{ __html: `<strong>Note:</strong> ${note}` }}\n />\n )}\n {rationale && hasText(rationale) && (\n <div className={classes.collapsible}>\n <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n >\n <div dangerouslySetInnerHTML={{ __html: rationale }}/>\n </Collapsible>\n </div>\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n mainContainer: {\n padding: theme.spacing.unit,\n color: color.text(),\n backgroundColor: color.background()\n },\n note: {\n padding: '5px 0',\n },\n collapsible: {\n margin: `${theme.spacing.unit * 2}px 0`,\n }\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.js"],"names":["Main","showCorrectAnswer","props","alwaysShowCorrect","value","maxLengthPerChoice","every","val","i","arr","onChange","maxWait","setState","state","getChangeSession","changeSession","nextProps","feedback","classes","mode","prompt","rationale","teacherInstructions","note","showNote","env","animationsDisabled","maxLengthPerChoiceEnabled","displayType","playerSpellCheckEnabled","role","displayNote","mainClasses","mainContainer","noBorderColor","teacherInstructionsDiv","rationaleDiv","display","collapsible","hidden","visible","toggleShowCorrect","__html","React","Component","PropTypes","object","isRequired","string","bool","disabled","markup","func","array","styles","theme","padding","spacing","unit","color","text","backgroundColor","background","inlineDisplay","blockDisplay","margin","borderColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,I;;;;;;;;;;;;;;;8FAyBH;AACNC,MAAAA,iBAAiB,EAAE,MAAKC,KAAL,CAAWC,iBAAX,IAAgC,KAD7C;AA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I,KANQ;AASvB2B,IAAAA,YAAY,EAAE;AACZ3B,MAAAA,OAAO,EAAE;AADG,KATS;AAYvBd,IAAAA,IAAI,EAAE;AACJiC,MAAAA,OAAO,EAAE;AADL,KAZiB;AAevBlB,IAAAA,WAAW,EAAE;AACX2B,MAAAA,MAAM,YAAKV,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAA1B;AADK,KAfU;AAkBvBxB,IAAAA,aAAa,EAAE;AACb,aAAO;AACLgC,QAAAA,WAAW,YAAKP,gBAAMC,IAAN,EAAL;AADN;AADM;AAlBQ,GAAL;AAAA,CAApB;;eAyBe,wBAAWN,MAAX,EAAmBtD,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/correct-answer-toggle';\nimport { ConstructedResponse } from '@pie-lib/mask-markup';\nimport {color, Collapsible, hasText, PreviewPrompt} from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\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 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 playerSpellCheckEnabled: PropTypes.bool\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) ? this.props.onChange\n : debounce(this.props.onChange, 1500, { maxWait: 1500 });\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { maxLengthPerChoice } = 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\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 } = this.props;\n\n const { role } = env || {};\n const displayNote = (showCorrectAnswer || mode === 'view' && role === 'instructor') && showNote && note;\n const mainClasses = classNames([classes.mainContainer, {\n [classes.noBorderColor]: alwaysShowCorrect\n }]);\n\n const teacherInstructionsDiv = <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />;\n\n const rationaleDiv = <PreviewPrompt prompt={rationale} />;\n\n return (\n <div className={mainClasses} style={{ display: `${displayType}` }}>\n {\n teacherInstructions && hasText(teacherInstructions) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n : teacherInstructionsDiv}\n </div>\n )\n }\n {!alwaysShowCorrect && <CorrectAnswerToggle\n show={mode === 'evaluate'}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n />}\n {prompt && <PreviewPrompt prompt={prompt} />}\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 {displayNote && (\n <div\n className={classNames(classes.note, 'note')}\n dangerouslySetInnerHTML={{ __html: `<strong>Note:</strong> ${note}` }}\n />\n )}\n {rationale && hasText(rationale) && (\n <div className={classes.collapsible}>\n {!animationsDisabled ? <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n >\n {rationaleDiv}\n </Collapsible>\n : rationaleDiv}\n </div>\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n mainContainer: {\n padding: theme.spacing.unit,\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 padding: '5px 0'\n },\n collapsible: {\n margin: `${theme.spacing.unit * 2}px 0`\n },\n noBorderColor: {\n '& *': {\n borderColor: `${color.text()} !important`\n }\n }\n});\n\nexport default withStyles(styles)(Main);\n"],"file":"main.js"}