@pie-element/explicit-constructed-response 3.9.2 → 3.9.3-next.1016

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/configure/CHANGELOG.md +176 -0
  3. package/configure/lib/alternateResponses.js +45 -12
  4. package/configure/lib/alternateResponses.js.map +1 -1
  5. package/configure/lib/alternateSection.js +116 -19
  6. package/configure/lib/alternateSection.js.map +1 -1
  7. package/configure/lib/defaults.js +30 -0
  8. package/configure/lib/defaults.js.map +1 -1
  9. package/configure/lib/ecr-toolbar.js +19 -7
  10. package/configure/lib/ecr-toolbar.js.map +1 -1
  11. package/configure/lib/index.js +3 -3
  12. package/configure/lib/main.js +250 -42
  13. package/configure/lib/main.js.map +1 -1
  14. package/configure/lib/markupUtils.js +29 -3
  15. package/configure/lib/markupUtils.js.map +1 -1
  16. package/configure/lib/utils.js +15 -0
  17. package/configure/lib/utils.js.map +1 -0
  18. package/configure/package.json +3 -3
  19. package/controller/CHANGELOG.md +61 -0
  20. package/controller/lib/index.js +99 -6
  21. package/controller/lib/index.js.map +1 -1
  22. package/controller/package.json +1 -1
  23. package/docs/config-schema.json +116 -0
  24. package/docs/config-schema.json.md +89 -1
  25. package/docs/demo/generate.js +3 -1
  26. package/docs/pie-schema.json +57 -0
  27. package/docs/pie-schema.json.md +45 -0
  28. package/lib/index.js +5 -1
  29. package/lib/index.js.map +1 -1
  30. package/lib/main.js +75 -24
  31. package/lib/main.js.map +1 -1
  32. package/lib/print.js +115 -0
  33. package/lib/print.js.map +1 -0
  34. package/package.json +11 -7
  35. package/module/configure.js +0 -2121
  36. package/module/controller.js +0 -20840
  37. package/module/demo.js +0 -44
  38. package/module/element.js +0 -240
  39. package/module/index.html +0 -16
  40. package/module/manifest.json +0 -10
@@ -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",
@@ -98,6 +113,24 @@
98
113
  "type": "string",
99
114
  "title": "note"
100
115
  },
116
+ "toolbarEditorPosition": {
117
+ "description": "Indicates the editor's toolbar position which can be 'bottom' or 'top'",
118
+ "default": ": 'bottom'",
119
+ "enum": [
120
+ "bottom",
121
+ "top"
122
+ ],
123
+ "type": "string",
124
+ "title": "toolbarEditorPosition"
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
+ },
101
134
  "id": {
102
135
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
103
136
  "type": "string",
@@ -112,12 +145,15 @@
112
145
  "required": [
113
146
  "autoScoring",
114
147
  "choices",
148
+ "displayType",
115
149
  "element",
116
150
  "id",
117
151
  "markup",
152
+ "playerSpellCheckEnabled",
118
153
  "rationale",
119
154
  "rationaleEnabled",
120
155
  "rubric",
156
+ "spellCheckEnabled",
121
157
  "studentInstructionsEnabled",
122
158
  "teacherInstructionsEnabled"
123
159
  ],
@@ -138,6 +174,27 @@
138
174
  }
139
175
  }
140
176
  },
177
+ "ConfigureMaxImageDimensionsProp": {
178
+ "title": "ConfigureMaxImageDimensionsProp",
179
+ "type": "object",
180
+ "properties": {
181
+ "teacherInstructions": {
182
+ "description": "Indicates the max dimension for images in teacher instructions",
183
+ "type": "number",
184
+ "title": "teacherInstructions"
185
+ },
186
+ "prompt": {
187
+ "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",
188
+ "type": "number",
189
+ "title": "prompt"
190
+ },
191
+ "rationale": {
192
+ "description": "Indicates the max dimension for images in rationale",
193
+ "type": "number",
194
+ "title": "rationale"
195
+ }
196
+ }
197
+ },
141
198
  "Choice": {
142
199
  "title": "Choice",
143
200
  "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
@@ -60,6 +72,23 @@ Indicates if Teacher Instructions are enabled
60
72
 
61
73
  Indicates the note for the answer
62
74
 
75
+ # `toolbarEditorPosition` (string, enum)
76
+
77
+ Indicates the editor's toolbar position which can be 'bottom' or 'top'
78
+
79
+ This element must be one of the following enum values:
80
+
81
+ * `bottom`
82
+ * `top`
83
+
84
+ Default: `": 'bottom'"`
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
+
63
92
  # `id` (string, required)
64
93
 
65
94
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -86,6 +115,22 @@ Indicates if the item has to be displayed in the Settings Panel
86
115
 
87
116
  Indicates the label for the item that has to be displayed in the Settings Panel
88
117
 
118
+ ## `ConfigureMaxImageDimensionsProp` (object)
119
+
120
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
121
+
122
+ ### `teacherInstructions` (number)
123
+
124
+ Indicates the max dimension for images in teacher instructions
125
+
126
+ ### `prompt` (number)
127
+
128
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
129
+
130
+ ### `rationale` (number)
131
+
132
+ Indicates the max dimension for images in rationale
133
+
89
134
  ## `Choice` (object)
90
135
 
91
136
  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;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vent\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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Ab,EADF,EAEE,MAAKC,OAAL,IAAgB,CAAC,CAAC,MAAKA,OAAL,CAAaX,KAFjC,CADF;AAMD,KA/Da;AAAA,sGAiEE,UAAAA,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,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AA,OAAO,EAAE;AADL,KANiB;AASvBjB,IAAAA,WAAW,EAAE;AACXwB,MAAAA,MAAM,YAAKR,KAAK,CAACE,OAAN,CAAcC,IAAd,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;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;AAGbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAHJ,KADQ;AAMvBC,IAAAA,aAAa,EAAE;AACb1B,MAAAA,OAAO,EAAE;AADI,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"}
package/lib/print.js ADDED
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
25
+
26
+ var _react = _interopRequireDefault(require("react"));
27
+
28
+ var _reactDom = _interopRequireDefault(require("react-dom"));
29
+
30
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
31
+
32
+ var _main = _interopRequireDefault(require("./main"));
33
+
34
+ var _mathRendering = require("@pie-lib/math-rendering");
35
+
36
+ var _debug = _interopRequireDefault(require("debug"));
37
+
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
+
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
41
+
42
+ 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
+
44
+ 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
+
46
+ var log = (0, _debug["default"])('pie-element:explicit-constructed-response:print');
47
+
48
+ var preparePrintModel = function preparePrintModel(model, opts) {
49
+ var instr = opts.role === 'instructor';
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;
55
+ model.disabled = true;
56
+ model.animationsDisabled = true;
57
+ return model;
58
+ };
59
+
60
+ var ExplicitConstructedResponsePrint = /*#__PURE__*/function (_HTMLElement) {
61
+ (0, _inherits2["default"])(ExplicitConstructedResponsePrint, _HTMLElement);
62
+
63
+ var _super = _createSuper(ExplicitConstructedResponsePrint);
64
+
65
+ function ExplicitConstructedResponsePrint() {
66
+ var _this;
67
+
68
+ (0, _classCallCheck2["default"])(this, ExplicitConstructedResponsePrint);
69
+ _this = _super.call(this);
70
+ _this._options = null;
71
+ _this._model = null;
72
+ _this._session = [];
73
+ _this._rerender = (0, _debounce["default"])(function () {
74
+ if (_this._model && _this._session) {
75
+ var printModel = preparePrintModel(_this._model, _this._options);
76
+
77
+ var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], _objectSpread(_objectSpread({}, printModel), {}, {
78
+ onChange: function onChange() {}
79
+ }));
80
+
81
+ _reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
82
+ log('render complete - render math');
83
+ (0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
84
+ });
85
+ } else {
86
+ log('skip');
87
+ }
88
+ }, 50, {
89
+ leading: false,
90
+ trailing: true
91
+ });
92
+ return _this;
93
+ }
94
+
95
+ (0, _createClass2["default"])(ExplicitConstructedResponsePrint, [{
96
+ key: "options",
97
+ set: function set(o) {
98
+ this._options = o;
99
+ }
100
+ }, {
101
+ key: "model",
102
+ set: function set(s) {
103
+ this._model = s;
104
+
105
+ this._rerender();
106
+ }
107
+ }, {
108
+ key: "connectedCallback",
109
+ value: function connectedCallback() {}
110
+ }]);
111
+ return ExplicitConstructedResponsePrint;
112
+ }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
113
+
114
+ exports["default"] = ExplicitConstructedResponsePrint;
115
+ //# sourceMappingURL=print.js.map
@@ -0,0 +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,GAA4BL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SAA9G;AACAN,EAAAA,KAAK,CAACS,SAAN,GAAkB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;;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/math-rendering';\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 = 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"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "3.9.2",
7
+ "version": "3.9.3-next.1016+1dc291af4",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -13,10 +13,10 @@
13
13
  "dependencies": {
14
14
  "@material-ui/core": "^3.9.2",
15
15
  "@pie-framework/pie-player-events": "^0.1.0",
16
- "@pie-lib/correct-answer-toggle": "^2.3.26",
17
- "@pie-lib/mask-markup": "^1.10.17",
18
- "@pie-lib/math-rendering": "^2.3.8",
19
- "@pie-lib/render-ui": "^4.11.7",
16
+ "@pie-lib/correct-answer-toggle": "^2.3.39",
17
+ "@pie-lib/mask-markup": "^1.12.7",
18
+ "@pie-lib/math-rendering": "^2.4.3",
19
+ "@pie-lib/render-ui": "^4.12.9",
20
20
  "classnames": "^2.2.5",
21
21
  "lodash": "^4.17.10",
22
22
  "prop-types": "^15.6.1",
@@ -25,7 +25,11 @@
25
25
  },
26
26
  "author": "",
27
27
  "license": "ISC",
28
- "gitHead": "c4ade45496a17fa2a49e6fe44f6bc500ea17580f",
28
+ "gitHead": "1dc291af490cf91cc86a6a7c8d0eb0fdf184232b",
29
29
  "main": "lib/index.js",
30
- "module": "src/index.js"
30
+ "module": "src/index.js",
31
+ "exports": {
32
+ ".": "./src/index.js",
33
+ "./print": "./src/print.js"
34
+ }
31
35
  }