@pie-element/math-inline 11.0.5-esm.1 → 11.1.2-next.1
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 +1191 -2718
- package/configure/CHANGELOG.md +984 -2344
- package/configure/lib/configure.js +162 -240
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +8 -8
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +447 -564
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +111 -176
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/response.js +330 -388
- package/configure/lib/response.js.map +1 -1
- package/configure/lib/utils.js +15 -30
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +14 -12
- package/controller/CHANGELOG.md +721 -1739
- package/controller/lib/defaults.js +5 -8
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +189 -278
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +1 -2
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +7 -7
- package/lib/index.js +72 -125
- package/lib/index.js.map +1 -1
- package/lib/main.js +784 -889
- package/lib/main.js.map +1 -1
- package/lib/print.js +43 -84
- package/lib/print.js.map +1 -1
- package/lib/simple-question-block.js +125 -162
- package/lib/simple-question-block.js.map +1 -1
- package/lib/utils.js +1 -2
- package/lib/utils.js.map +1 -1
- package/package.json +18 -33
- package/esm/configure.css +0 -847
- package/esm/configure.js +0 -1769
- package/esm/configure.js.map +0 -1
- package/esm/controller.css +0 -847
- package/esm/controller.js +0 -416
- package/esm/controller.js.map +0 -1
- package/esm/element.css +0 -847
- package/esm/element.js +0 -1476
- package/esm/element.js.map +0 -1
- package/esm/print.css +0 -847
- package/esm/print.js +0 -1288
- package/esm/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -4320
- package/module/demo.js +0 -66
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -104
- package/module/print.html +0 -18
- package/module/print.js +0 -1
package/lib/main.js
CHANGED
|
@@ -1,342 +1,261 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
7
|
+
exports.default = exports.Main = void 0;
|
|
22
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
9
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
11
|
var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
|
|
29
|
-
|
|
30
12
|
var _mathInput = require("@pie-lib/math-input");
|
|
31
|
-
|
|
32
13
|
var _renderUi = require("@pie-lib/render-ui");
|
|
33
|
-
|
|
34
14
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
39
|
-
|
|
15
|
+
var _styles = require("@mui/material/styles");
|
|
16
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
40
17
|
var _utils = require("./utils");
|
|
41
|
-
|
|
42
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
43
|
-
|
|
44
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
45
|
-
|
|
18
|
+
var _lodashEs = require("lodash-es");
|
|
46
19
|
var _simpleQuestionBlock = _interopRequireDefault(require("./simple-question-block"));
|
|
47
|
-
|
|
48
20
|
var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
49
|
-
|
|
50
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
51
|
-
|
|
52
21
|
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
53
|
-
|
|
54
22
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var translator = _translator["default"].translator;
|
|
65
|
-
var registered = false;
|
|
66
|
-
var NEWLINE_LATEX = /\\newline/g;
|
|
67
|
-
var REGEX = /{{response}}/gm;
|
|
68
|
-
var DEFAULT_KEYPAD_VARIANT = 6; // !!! If you're using Chrome but have selected the "iPad" device in Chrome Developer Tools, the navigator.userAgent string may still report as
|
|
23
|
+
const {
|
|
24
|
+
translator
|
|
25
|
+
} = _translator.default;
|
|
26
|
+
let registered = false;
|
|
27
|
+
const NEWLINE_LATEX = /\\newline/g;
|
|
28
|
+
const REGEX = /{{response}}/gm;
|
|
29
|
+
const DEFAULT_KEYPAD_VARIANT = 6;
|
|
30
|
+
|
|
31
|
+
// !!! If you're using Chrome but have selected the "iPad" device in Chrome Developer Tools, the navigator.userAgent string may still report as
|
|
69
32
|
// Safari because Chrome on iOS actually uses the Safari rendering engine under the hood due to Apple's restrictions on third-party browser engines.
|
|
70
33
|
// When you select the "iPad" device in Chrome Developer Tools, you're essentially emulating the behavior of Safari on an iPad, including the user agent string.
|
|
71
34
|
// Therefore, even though you're using Chrome, the user agent string will resemble that of Safari on an iPad.
|
|
72
35
|
// Since the regular expression /^((?!chrome|android).)*safari/i checks for the presence of "safari" in the user agent string while excluding "chrome" and "android",
|
|
73
36
|
// it will return true in this case because "safari" is present in the user agent string emulated by Chrome when in iPad mode.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
latex: key,
|
|
83
|
-
write: key,
|
|
84
|
-
label: key
|
|
85
|
-
};
|
|
86
|
-
});
|
|
37
|
+
const IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
38
|
+
function generateAdditionalKeys(keyData = []) {
|
|
39
|
+
return keyData.map(key => ({
|
|
40
|
+
name: key,
|
|
41
|
+
latex: key,
|
|
42
|
+
write: key,
|
|
43
|
+
label: key
|
|
44
|
+
}));
|
|
87
45
|
}
|
|
88
|
-
|
|
89
46
|
function isChildOfCurrentPieElement(child, parent) {
|
|
90
|
-
|
|
91
|
-
|
|
47
|
+
let node = child;
|
|
92
48
|
while (node !== null) {
|
|
93
49
|
if (parent && node === parent) {
|
|
94
50
|
return true;
|
|
95
51
|
}
|
|
96
|
-
|
|
97
52
|
node = node.parentNode;
|
|
98
53
|
}
|
|
99
|
-
|
|
100
54
|
return false;
|
|
101
55
|
}
|
|
102
|
-
|
|
103
|
-
function getKeyPadWidth() {
|
|
104
|
-
var additionalKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
105
|
-
var equationEditor = arguments.length > 1 ? arguments[1] : undefined;
|
|
56
|
+
function getKeyPadWidth(additionalKeys = [], equationEditor) {
|
|
106
57
|
return Math.floor(additionalKeys.length / 5) * 30 + (equationEditor === 'miscellaneous' ? 600 : 500);
|
|
107
58
|
}
|
|
108
|
-
|
|
109
59
|
function prepareForStatic(model, state) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
60
|
+
const {
|
|
61
|
+
config,
|
|
62
|
+
disabled
|
|
63
|
+
} = model || {};
|
|
64
|
+
const {
|
|
65
|
+
expression,
|
|
66
|
+
responses,
|
|
67
|
+
printMode,
|
|
68
|
+
alwaysShowCorrect
|
|
69
|
+
} = config || {};
|
|
120
70
|
if (config && expression) {
|
|
121
|
-
|
|
122
|
-
|
|
71
|
+
const modelExpression = expression;
|
|
123
72
|
if (state.showCorrect) {
|
|
124
73
|
return responses && responses.length && responses[0].answer;
|
|
125
74
|
}
|
|
126
|
-
|
|
127
|
-
var answerBlocks = 1; // assume one at least
|
|
75
|
+
let answerBlocks = 1; // assume one at least
|
|
128
76
|
// build out local state model using responses declared in expression
|
|
129
77
|
|
|
130
78
|
return (modelExpression || '').replace(REGEX, function () {
|
|
131
|
-
|
|
132
|
-
|
|
79
|
+
const answer = state.session.answers[`r${answerBlocks}`];
|
|
133
80
|
if (printMode && !alwaysShowCorrect) {
|
|
134
|
-
|
|
135
|
-
return
|
|
81
|
+
const blankSpace = '\\ \\ '.repeat(30) + '\\newline ';
|
|
82
|
+
return `\\MathQuillMathField[r${answerBlocks++}]{${blankSpace.repeat(3)}}`;
|
|
136
83
|
}
|
|
137
|
-
|
|
138
84
|
if (disabled) {
|
|
139
|
-
return
|
|
85
|
+
return `\\embed{answerBlock}[r${answerBlocks++}]`;
|
|
140
86
|
}
|
|
141
|
-
|
|
142
|
-
return "\\MathQuillMathField[r".concat(answerBlocks++, "]{").concat(answer && answer.value || '', "}");
|
|
87
|
+
return `\\MathQuillMathField[r${answerBlocks++}]{${answer && answer.value || ''}}`;
|
|
143
88
|
}).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
|
|
144
89
|
}
|
|
145
90
|
}
|
|
146
|
-
|
|
147
91
|
function parseAnswers(session, model) {
|
|
148
|
-
|
|
149
|
-
|
|
92
|
+
const answers = {};
|
|
150
93
|
if (model.config && model.config.expression) {
|
|
151
|
-
|
|
94
|
+
let answerBlocks = 1; // assume one at least
|
|
152
95
|
// build out local state model using responses declared in expression
|
|
153
96
|
|
|
154
|
-
(model.config.expression || '').replace(REGEX,
|
|
155
|
-
answers[
|
|
156
|
-
value: session && session.answers && session.answers[
|
|
97
|
+
(model.config.expression || '').replace(REGEX, () => {
|
|
98
|
+
answers[`r${answerBlocks}`] = {
|
|
99
|
+
value: session && session.answers && session.answers[`r${answerBlocks}`] && session.answers[`r${answerBlocks}`].value || ''
|
|
157
100
|
};
|
|
158
101
|
answerBlocks += 1;
|
|
159
102
|
});
|
|
160
103
|
}
|
|
161
|
-
|
|
162
104
|
return answers;
|
|
163
105
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
showCorrect = _this$state.showCorrect;
|
|
182
|
-
var answers = session.answers;
|
|
183
|
-
|
|
184
|
-
if (_this.root && model.disabled && !showCorrect) {
|
|
185
|
-
Object.keys(answers).forEach(function (answerId) {
|
|
186
|
-
var el = _this.root.querySelector("#".concat(answerId));
|
|
187
|
-
|
|
188
|
-
var indexEl = _this.root.querySelector("#".concat(answerId, "Index")); // const correct = model.correctness && model.correctness.correct;
|
|
189
|
-
|
|
106
|
+
class Main extends _react.default.Component {
|
|
107
|
+
constructor(props) {
|
|
108
|
+
super(props);
|
|
109
|
+
(0, _defineProperty2.default)(this, "handleAnswerBlockDomUpdate", () => {
|
|
110
|
+
const {
|
|
111
|
+
model
|
|
112
|
+
} = this.props;
|
|
113
|
+
const {
|
|
114
|
+
session,
|
|
115
|
+
showCorrect
|
|
116
|
+
} = this.state;
|
|
117
|
+
const answers = session.answers;
|
|
118
|
+
if (this.root && model.disabled && !showCorrect) {
|
|
119
|
+
Object.keys(answers).forEach(answerId => {
|
|
120
|
+
const el = this.root.querySelector(`#${answerId}`);
|
|
121
|
+
const indexEl = this.root.querySelector(`#${answerId}Index`);
|
|
122
|
+
// const correct = model.correctness && model.correctness.correct;
|
|
190
123
|
|
|
191
124
|
if (el) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var answer = answers[answerId];
|
|
125
|
+
let MQ = _mathquill.default.getInterface(2);
|
|
126
|
+
const answer = answers[answerId];
|
|
195
127
|
el.textContent = answer && answer.value || '';
|
|
196
|
-
|
|
197
|
-
|
|
128
|
+
if (!model.view) {
|
|
129
|
+
// for now, we're not going to be showing individual response correctness
|
|
198
130
|
// TODO re-attach the classes once we are
|
|
199
131
|
// el.parentElement.parentElement.classList.add(
|
|
200
|
-
// correct ?
|
|
132
|
+
// correct ? 'correct' : 'incorrect'
|
|
201
133
|
// );
|
|
202
134
|
} else {
|
|
203
|
-
el.parentElement.parentElement.classList.remove(
|
|
204
|
-
el.parentElement.parentElement.classList.remove(
|
|
135
|
+
el.parentElement.parentElement.classList.remove('correct');
|
|
136
|
+
el.parentElement.parentElement.classList.remove('incorrect');
|
|
205
137
|
}
|
|
138
|
+
MQ.StaticMath(el);
|
|
206
139
|
|
|
207
|
-
|
|
140
|
+
// For now, we're not going to be indexing response blocks
|
|
208
141
|
// TODO go back to indexing once we support individual response correctness
|
|
209
142
|
// indexEl.textContent = `R${idx + 1}`;
|
|
210
|
-
|
|
211
143
|
indexEl.textContent = 'R';
|
|
212
144
|
}
|
|
213
145
|
});
|
|
214
146
|
}
|
|
215
|
-
|
|
216
|
-
(0, _mathRendering.renderMath)(_this.root);
|
|
147
|
+
(0, _mathRendering.renderMath)(this.root);
|
|
217
148
|
});
|
|
218
|
-
(0, _defineProperty2
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (_this.root) {
|
|
149
|
+
(0, _defineProperty2.default)(this, "updateAria", () => {
|
|
150
|
+
if (this.root) {
|
|
222
151
|
// Update aria-hidden for .mq-selectable elements
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
selectableElements.forEach(function (elem) {
|
|
226
|
-
return elem.setAttribute('aria-hidden', 'true');
|
|
227
|
-
}); // Update aria-label for textarea elements and add aria-describedby
|
|
228
|
-
|
|
229
|
-
var textareaElements = _this.root.querySelectorAll('textarea');
|
|
230
|
-
|
|
231
|
-
textareaElements.forEach(function (elem, index) {
|
|
232
|
-
elem.setAttribute('aria-label', 'Enter answer.'); // Create a unique id for each instructions element
|
|
152
|
+
const selectableElements = this.root.querySelectorAll('.mq-selectable');
|
|
153
|
+
selectableElements.forEach(elem => elem.setAttribute('aria-hidden', 'true'));
|
|
233
154
|
|
|
234
|
-
|
|
155
|
+
// Update aria-label for textarea elements and add aria-describedby
|
|
156
|
+
const textareaElements = this.root.querySelectorAll('textarea');
|
|
157
|
+
textareaElements.forEach((elem, index) => {
|
|
158
|
+
elem.setAttribute('aria-label', 'Enter answer.');
|
|
235
159
|
|
|
236
|
-
|
|
160
|
+
// Create a unique id for each instructions element
|
|
161
|
+
const instructionsId = `instructions-${index}`;
|
|
237
162
|
|
|
163
|
+
// Find the parent element that contains the textarea
|
|
164
|
+
const parent = elem.closest('.mq-textarea');
|
|
238
165
|
if (parent) {
|
|
239
166
|
// Create or find the instructions element within the parent
|
|
240
|
-
|
|
241
|
-
|
|
167
|
+
let instructionsElement = parent.querySelector(`#${instructionsId}`);
|
|
242
168
|
if (!instructionsElement) {
|
|
243
169
|
instructionsElement = document.createElement('span');
|
|
244
170
|
instructionsElement.id = instructionsId;
|
|
245
|
-
instructionsElement.className =
|
|
171
|
+
instructionsElement.className = 'sr-only';
|
|
246
172
|
instructionsElement.textContent = 'This field supports both keypad and keyboard input. Use the keyboard to access and interact with the on-screen math keypad, which accepts LaTeX markup. Use the down arrow key to open the keypad and navigate its buttons. Use the escape key to close the keypad and return to the input field.';
|
|
247
173
|
parent.insertBefore(instructionsElement, elem);
|
|
248
174
|
}
|
|
249
|
-
|
|
250
175
|
elem.setAttribute('aria-describedby', instructionsId);
|
|
251
176
|
}
|
|
252
177
|
});
|
|
253
178
|
}
|
|
254
179
|
});
|
|
255
|
-
(0, _defineProperty2
|
|
256
|
-
setTimeout(
|
|
257
|
-
|
|
258
|
-
|
|
180
|
+
(0, _defineProperty2.default)(this, "focusFirstKeypadElement", () => {
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
const keypadElement = document.querySelector('[data-keypad]');
|
|
259
183
|
if (keypadElement) {
|
|
260
|
-
|
|
261
|
-
|
|
184
|
+
const firstButton = keypadElement.querySelector("button, [role='button']");
|
|
262
185
|
if (firstButton) {
|
|
263
186
|
firstButton.focus();
|
|
264
187
|
}
|
|
265
188
|
}
|
|
266
189
|
}, 0);
|
|
267
190
|
});
|
|
268
|
-
(0, _defineProperty2
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
191
|
+
(0, _defineProperty2.default)(this, "handleKeyDown", (event, id) => {
|
|
192
|
+
const isTrigerredFromActualPieElement = isChildOfCurrentPieElement(event.target, this.root);
|
|
193
|
+
const isAnswerInputFocused = this.mqStatic && this.mqStatic.inputRef?.current ? this.mqStatic.inputRef?.current.contains(document.activeElement) : document.activeElement?.getAttribute('aria-label') === 'Enter answer.';
|
|
194
|
+
const {
|
|
195
|
+
key,
|
|
196
|
+
type
|
|
197
|
+
} = event;
|
|
198
|
+
const isClickOrTouchEvent = type === 'click' || type === 'touchstart';
|
|
277
199
|
if (isAnswerInputFocused && (key === 'ArrowDown' || isClickOrTouchEvent)) {
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
_this.setState({
|
|
200
|
+
if (this.state.activeAnswerBlock !== id && isTrigerredFromActualPieElement) {
|
|
201
|
+
this.cleanupKeyDownListener();
|
|
202
|
+
this.setState({
|
|
282
203
|
activeAnswerBlock: id
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
|
|
204
|
+
}, () => {
|
|
205
|
+
this.onSubFieldFocus(id);
|
|
286
206
|
if (key === 'ArrowDown') {
|
|
287
|
-
|
|
207
|
+
this.focusFirstKeypadElement();
|
|
288
208
|
}
|
|
289
209
|
});
|
|
290
210
|
}
|
|
291
211
|
} else if (event.key === 'Escape') {
|
|
292
|
-
|
|
212
|
+
this.setState({
|
|
293
213
|
activeAnswerBlock: ''
|
|
294
214
|
});
|
|
295
215
|
}
|
|
296
216
|
});
|
|
297
|
-
(0, _defineProperty2
|
|
298
|
-
if (!
|
|
299
|
-
|
|
300
|
-
|
|
217
|
+
(0, _defineProperty2.default)(this, "onSubFieldFocus", id => {
|
|
218
|
+
if (!this.handleEvent) {
|
|
219
|
+
this.handleEvent = event => {
|
|
220
|
+
this.handleKeyDown(event, id);
|
|
301
221
|
};
|
|
302
|
-
|
|
303
|
-
document.addEventListener('
|
|
304
|
-
document.addEventListener('
|
|
305
|
-
document.addEventListener('touchstart', _this.handleEvent);
|
|
222
|
+
document.addEventListener('keydown', this.handleEvent);
|
|
223
|
+
document.addEventListener('click', this.handleEvent);
|
|
224
|
+
document.addEventListener('touchstart', this.handleEvent);
|
|
306
225
|
}
|
|
307
226
|
});
|
|
308
|
-
(0, _defineProperty2
|
|
309
|
-
if (
|
|
310
|
-
document.removeEventListener('keydown',
|
|
311
|
-
document.removeEventListener('click',
|
|
312
|
-
document.removeEventListener('touchstart',
|
|
313
|
-
|
|
227
|
+
(0, _defineProperty2.default)(this, "cleanupKeyDownListener", () => {
|
|
228
|
+
if (this.handleEvent) {
|
|
229
|
+
document.removeEventListener('keydown', this.handleEvent);
|
|
230
|
+
document.removeEventListener('click', this.handleEvent);
|
|
231
|
+
document.removeEventListener('touchstart', this.handleEvent);
|
|
232
|
+
this.handleEvent = null;
|
|
314
233
|
}
|
|
315
234
|
});
|
|
316
|
-
(0, _defineProperty2
|
|
317
|
-
(0, _defineProperty2
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}, _this.callOnSessionChange);
|
|
235
|
+
(0, _defineProperty2.default)(this, "onDone", () => {});
|
|
236
|
+
(0, _defineProperty2.default)(this, "onSimpleResponseChange", response => {
|
|
237
|
+
this.setState(state => ({
|
|
238
|
+
session: {
|
|
239
|
+
...state.session,
|
|
240
|
+
response
|
|
241
|
+
}
|
|
242
|
+
}), this.callOnSessionChange);
|
|
325
243
|
});
|
|
326
|
-
(0, _defineProperty2
|
|
244
|
+
(0, _defineProperty2.default)(this, "toNodeData", data => {
|
|
327
245
|
if (!data) {
|
|
328
246
|
return;
|
|
329
247
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
248
|
+
const {
|
|
249
|
+
type,
|
|
250
|
+
value
|
|
251
|
+
} = data;
|
|
334
252
|
if (type === 'command' || type === 'cursor') {
|
|
335
253
|
return data;
|
|
336
254
|
} else if (type === 'answer') {
|
|
337
|
-
return
|
|
338
|
-
type: 'answer'
|
|
339
|
-
|
|
255
|
+
return {
|
|
256
|
+
type: 'answer',
|
|
257
|
+
...data
|
|
258
|
+
};
|
|
340
259
|
} else if (value === 'clear') {
|
|
341
260
|
return {
|
|
342
261
|
type: 'clear'
|
|
@@ -344,123 +263,114 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
344
263
|
} else {
|
|
345
264
|
return {
|
|
346
265
|
type: 'write',
|
|
347
|
-
value
|
|
266
|
+
value
|
|
348
267
|
};
|
|
349
268
|
}
|
|
350
269
|
});
|
|
351
|
-
(0, _defineProperty2
|
|
352
|
-
|
|
270
|
+
(0, _defineProperty2.default)(this, "setInput", input => {
|
|
271
|
+
this.input = input;
|
|
353
272
|
});
|
|
354
|
-
(0, _defineProperty2
|
|
355
|
-
|
|
356
|
-
|
|
273
|
+
(0, _defineProperty2.default)(this, "onClick", data => {
|
|
274
|
+
const c = this.toNodeData(data);
|
|
357
275
|
if (c.type === 'clear') {
|
|
358
|
-
|
|
276
|
+
this.input.clear();
|
|
359
277
|
} else if (c.type === 'command') {
|
|
360
278
|
if (Array.isArray(c.value)) {
|
|
361
|
-
c.value.forEach(
|
|
362
|
-
|
|
279
|
+
c.value.forEach(vv => {
|
|
280
|
+
this.input.cmd(vv);
|
|
363
281
|
});
|
|
364
282
|
} else {
|
|
365
|
-
|
|
283
|
+
this.input.cmd(c.value);
|
|
366
284
|
}
|
|
367
285
|
} else if (c.type === 'cursor') {
|
|
368
|
-
|
|
286
|
+
this.input.keystroke(c.value);
|
|
369
287
|
} else {
|
|
370
|
-
|
|
288
|
+
this.input.write(c.value);
|
|
371
289
|
}
|
|
372
|
-
|
|
373
|
-
_this.input.focus();
|
|
290
|
+
this.input.focus();
|
|
374
291
|
});
|
|
375
|
-
(0, _defineProperty2
|
|
376
|
-
|
|
377
|
-
|
|
292
|
+
(0, _defineProperty2.default)(this, "callOnSessionChange", () => {
|
|
293
|
+
const {
|
|
294
|
+
onSessionChange
|
|
295
|
+
} = this.props;
|
|
378
296
|
if (onSessionChange) {
|
|
379
|
-
onSessionChange(
|
|
297
|
+
onSessionChange(this.state.session);
|
|
380
298
|
}
|
|
381
299
|
});
|
|
382
|
-
(0, _defineProperty2
|
|
383
|
-
|
|
300
|
+
(0, _defineProperty2.default)(this, "toggleShowCorrect", show => {
|
|
301
|
+
this.setState({
|
|
384
302
|
showCorrect: show
|
|
385
|
-
},
|
|
303
|
+
}, this.handleAnswerBlockDomUpdate);
|
|
386
304
|
});
|
|
387
|
-
(0, _defineProperty2
|
|
305
|
+
(0, _defineProperty2.default)(this, "subFieldChanged", (name, subfieldValue) => {
|
|
388
306
|
(0, _mathInput.updateSpans)();
|
|
389
|
-
|
|
390
307
|
if (name) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
308
|
+
this.setState(state => ({
|
|
309
|
+
session: {
|
|
310
|
+
...state.session,
|
|
311
|
+
completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
|
|
312
|
+
answers: {
|
|
313
|
+
...state.session.answers,
|
|
314
|
+
[name]: {
|
|
396
315
|
value: subfieldValue
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
},
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}), this.callOnSessionChange);
|
|
401
320
|
}
|
|
402
321
|
});
|
|
403
|
-
(0, _defineProperty2
|
|
404
|
-
|
|
405
|
-
|
|
322
|
+
(0, _defineProperty2.default)(this, "getFieldName", (changeField, fields) => {
|
|
323
|
+
const {
|
|
324
|
+
answers
|
|
325
|
+
} = this.state.session;
|
|
406
326
|
if (Object.keys(answers || {}).length) {
|
|
407
|
-
|
|
408
|
-
return keys.find(
|
|
409
|
-
|
|
327
|
+
const keys = Object.keys(answers);
|
|
328
|
+
return keys.find(k => {
|
|
329
|
+
const tf = fields[k];
|
|
410
330
|
return tf && tf.id == changeField.id;
|
|
411
331
|
});
|
|
412
332
|
}
|
|
413
333
|
});
|
|
414
|
-
(0, _defineProperty2
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
334
|
+
(0, _defineProperty2.default)(this, "onBlur", e => {
|
|
335
|
+
const {
|
|
336
|
+
relatedTarget,
|
|
337
|
+
currentTarget
|
|
338
|
+
} = e || {};
|
|
420
339
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
340
|
+
// our keypad is in tooltip
|
|
341
|
+
// in this way we see if event was triggered from the keypad
|
|
342
|
+
const isKeypadOpen = currentTarget && currentTarget.closest('[role=tooltip]');
|
|
343
|
+
function getParentWithRoleTooltip(element, depth = 0) {
|
|
425
344
|
// only run this max 16 times
|
|
426
345
|
if (!element || depth >= 16) return null;
|
|
427
|
-
|
|
346
|
+
const parent = element.offsetParent;
|
|
428
347
|
if (!parent) return null;
|
|
429
|
-
|
|
430
348
|
if (parent.getAttribute('role') === 'tooltip') {
|
|
431
349
|
return parent;
|
|
432
350
|
}
|
|
433
|
-
|
|
434
351
|
return getParentWithRoleTooltip(parent, depth + 1);
|
|
435
352
|
}
|
|
436
|
-
|
|
437
|
-
function getDeepChildDataKeypad(element) {
|
|
438
|
-
var _element$children;
|
|
439
|
-
|
|
440
|
-
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
353
|
+
function getDeepChildDataKeypad(element, depth = 0) {
|
|
441
354
|
// only run this max 4 times
|
|
442
355
|
if (!element || depth >= 4) return null;
|
|
443
|
-
|
|
356
|
+
const child = element?.children?.[0];
|
|
444
357
|
if (!child) return null;
|
|
445
|
-
|
|
446
358
|
if (child.attributes && child.attributes['data-keypad']) {
|
|
447
359
|
return child;
|
|
448
360
|
}
|
|
449
|
-
|
|
450
361
|
return getDeepChildDataKeypad(child, depth + 1);
|
|
451
362
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (!relatedTarget || !currentTarget || !(childWithDataKeypad !== null && childWithDataKeypad !== void 0 && childWithDataKeypad.attributes['data-keypad'])) {
|
|
363
|
+
const parentWithTooltipRole = getParentWithRoleTooltip(relatedTarget);
|
|
364
|
+
const childWithDataKeypad = parentWithTooltipRole ? getDeepChildDataKeypad(parentWithTooltipRole) : null;
|
|
365
|
+
if (!relatedTarget || !currentTarget || !childWithDataKeypad?.attributes['data-keypad']) {
|
|
457
366
|
// if event was trigered from the keypad, avoid closing the keypad
|
|
458
367
|
if (!isKeypadOpen) {
|
|
459
|
-
|
|
368
|
+
this.setState({
|
|
460
369
|
activeAnswerBlock: ''
|
|
461
370
|
});
|
|
462
371
|
}
|
|
463
|
-
}
|
|
372
|
+
}
|
|
373
|
+
// else {
|
|
464
374
|
// // Just for debugging purpose:
|
|
465
375
|
// console.log('\n\nNew childWithDataKeypad', childWithDataKeypad);
|
|
466
376
|
//
|
|
@@ -472,655 +382,640 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
472
382
|
// console.log('What was being used', relatedTarget?.offsetParent?.children[0]);
|
|
473
383
|
// }
|
|
474
384
|
// }
|
|
475
|
-
|
|
476
385
|
});
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
session:
|
|
386
|
+
const {
|
|
387
|
+
model: _model,
|
|
388
|
+
session: _session
|
|
389
|
+
} = props;
|
|
390
|
+
const _answers = parseAnswers(_session, _model);
|
|
391
|
+
this.state = {
|
|
392
|
+
session: {
|
|
393
|
+
...props.session,
|
|
484
394
|
answers: _answers
|
|
485
|
-
}
|
|
395
|
+
},
|
|
486
396
|
activeAnswerBlock: '',
|
|
487
|
-
showCorrect:
|
|
488
|
-
tooltipContainerRef: /*#__PURE__*/_react
|
|
397
|
+
showCorrect: this.props.model.config.alwaysShowCorrect || false,
|
|
398
|
+
tooltipContainerRef: /*#__PURE__*/_react.default.createRef()
|
|
489
399
|
};
|
|
490
|
-
return _this;
|
|
491
400
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (typeof window !== 'undefined') {
|
|
499
|
-
var MQ = _mathquill["default"].getInterface(2);
|
|
500
|
-
|
|
501
|
-
if (!registered) {
|
|
502
|
-
MQ.registerEmbed('answerBlock', function (data) {
|
|
503
|
-
return {
|
|
504
|
-
htmlString: "<div class=\"".concat(classes.blockContainer, "\">\n <div class=\"").concat(classes.blockResponse, "\" id=\"").concat(data, "Index\">R</div>\n <div class=\"").concat(classes.blockMath, "\">\n <span id=\"").concat(data, "\"></span>\n </div>\n </div>"),
|
|
505
|
-
text: function text() {
|
|
506
|
-
return 'text';
|
|
507
|
-
},
|
|
508
|
-
latex: function latex() {
|
|
509
|
-
return "\\embed{answerBlock}[".concat(data, "]");
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
});
|
|
513
|
-
registered = true;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}, {
|
|
518
|
-
key: "countResponseOccurrences",
|
|
519
|
-
value: function countResponseOccurrences(expression) {
|
|
520
|
-
var pattern = /\{\{response\}\}/g;
|
|
521
|
-
var matches = expression === null || expression === void 0 ? void 0 : expression.match(pattern);
|
|
522
|
-
return matches ? matches.length : 0;
|
|
523
|
-
}
|
|
524
|
-
}, {
|
|
525
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
526
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
527
|
-
var _this2 = this;
|
|
528
|
-
|
|
529
|
-
var config = this.props.model.config;
|
|
530
|
-
|
|
531
|
-
var _ref4 = nextProps.model || {},
|
|
532
|
-
_ref4$config = _ref4.config,
|
|
533
|
-
nextConfig = _ref4$config === void 0 ? {} : _ref4$config;
|
|
534
|
-
|
|
535
|
-
var session = this.props.session;
|
|
536
|
-
|
|
537
|
-
var _ref5 = nextProps || {},
|
|
538
|
-
_ref5$session = _ref5.session,
|
|
539
|
-
nextSession = _ref5$session === void 0 ? {} : _ref5$session; // in case session props changed in parent, we need to catch this and update local state
|
|
540
|
-
// example: when env is changing in pieoneer
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (session && nextSession && !(0, _isEqual["default"])(session.answers, nextSession.answers)) {
|
|
544
|
-
this.setState({
|
|
545
|
-
session: _objectSpread(_objectSpread({}, nextSession), {}, {
|
|
546
|
-
answers: parseAnswers(nextSession, this.props.model)
|
|
547
|
-
})
|
|
548
|
-
});
|
|
549
|
-
} // check if the note is the default one for prev language and change to the default one for new language
|
|
550
|
-
// this check is necessary in order to diferanciate between default and authour defined note
|
|
551
|
-
// and only change between languages for default ones
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (config.note && config.language && config.language !== nextConfig.language && config.note === translator.t('mathInline.primaryCorrectWithAlternates', {
|
|
555
|
-
lng: config.language
|
|
556
|
-
})) {
|
|
557
|
-
config.note = translator.t('mathInline.primaryCorrectWithAlternates', {
|
|
558
|
-
lng: nextConfig.language
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
if (config.env && config.env.mode !== 'evaluate' || nextConfig.env && nextConfig.env.mode !== 'evaluate') {
|
|
563
|
-
this.setState(_objectSpread(_objectSpread({}, this.state.session), {}, {
|
|
564
|
-
showCorrect: false
|
|
565
|
-
}));
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (nextConfig.alwaysShowCorrect) {
|
|
569
|
-
this.setState({
|
|
570
|
-
showCorrect: true
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
if (this.countResponseOccurrences(config.expression) < this.countResponseOccurrences(nextConfig.expression)) {
|
|
575
|
-
setTimeout(function () {
|
|
576
|
-
return _this2.updateAria();
|
|
577
|
-
}, 100);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
if (config && config.responses && config.responses.length !== nextConfig.responses.length || !config && nextConfig && nextConfig.responses || config && nextConfig && config.expression !== nextConfig.expression) {
|
|
581
|
-
var newAnswers = {};
|
|
582
|
-
var answers = this.state.session.answers;
|
|
583
|
-
var answerBlocks = 1; // assume one at least
|
|
584
|
-
// build out local state model using responses declared in expression
|
|
585
|
-
|
|
586
|
-
(nextConfig.expression || '').replace(REGEX, function () {
|
|
587
|
-
newAnswers["r".concat(answerBlocks)] = {
|
|
588
|
-
value: answers && answers["r".concat(answerBlocks)] && answers["r".concat(answerBlocks)].value || ''
|
|
589
|
-
};
|
|
590
|
-
answerBlocks++;
|
|
591
|
-
});
|
|
592
|
-
this.setState(function (state) {
|
|
401
|
+
UNSAFE_componentWillMount() {
|
|
402
|
+
if (typeof window !== 'undefined') {
|
|
403
|
+
let MQ = _mathquill.default.getInterface(2);
|
|
404
|
+
if (!registered) {
|
|
405
|
+
MQ.registerEmbed('answerBlock', data => {
|
|
406
|
+
const classNames = getBlockClassNames();
|
|
593
407
|
return {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
408
|
+
htmlString: `<div class="${classNames.blockContainer}">
|
|
409
|
+
<div class="${classNames.blockResponse}" id="${data}Index">R</div>
|
|
410
|
+
<div class="${classNames.blockMath}">
|
|
411
|
+
<span id="${data}"></span>
|
|
412
|
+
</div>
|
|
413
|
+
</div>`,
|
|
414
|
+
text: () => 'text',
|
|
415
|
+
latex: () => `\\embed{answerBlock}[${data}]`
|
|
598
416
|
};
|
|
599
|
-
}
|
|
417
|
+
});
|
|
418
|
+
registered = true;
|
|
600
419
|
}
|
|
601
420
|
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
421
|
+
}
|
|
422
|
+
countResponseOccurrences(expression) {
|
|
423
|
+
const pattern = /\{\{response\}\}/g;
|
|
424
|
+
const matches = expression?.match(pattern);
|
|
425
|
+
return matches ? matches.length : 0;
|
|
426
|
+
}
|
|
427
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
428
|
+
const {
|
|
429
|
+
config
|
|
430
|
+
} = this.props.model;
|
|
431
|
+
const {
|
|
432
|
+
config: nextConfig = {}
|
|
433
|
+
} = nextProps.model || {};
|
|
434
|
+
const {
|
|
435
|
+
session
|
|
436
|
+
} = this.props;
|
|
437
|
+
const {
|
|
438
|
+
session: nextSession = {}
|
|
439
|
+
} = nextProps || {};
|
|
440
|
+
|
|
441
|
+
// in case session props changed in parent, we need to catch this and update local state
|
|
442
|
+
// example: when env is changing in pieoneer
|
|
443
|
+
if (session && nextSession && !(0, _lodashEs.isEqual)(session.answers, nextSession.answers)) {
|
|
444
|
+
this.setState({
|
|
445
|
+
session: {
|
|
446
|
+
...nextSession,
|
|
447
|
+
answers: parseAnswers(nextSession, this.props.model)
|
|
448
|
+
}
|
|
449
|
+
});
|
|
608
450
|
}
|
|
609
|
-
}, {
|
|
610
|
-
key: "componentDidMount",
|
|
611
|
-
value: function componentDidMount() {
|
|
612
|
-
var _this3 = this;
|
|
613
451
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
452
|
+
// check if the note is the default one for prev language and change to the default one for new language
|
|
453
|
+
// this check is necessary in order to diferanciate between default and authour defined note
|
|
454
|
+
// and only change between languages for default ones
|
|
455
|
+
if (config.note && config.language && config.language !== nextConfig.language && config.note === translator.t('mathInline.primaryCorrectWithAlternates', {
|
|
456
|
+
lng: config.language
|
|
457
|
+
})) {
|
|
458
|
+
config.note = translator.t('mathInline.primaryCorrectWithAlternates', {
|
|
459
|
+
lng: nextConfig.language
|
|
460
|
+
});
|
|
619
461
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
this.handleAnswerBlockDomUpdate();
|
|
626
|
-
var prevResponseType = (_prevProps$model = prevProps.model) === null || _prevProps$model === void 0 ? void 0 : (_prevProps$model$conf = _prevProps$model.config) === null || _prevProps$model$conf === void 0 ? void 0 : _prevProps$model$conf.responseType;
|
|
627
|
-
var currentResponseType = (_this$props$model = this.props.model) === null || _this$props$model === void 0 ? void 0 : (_this$props$model$con = _this$props$model.config) === null || _this$props$model$con === void 0 ? void 0 : _this$props$model$con.responseType;
|
|
628
|
-
|
|
629
|
-
if (prevResponseType !== currentResponseType) {
|
|
630
|
-
this.updateAria();
|
|
631
|
-
}
|
|
462
|
+
if (config.env && config.env.mode !== 'evaluate' || nextConfig.env && nextConfig.env.mode !== 'evaluate') {
|
|
463
|
+
this.setState({
|
|
464
|
+
...this.state.session,
|
|
465
|
+
showCorrect: false
|
|
466
|
+
});
|
|
632
467
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
this.cleanupKeyDownListener();
|
|
638
|
-
}
|
|
468
|
+
if (nextConfig.alwaysShowCorrect) {
|
|
469
|
+
this.setState({
|
|
470
|
+
showCorrect: true
|
|
471
|
+
});
|
|
639
472
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
value: function setTooltipRef(ref) {
|
|
643
|
-
// Safari Hack: https://stackoverflow.com/a/42764495/5757635
|
|
644
|
-
setTimeout(function () {
|
|
645
|
-
if (ref && IS_SAFARI) {
|
|
646
|
-
var div = document.querySelector("[role='tooltip']");
|
|
647
|
-
|
|
648
|
-
if (div) {
|
|
649
|
-
var el = div.firstChild;
|
|
650
|
-
el.setAttribute('tabindex', '-1');
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}, 1);
|
|
473
|
+
if (this.countResponseOccurrences(config.expression) < this.countResponseOccurrences(nextConfig.expression)) {
|
|
474
|
+
setTimeout(() => this.updateAria(), 100);
|
|
654
475
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
correctness = _ref6.correctness,
|
|
673
|
-
disabled = _ref6.disabled,
|
|
674
|
-
extraCSSRules = _ref6.extraCSSRules,
|
|
675
|
-
view = _ref6.view,
|
|
676
|
-
teacherInstructions = _ref6.teacherInstructions,
|
|
677
|
-
rationale = _ref6.rationale,
|
|
678
|
-
feedback = _ref6.feedback,
|
|
679
|
-
animationsDisabled = _ref6.animationsDisabled,
|
|
680
|
-
printMode = _ref6.printMode,
|
|
681
|
-
alwaysShowCorrect = _ref6.alwaysShowCorrect,
|
|
682
|
-
language = _ref6.language;
|
|
683
|
-
|
|
684
|
-
if (!config) {
|
|
685
|
-
return null;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
var _ref7 = config || {},
|
|
689
|
-
showNote = _ref7.showNote,
|
|
690
|
-
note = _ref7.note,
|
|
691
|
-
prompt = _ref7.prompt,
|
|
692
|
-
responses = _ref7.responses,
|
|
693
|
-
responseType = _ref7.responseType,
|
|
694
|
-
equationEditor = _ref7.equationEditor,
|
|
695
|
-
customKeys = _ref7.customKeys,
|
|
696
|
-
id = _ref7.id,
|
|
697
|
-
_ref7$env = _ref7.env;
|
|
698
|
-
|
|
699
|
-
_ref7$env = _ref7$env === void 0 ? {} : _ref7$env;
|
|
700
|
-
var mode = _ref7$env.mode,
|
|
701
|
-
role = _ref7$env.role;
|
|
702
|
-
var displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;
|
|
703
|
-
var emptyResponse = (0, _isEmpty["default"])(responses);
|
|
704
|
-
var showCorrectAnswerToggle = !emptyResponse && correctness && correctness.correctness !== 'correct';
|
|
705
|
-
var tooltipModeEnabled = disabled && correctness;
|
|
706
|
-
var additionalKeys = generateAdditionalKeys(customKeys);
|
|
707
|
-
var correct = correctness && correctness.correct;
|
|
708
|
-
var staticLatex = prepareForStatic(model, this.state) || '';
|
|
709
|
-
var viewMode = disabled && !correctness;
|
|
710
|
-
var studentPrintMode = printMode && !alwaysShowCorrect;
|
|
711
|
-
var showRationale = rationale && ((0, _renderUi.hasText)(rationale) || (0, _renderUi.hasMedia)(rationale));
|
|
712
|
-
var showTeacherInstructions = teacherInstructions && ((0, _renderUi.hasText)(teacherInstructions) || (0, _renderUi.hasMedia)(teacherInstructions));
|
|
713
|
-
|
|
714
|
-
var printView = /*#__PURE__*/_react["default"].createElement("div", {
|
|
715
|
-
className: classes.printContainer
|
|
716
|
-
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
717
|
-
className: classes["static"],
|
|
718
|
-
ref: function ref(mqStatic) {
|
|
719
|
-
if (mqStatic) _this4.mqStatic = mqStatic;
|
|
720
|
-
},
|
|
721
|
-
latex: staticLatex,
|
|
722
|
-
onSubFieldChange: this.subFieldChanged,
|
|
723
|
-
getFieldName: this.getFieldName,
|
|
724
|
-
setInput: this.setInput,
|
|
725
|
-
onSubFieldFocus: this.onSubFieldFocus,
|
|
726
|
-
onBlur: this.onBlur
|
|
727
|
-
}));
|
|
728
|
-
|
|
729
|
-
var midContent = /*#__PURE__*/_react["default"].createElement("div", {
|
|
730
|
-
className: classes.main
|
|
731
|
-
}, mode === 'gather' && /*#__PURE__*/_react["default"].createElement("h2", {
|
|
732
|
-
className: classes.srOnly
|
|
733
|
-
}, "Math Equation Response Question"), viewMode && showTeacherInstructions && (!animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
734
|
-
className: classes.collapsible,
|
|
735
|
-
labels: {
|
|
736
|
-
hidden: 'Show Teacher Instructions',
|
|
737
|
-
visible: 'Hide Teacher Instructions'
|
|
738
|
-
}
|
|
739
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
740
|
-
dangerouslySetInnerHTML: {
|
|
741
|
-
__html: teacherInstructions
|
|
476
|
+
if (config && config.responses && config.responses.length !== nextConfig.responses.length || !config && nextConfig && nextConfig.responses || config && nextConfig && config.expression !== nextConfig.expression) {
|
|
477
|
+
const newAnswers = {};
|
|
478
|
+
const answers = this.state.session.answers;
|
|
479
|
+
let answerBlocks = 1; // assume one at least
|
|
480
|
+
|
|
481
|
+
// build out local state model using responses declared in expression
|
|
482
|
+
(nextConfig.expression || '').replace(REGEX, () => {
|
|
483
|
+
newAnswers[`r${answerBlocks}`] = {
|
|
484
|
+
value: answers && answers[`r${answerBlocks}`] && answers[`r${answerBlocks}`].value || ''
|
|
485
|
+
};
|
|
486
|
+
answerBlocks++;
|
|
487
|
+
});
|
|
488
|
+
this.setState(state => ({
|
|
489
|
+
session: {
|
|
490
|
+
...state.session,
|
|
491
|
+
completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
|
|
492
|
+
answers: newAnswers
|
|
742
493
|
}
|
|
743
|
-
})
|
|
744
|
-
|
|
745
|
-
|
|
494
|
+
}), this.handleAnswerBlockDomUpdate);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
498
|
+
const sameModel = (0, _lodashEs.isEqual)(this.props.model, nextProps.model);
|
|
499
|
+
const sameState = (0, _lodashEs.isEqual)(this.state, nextState);
|
|
500
|
+
return !sameModel || !sameState;
|
|
501
|
+
}
|
|
502
|
+
componentDidMount() {
|
|
503
|
+
this.handleAnswerBlockDomUpdate();
|
|
504
|
+
this.updateAria();
|
|
505
|
+
setTimeout(() => (0, _mathRendering.renderMath)(this.root), 100);
|
|
506
|
+
}
|
|
507
|
+
componentDidUpdate(prevProps, prevState) {
|
|
508
|
+
this.handleAnswerBlockDomUpdate();
|
|
509
|
+
const prevResponseType = prevProps.model?.config?.responseType;
|
|
510
|
+
const currentResponseType = this.props.model?.config?.responseType;
|
|
511
|
+
if (prevResponseType !== currentResponseType) {
|
|
512
|
+
this.updateAria();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
componentWillUnmount() {
|
|
516
|
+
if (this.cleanupKeyDownListener) {
|
|
517
|
+
this.cleanupKeyDownListener();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
setTooltipRef(ref) {
|
|
521
|
+
// Safari Hack: https://stackoverflow.com/a/42764495/5757635
|
|
522
|
+
setTimeout(() => {
|
|
523
|
+
if (ref && IS_SAFARI) {
|
|
524
|
+
const div = document.querySelector("[role='tooltip']");
|
|
525
|
+
if (div) {
|
|
526
|
+
const el = div.firstChild;
|
|
527
|
+
el.setAttribute('tabindex', '-1');
|
|
746
528
|
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
529
|
+
}
|
|
530
|
+
}, 1);
|
|
531
|
+
}
|
|
532
|
+
render() {
|
|
533
|
+
const {
|
|
534
|
+
model
|
|
535
|
+
} = this.props;
|
|
536
|
+
const {
|
|
537
|
+
activeAnswerBlock,
|
|
538
|
+
showCorrect,
|
|
539
|
+
session,
|
|
540
|
+
tooltipContainerRef
|
|
541
|
+
} = this.state;
|
|
542
|
+
const {
|
|
543
|
+
config,
|
|
544
|
+
correctness,
|
|
545
|
+
disabled,
|
|
546
|
+
extraCSSRules,
|
|
547
|
+
view,
|
|
548
|
+
teacherInstructions,
|
|
549
|
+
rationale,
|
|
550
|
+
feedback,
|
|
551
|
+
animationsDisabled,
|
|
552
|
+
printMode,
|
|
553
|
+
alwaysShowCorrect,
|
|
554
|
+
language
|
|
555
|
+
} = model || {};
|
|
556
|
+
if (!config) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
const {
|
|
560
|
+
showNote,
|
|
561
|
+
note,
|
|
562
|
+
prompt,
|
|
563
|
+
responses,
|
|
564
|
+
responseType,
|
|
565
|
+
equationEditor,
|
|
566
|
+
customKeys,
|
|
567
|
+
id,
|
|
568
|
+
env: {
|
|
569
|
+
mode,
|
|
570
|
+
role
|
|
571
|
+
} = {}
|
|
572
|
+
} = config || {};
|
|
573
|
+
const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;
|
|
574
|
+
const emptyResponse = (0, _lodashEs.isEmpty)(responses);
|
|
575
|
+
const showCorrectAnswerToggle = !emptyResponse && correctness && correctness.correctness !== 'correct';
|
|
576
|
+
const tooltipModeEnabled = disabled && correctness;
|
|
577
|
+
const additionalKeys = generateAdditionalKeys(customKeys);
|
|
578
|
+
const correct = correctness && correctness.correct;
|
|
579
|
+
const staticLatex = prepareForStatic(model, this.state) || '';
|
|
580
|
+
const viewMode = disabled && !correctness;
|
|
581
|
+
const studentPrintMode = printMode && !alwaysShowCorrect;
|
|
582
|
+
const showRationale = rationale && ((0, _renderUi.hasText)(rationale) || (0, _renderUi.hasMedia)(rationale));
|
|
583
|
+
const showTeacherInstructions = teacherInstructions && ((0, _renderUi.hasText)(teacherInstructions) || (0, _renderUi.hasMedia)(teacherInstructions));
|
|
584
|
+
const printView = /*#__PURE__*/_react.default.createElement(PrintContainer, null, /*#__PURE__*/_react.default.createElement(_mathInput.mq.Static, {
|
|
585
|
+
className: "static-math",
|
|
586
|
+
ref: mqStatic => {
|
|
587
|
+
if (mqStatic) this.mqStatic = mqStatic;
|
|
588
|
+
},
|
|
589
|
+
latex: staticLatex,
|
|
590
|
+
onSubFieldChange: this.subFieldChanged,
|
|
591
|
+
getFieldName: this.getFieldName,
|
|
592
|
+
setInput: this.setInput,
|
|
593
|
+
onSubFieldFocus: this.onSubFieldFocus,
|
|
594
|
+
onBlur: this.onBlur
|
|
595
|
+
}));
|
|
596
|
+
const midContent = /*#__PURE__*/_react.default.createElement(MainContent, null, mode === 'gather' && /*#__PURE__*/_react.default.createElement(SrOnly, null, "Math Equation Response Question"), viewMode && showTeacherInstructions && (!animationsDisabled ? /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
597
|
+
labels: {
|
|
598
|
+
hidden: 'Show Teacher Instructions',
|
|
599
|
+
visible: 'Hide Teacher Instructions'
|
|
600
|
+
}
|
|
601
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
602
|
+
dangerouslySetInnerHTML: {
|
|
603
|
+
__html: teacherInstructions
|
|
604
|
+
}
|
|
605
|
+
})) : /*#__PURE__*/_react.default.createElement("div", {
|
|
606
|
+
dangerouslySetInnerHTML: {
|
|
607
|
+
__html: teacherInstructions
|
|
608
|
+
}
|
|
609
|
+
})), prompt && /*#__PURE__*/_react.default.createElement(PromptContainer, null, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
610
|
+
prompt: prompt
|
|
611
|
+
})), studentPrintMode ? printView : /*#__PURE__*/_react.default.createElement(_renderUi.Readable, {
|
|
612
|
+
false: true
|
|
613
|
+
}, /*#__PURE__*/_react.default.createElement(InputAndKeypadContainer, {
|
|
614
|
+
tabIndex: 0
|
|
615
|
+
}, responseType === _utils.ResponseTypes.simple && /*#__PURE__*/_react.default.createElement(_simpleQuestionBlock.default, {
|
|
616
|
+
onSimpleResponseChange: this.onSimpleResponseChange,
|
|
617
|
+
showCorrect: showCorrect,
|
|
618
|
+
emptyResponse: emptyResponse,
|
|
619
|
+
model: model,
|
|
620
|
+
session: session,
|
|
621
|
+
onSubFieldFocus: this.onSubFieldFocus,
|
|
622
|
+
showKeypad: !!activeAnswerBlock
|
|
623
|
+
}), responseType === _utils.ResponseTypes.advanced && /*#__PURE__*/_react.default.createElement(Expression, {
|
|
624
|
+
ref: tooltipContainerRef,
|
|
625
|
+
isIncorrect: !emptyResponse && !correct && !showCorrect,
|
|
626
|
+
isCorrect: !emptyResponse && (correct || showCorrect),
|
|
627
|
+
showCorrectness: !emptyResponse && disabled && correctness && !view,
|
|
628
|
+
correctAnswerShown: showCorrect,
|
|
629
|
+
printCorrect: printMode && alwaysShowCorrect
|
|
630
|
+
}, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
631
|
+
ref: ref => this.setTooltipRef(ref),
|
|
632
|
+
enterTouchDelay: 0,
|
|
633
|
+
interactive: true,
|
|
634
|
+
open: !!activeAnswerBlock,
|
|
635
|
+
slotProps: {
|
|
636
|
+
popper: {
|
|
637
|
+
container: tooltipContainerRef?.current || undefined,
|
|
780
638
|
placement: 'bottom-start',
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
enabled: false
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
title: Object.keys(session.answers).map(function (answerId) {
|
|
792
|
-
return answerId === activeAnswerBlock && !(showCorrect || disabled) && /*#__PURE__*/_react["default"].createElement("div", {
|
|
793
|
-
"data-keypad": true,
|
|
794
|
-
key: answerId,
|
|
795
|
-
className: classes.responseContainer,
|
|
796
|
-
style: {
|
|
797
|
-
// marginTop: this.mqStatic && this.mqStatic.input.offsetHeight - 20,
|
|
798
|
-
width: getKeyPadWidth(additionalKeys, equationEditor)
|
|
639
|
+
sx: {
|
|
640
|
+
backgroundColor: 'transparent',
|
|
641
|
+
width: '650px',
|
|
642
|
+
opacity: 1,
|
|
643
|
+
'& .MuiTooltip-arrow': {
|
|
644
|
+
display: 'none'
|
|
799
645
|
}
|
|
800
|
-
}, /*#__PURE__*/_react["default"].createElement(_mathInput.HorizontalKeypad, {
|
|
801
|
-
additionalKeys: additionalKeys,
|
|
802
|
-
mode: equationEditor || DEFAULT_KEYPAD_VARIANT,
|
|
803
|
-
onClick: _this4.onClick
|
|
804
|
-
})) || null;
|
|
805
|
-
})
|
|
806
|
-
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
807
|
-
className: classes["static"],
|
|
808
|
-
ref: function ref(mqStatic) {
|
|
809
|
-
if (mqStatic) _this4.mqStatic = mqStatic;
|
|
810
|
-
},
|
|
811
|
-
latex: staticLatex,
|
|
812
|
-
onSubFieldChange: this.subFieldChanged,
|
|
813
|
-
getFieldName: this.getFieldName,
|
|
814
|
-
setInput: this.setInput,
|
|
815
|
-
onSubFieldFocus: this.onSubFieldFocus,
|
|
816
|
-
onBlur: this.onBlur
|
|
817
|
-
}))))), viewMode && displayNote && /*#__PURE__*/_react["default"].createElement("div", {
|
|
818
|
-
className: classes.note,
|
|
819
|
-
dangerouslySetInnerHTML: {
|
|
820
|
-
__html: "<strong>Note:</strong> ".concat(note)
|
|
821
|
-
}
|
|
822
|
-
}), viewMode && showRationale && (!animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
823
|
-
labels: {
|
|
824
|
-
hidden: 'Show Rationale',
|
|
825
|
-
visible: 'Hide Rationale'
|
|
826
|
-
}
|
|
827
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
828
|
-
dangerouslySetInnerHTML: {
|
|
829
|
-
__html: rationale
|
|
830
|
-
}
|
|
831
|
-
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
832
|
-
dangerouslySetInnerHTML: {
|
|
833
|
-
__html: rationale
|
|
834
|
-
}
|
|
835
|
-
})));
|
|
836
|
-
|
|
837
|
-
if (tooltipModeEnabled && (showCorrectAnswerToggle || showTeacherInstructions || showRationale || feedback)) {
|
|
838
|
-
return /*#__PURE__*/_react["default"].createElement(_renderUi.UiLayout, {
|
|
839
|
-
extraCSSRules: extraCSSRules
|
|
840
|
-
}, /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
841
|
-
interactive: true,
|
|
842
|
-
enterTouchDelay: 0,
|
|
843
|
-
classes: {
|
|
844
|
-
tooltip: classes.tooltip,
|
|
845
|
-
popper: classes.tooltipPopper
|
|
846
646
|
},
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
className: classes.toggle,
|
|
852
|
-
show: true,
|
|
853
|
-
toggled: showCorrect,
|
|
854
|
-
onToggle: this.toggleShowCorrect
|
|
855
|
-
})), showTeacherInstructions && /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
856
|
-
className: classes.collapsible,
|
|
857
|
-
key: "collapsible-teacher-instructions",
|
|
858
|
-
labels: {
|
|
859
|
-
hidden: 'Show Teacher Instructions',
|
|
860
|
-
visible: 'Hide Teacher Instructions'
|
|
647
|
+
modifiers: [{
|
|
648
|
+
name: 'offset',
|
|
649
|
+
options: {
|
|
650
|
+
offset: [0, 8]
|
|
861
651
|
}
|
|
862
|
-
},
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
hidden: translator.t('common:showNote', {
|
|
869
|
-
lng: language
|
|
870
|
-
}),
|
|
871
|
-
visible: translator.t('common:hideNote', {
|
|
872
|
-
lng: language
|
|
873
|
-
})
|
|
652
|
+
}, {
|
|
653
|
+
name: 'preventOverflow',
|
|
654
|
+
enabled: true,
|
|
655
|
+
options: {
|
|
656
|
+
boundary: 'viewport',
|
|
657
|
+
padding: 8
|
|
874
658
|
}
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
labels: {
|
|
881
|
-
hidden: 'Show Rationale',
|
|
882
|
-
visible: 'Hide Rationale'
|
|
659
|
+
}, {
|
|
660
|
+
name: 'computeStyles',
|
|
661
|
+
options: {
|
|
662
|
+
adaptive: true,
|
|
663
|
+
gpuAcceleration: true
|
|
883
664
|
}
|
|
884
|
-
},
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
665
|
+
}, {
|
|
666
|
+
name: 'flip',
|
|
667
|
+
enabled: false
|
|
668
|
+
}]
|
|
669
|
+
},
|
|
670
|
+
tooltip: {
|
|
671
|
+
sx: {
|
|
672
|
+
fontSize: 'initial',
|
|
673
|
+
backgroundColor: 'transparent',
|
|
674
|
+
width: '600px',
|
|
675
|
+
marginTop: 0,
|
|
676
|
+
paddingTop: 0,
|
|
677
|
+
boxShadow: 'none'
|
|
894
678
|
}
|
|
895
|
-
}
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
title: Object.keys(session.answers).map(answerId => answerId === activeAnswerBlock && !(showCorrect || disabled) && /*#__PURE__*/_react.default.createElement(ResponseContainer, {
|
|
682
|
+
"data-keypad": true,
|
|
683
|
+
key: answerId,
|
|
684
|
+
style: {
|
|
685
|
+
// marginTop: this.mqStatic && this.mqStatic.input.offsetHeight - 20,
|
|
686
|
+
width: getKeyPadWidth(additionalKeys, equationEditor)
|
|
687
|
+
}
|
|
688
|
+
}, /*#__PURE__*/_react.default.createElement(_mathInput.HorizontalKeypad, {
|
|
689
|
+
additionalKeys: additionalKeys,
|
|
690
|
+
mode: equationEditor || DEFAULT_KEYPAD_VARIANT,
|
|
691
|
+
onClick: this.onClick
|
|
692
|
+
})) || null)
|
|
693
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_mathInput.mq.Static, {
|
|
694
|
+
className: "static-math",
|
|
695
|
+
ref: mqStatic => {
|
|
696
|
+
if (mqStatic) this.mqStatic = mqStatic;
|
|
697
|
+
},
|
|
698
|
+
latex: staticLatex,
|
|
699
|
+
onSubFieldChange: this.subFieldChanged,
|
|
700
|
+
getFieldName: this.getFieldName,
|
|
701
|
+
setInput: this.setInput,
|
|
702
|
+
onSubFieldFocus: this.onSubFieldFocus,
|
|
703
|
+
onBlur: this.onBlur
|
|
704
|
+
})))))), viewMode && displayNote && /*#__PURE__*/_react.default.createElement(Note, {
|
|
705
|
+
dangerouslySetInnerHTML: {
|
|
706
|
+
__html: `<strong>Note:</strong> ${note}`
|
|
896
707
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
708
|
+
}), viewMode && showRationale && (!animationsDisabled ? /*#__PURE__*/_react.default.createElement(_renderUi.Collapsible, {
|
|
709
|
+
labels: {
|
|
710
|
+
hidden: 'Show Rationale',
|
|
711
|
+
visible: 'Hide Rationale'
|
|
712
|
+
}
|
|
713
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
714
|
+
dangerouslySetInnerHTML: {
|
|
715
|
+
__html: rationale
|
|
716
|
+
}
|
|
717
|
+
})) : /*#__PURE__*/_react.default.createElement("div", {
|
|
718
|
+
dangerouslySetInnerHTML: {
|
|
719
|
+
__html: rationale
|
|
720
|
+
}
|
|
721
|
+
})));
|
|
722
|
+
if (tooltipModeEnabled && (showCorrectAnswerToggle || showTeacherInstructions || showRationale || feedback)) {
|
|
723
|
+
return /*#__PURE__*/_react.default.createElement(StyledUiLayout, {
|
|
900
724
|
extraCSSRules: extraCSSRules,
|
|
901
|
-
|
|
902
|
-
ref: function ref(r) {
|
|
725
|
+
ref: r => {
|
|
903
726
|
// eslint-disable-next-line react/no-find-dom-node
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
_this4.root = domNode || _this4.root;
|
|
727
|
+
const domNode = _reactDom.default.findDOMNode(r);
|
|
728
|
+
this.root = domNode || this.root;
|
|
907
729
|
}
|
|
908
|
-
},
|
|
730
|
+
}, /*#__PURE__*/_react.default.createElement(StyledTooltip, {
|
|
731
|
+
interactive: true,
|
|
732
|
+
enterTouchDelay: 0,
|
|
733
|
+
placement: "bottom-start",
|
|
734
|
+
slotProps: {
|
|
735
|
+
tooltip: {
|
|
736
|
+
sx: theme => ({
|
|
737
|
+
background: `${_renderUi.color.primaryLight()} !important`,
|
|
738
|
+
color: _renderUi.color.text(),
|
|
739
|
+
padding: theme.spacing(2),
|
|
740
|
+
border: `1px solid ${_renderUi.color.secondary()}`,
|
|
741
|
+
fontSize: '16px',
|
|
742
|
+
'& :not(.MathJax) > table tr': {
|
|
743
|
+
'&:nth-child(2n)': {
|
|
744
|
+
backgroundColor: 'unset !important'
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
},
|
|
749
|
+
popper: {
|
|
750
|
+
sx: {
|
|
751
|
+
opacity: 1
|
|
752
|
+
},
|
|
753
|
+
modifiers: [{
|
|
754
|
+
name: 'offset',
|
|
755
|
+
options: {
|
|
756
|
+
offset: [0, 2]
|
|
757
|
+
}
|
|
758
|
+
}]
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
title: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(MainContent, null, showCorrectAnswerToggle && /*#__PURE__*/_react.default.createElement(StyledCorrectAnswerToggle, {
|
|
762
|
+
language: language,
|
|
763
|
+
show: true,
|
|
764
|
+
toggled: showCorrect,
|
|
765
|
+
onToggle: this.toggleShowCorrect
|
|
766
|
+
})), showTeacherInstructions && /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
767
|
+
key: "collapsible-teacher-instructions",
|
|
768
|
+
labels: {
|
|
769
|
+
hidden: 'Show Teacher Instructions',
|
|
770
|
+
visible: 'Hide Teacher Instructions'
|
|
771
|
+
}
|
|
772
|
+
}, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
773
|
+
prompt: teacherInstructions
|
|
774
|
+
})), displayNote && (0, _renderUi.hasText)(note) && /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
775
|
+
key: "collapsible-note",
|
|
776
|
+
labels: {
|
|
777
|
+
hidden: translator.t('common:showNote', {
|
|
778
|
+
lng: language
|
|
779
|
+
}),
|
|
780
|
+
visible: translator.t('common:hideNote', {
|
|
781
|
+
lng: language
|
|
782
|
+
})
|
|
783
|
+
}
|
|
784
|
+
}, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
785
|
+
prompt: note
|
|
786
|
+
})), showRationale && /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
787
|
+
key: "collapsible-rationale",
|
|
788
|
+
labels: {
|
|
789
|
+
hidden: 'Show Rationale',
|
|
790
|
+
visible: 'Hide Rationale'
|
|
791
|
+
}
|
|
792
|
+
}, /*#__PURE__*/_react.default.createElement(_renderUi.PreviewPrompt, {
|
|
793
|
+
prompt: rationale
|
|
794
|
+
})), feedback && /*#__PURE__*/_react.default.createElement(_renderUi.Feedback, {
|
|
795
|
+
correctness: correctness.correctness,
|
|
796
|
+
feedback: feedback
|
|
797
|
+
}))
|
|
798
|
+
}, midContent));
|
|
909
799
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
800
|
+
return /*#__PURE__*/_react.default.createElement(StyledUiLayout, {
|
|
801
|
+
id: id,
|
|
802
|
+
extraCSSRules: extraCSSRules,
|
|
803
|
+
ref: r => {
|
|
804
|
+
// eslint-disable-next-line react/no-find-dom-node
|
|
805
|
+
const domNode = _reactDom.default.findDOMNode(r);
|
|
806
|
+
this.root = domNode || this.root;
|
|
807
|
+
}
|
|
808
|
+
}, midContent);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
913
811
|
|
|
812
|
+
// Helper function to get class names for HTML string generation
|
|
914
813
|
exports.Main = Main;
|
|
915
|
-
(0, _defineProperty2
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
model: _propTypes["default"].object.isRequired
|
|
814
|
+
(0, _defineProperty2.default)(Main, "propTypes", {
|
|
815
|
+
session: _propTypes.default.object.isRequired,
|
|
816
|
+
onSessionChange: _propTypes.default.func,
|
|
817
|
+
model: _propTypes.default.object.isRequired
|
|
920
818
|
});
|
|
921
|
-
|
|
922
|
-
var styles = function styles(theme) {
|
|
819
|
+
const getBlockClassNames = () => {
|
|
923
820
|
return {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
821
|
+
blockContainer: 'block-container',
|
|
822
|
+
blockResponse: 'block-response',
|
|
823
|
+
blockMath: 'block-math'
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// CSS for block classes used in HTML string generation
|
|
828
|
+
if (typeof document !== 'undefined') {
|
|
829
|
+
const styleId = 'math-inline-block-styles';
|
|
830
|
+
if (!document.getElementById(styleId)) {
|
|
831
|
+
const style = document.createElement('style');
|
|
832
|
+
style.id = styleId;
|
|
833
|
+
style.textContent = `
|
|
834
|
+
.block-container {
|
|
835
|
+
margin: 8px !important;
|
|
836
|
+
display: inline-flex;
|
|
837
|
+
border: 2px solid grey !important;
|
|
939
838
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
background: 'transparent',
|
|
953
|
-
width: '650px',
|
|
954
|
-
opacity: 1
|
|
955
|
-
},
|
|
956
|
-
promptContainer: {
|
|
957
|
-
marginBottom: theme.spacing.unit * 2
|
|
958
|
-
},
|
|
959
|
-
main: {
|
|
960
|
-
width: '100%',
|
|
961
|
-
position: 'relative',
|
|
962
|
-
backgroundColor: _renderUi.color.background(),
|
|
963
|
-
color: _renderUi.color.text()
|
|
964
|
-
},
|
|
965
|
-
title: {
|
|
966
|
-
fontSize: '1.1rem',
|
|
967
|
-
display: 'block',
|
|
968
|
-
marginTop: theme.spacing.unit * 2,
|
|
969
|
-
marginBottom: theme.spacing.unit
|
|
970
|
-
},
|
|
971
|
-
note: {
|
|
972
|
-
paddingBottom: theme.spacing.unit * 2
|
|
973
|
-
},
|
|
974
|
-
collapsible: {
|
|
975
|
-
marginBottom: theme.spacing.unit * 2
|
|
976
|
-
},
|
|
977
|
-
responseContainer: {
|
|
978
|
-
zIndex: 10,
|
|
979
|
-
// position: 'absolute',
|
|
980
|
-
// right: 0,
|
|
981
|
-
minWidth: '400px',
|
|
982
|
-
marginTop: theme.spacing.unit * 2
|
|
983
|
-
},
|
|
984
|
-
expression: {
|
|
985
|
-
maxWidth: 'fit-content',
|
|
986
|
-
padding: theme.spacing.unit / 4,
|
|
987
|
-
'& > .mq-math-mode': {
|
|
988
|
-
'& > .mq-root-block': {
|
|
989
|
-
// PD-4803 unset padding as events are not correctly propagated in the proximity of math input
|
|
990
|
-
paddingRight: '0 !important',
|
|
991
|
-
paddingLeft: '0 !important',
|
|
992
|
-
'& > .mq-editable-field': {
|
|
993
|
-
minWidth: '10px',
|
|
994
|
-
padding: theme.spacing.unit / 4
|
|
995
|
-
}
|
|
996
|
-
},
|
|
997
|
-
'& sup': {
|
|
998
|
-
top: 0
|
|
999
|
-
}
|
|
839
|
+
.block-response {
|
|
840
|
+
color: grey;
|
|
841
|
+
background: #f5f5f5;
|
|
842
|
+
font-size: 0.8rem !important;
|
|
843
|
+
padding: 4px !important;
|
|
844
|
+
display: flex;
|
|
845
|
+
align-items: center;
|
|
846
|
+
justify-content: center;
|
|
847
|
+
border-right: 2px solid #bdbdbd !important;
|
|
848
|
+
flex-shrink: 0;
|
|
849
|
+
flex-grow: 0;
|
|
850
|
+
flex-basis: auto;
|
|
1000
851
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
852
|
+
.block-math {
|
|
853
|
+
color: ${_renderUi.color.text()};
|
|
854
|
+
background-color: ${_renderUi.color.background()};
|
|
855
|
+
padding: 4px !important;
|
|
856
|
+
display: flex;
|
|
857
|
+
align-items: center;
|
|
858
|
+
justify-content: center;
|
|
859
|
+
flex-grow: 1;
|
|
860
|
+
}
|
|
861
|
+
.block-math > .mq-math-mode > .mq-hasCursor > .mq-cursor {
|
|
862
|
+
display: none;
|
|
863
|
+
}
|
|
864
|
+
.sr-only {
|
|
865
|
+
position: absolute;
|
|
866
|
+
left: -10000px;
|
|
867
|
+
top: auto;
|
|
868
|
+
width: 1px;
|
|
869
|
+
height: 1px;
|
|
870
|
+
overflow: hidden;
|
|
871
|
+
}
|
|
872
|
+
.static-math > .mq-root-block > .mq-editable-field {
|
|
873
|
+
border-color: ${_renderUi.color.text()};
|
|
874
|
+
}
|
|
875
|
+
`;
|
|
876
|
+
document.head.appendChild(style);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
const StyledUiLayout = (0, _styles.styled)(_renderUi.UiLayout)(() => ({
|
|
880
|
+
color: _renderUi.color.text(),
|
|
881
|
+
backgroundColor: _renderUi.color.background(),
|
|
882
|
+
display: 'inline-block'
|
|
883
|
+
}));
|
|
884
|
+
const StyledTooltip = (0, _styles.styled)(_Tooltip.default)({
|
|
885
|
+
// Styles applied via slotProps.sx below
|
|
886
|
+
});
|
|
887
|
+
const PromptContainer = (0, _styles.styled)('div')(({
|
|
888
|
+
theme
|
|
889
|
+
}) => ({
|
|
890
|
+
marginBottom: theme.spacing(2)
|
|
891
|
+
}));
|
|
892
|
+
const MainContent = (0, _styles.styled)('div')({
|
|
893
|
+
width: '100%',
|
|
894
|
+
position: 'relative',
|
|
895
|
+
backgroundColor: _renderUi.color.background(),
|
|
896
|
+
color: _renderUi.color.text()
|
|
897
|
+
});
|
|
898
|
+
const Note = (0, _styles.styled)('div')(({
|
|
899
|
+
theme
|
|
900
|
+
}) => ({
|
|
901
|
+
paddingBottom: theme.spacing(2)
|
|
902
|
+
}));
|
|
903
|
+
const StyledCollapsible = (0, _styles.styled)(_renderUi.Collapsible)(({
|
|
904
|
+
theme
|
|
905
|
+
}) => ({
|
|
906
|
+
marginBottom: theme.spacing(2)
|
|
907
|
+
}));
|
|
908
|
+
const ResponseContainer = (0, _styles.styled)('div')(({
|
|
909
|
+
theme
|
|
910
|
+
}) => ({
|
|
911
|
+
zIndex: 10,
|
|
912
|
+
minWidth: '400px',
|
|
913
|
+
marginTop: theme.spacing(2)
|
|
914
|
+
}));
|
|
915
|
+
const Expression = (0, _styles.styled)('div', {
|
|
916
|
+
shouldForwardProp: prop => !['isIncorrect', 'isCorrect', 'showCorrectness', 'correctAnswerShown', 'printCorrect'].includes(prop)
|
|
917
|
+
})(({
|
|
918
|
+
theme,
|
|
919
|
+
isIncorrect,
|
|
920
|
+
isCorrect,
|
|
921
|
+
showCorrectness,
|
|
922
|
+
correctAnswerShown,
|
|
923
|
+
printCorrect
|
|
924
|
+
}) => {
|
|
925
|
+
const borderColor = isIncorrect ? _renderUi.color.incorrect() : isCorrect ? _renderUi.color.correct() : undefined;
|
|
926
|
+
return {
|
|
927
|
+
maxWidth: 'fit-content',
|
|
928
|
+
padding: theme.spacing(0.25),
|
|
929
|
+
...(showCorrectness && {
|
|
930
|
+
border: borderColor ? `2px solid ${borderColor} !important` : '2px solid'
|
|
931
|
+
}),
|
|
932
|
+
...(!showCorrectness && borderColor && {
|
|
933
|
+
borderColor: `${borderColor} !important`
|
|
934
|
+
}),
|
|
935
|
+
...(correctAnswerShown && {
|
|
936
|
+
padding: theme.spacing(1),
|
|
937
|
+
letterSpacing: '0.5px'
|
|
938
|
+
}),
|
|
939
|
+
...(printCorrect && {
|
|
940
|
+
border: `2px solid ${_renderUi.color.correct()} !important`
|
|
941
|
+
}),
|
|
942
|
+
'& > .mq-math-mode': {
|
|
1003
943
|
'& > .mq-root-block': {
|
|
944
|
+
paddingRight: '0 !important',
|
|
945
|
+
paddingLeft: '0 !important',
|
|
1004
946
|
'& > .mq-editable-field': {
|
|
1005
|
-
|
|
947
|
+
minWidth: '10px',
|
|
948
|
+
padding: theme.spacing(0.25)
|
|
1006
949
|
}
|
|
1007
|
-
}
|
|
1008
|
-
},
|
|
1009
|
-
inputAndKeypadContainer: {
|
|
1010
|
-
position: 'relative',
|
|
1011
|
-
'& .mq-overarrow-inner': {
|
|
1012
|
-
border: 'none !important',
|
|
1013
|
-
padding: '0 !important'
|
|
1014
|
-
},
|
|
1015
|
-
'& .mq-overarrow-inner-right': {
|
|
1016
|
-
display: 'none !important'
|
|
1017
|
-
},
|
|
1018
|
-
'& .mq-overarrow-inner-left': {
|
|
1019
|
-
display: 'none !important'
|
|
1020
|
-
},
|
|
1021
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
1022
|
-
minWidth: '1.23em',
|
|
1023
|
-
'& *': {
|
|
1024
|
-
lineHeight: '1 !important'
|
|
1025
|
-
},
|
|
1026
|
-
'&:before': {
|
|
1027
|
-
top: '-0.4em',
|
|
1028
|
-
left: '-1px'
|
|
1029
|
-
},
|
|
1030
|
-
'&:after': {
|
|
1031
|
-
top: '-2.4em',
|
|
1032
|
-
right: '-1px'
|
|
1033
|
-
},
|
|
1034
|
-
'&.mq-empty:after': {
|
|
1035
|
-
top: '-0.45em'
|
|
1036
|
-
}
|
|
1037
|
-
},
|
|
1038
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
1039
|
-
'&:before': {
|
|
1040
|
-
top: '-0.4em',
|
|
1041
|
-
right: '-1px'
|
|
1042
|
-
}
|
|
1043
|
-
},
|
|
1044
|
-
'& .mq-longdiv-inner': {
|
|
1045
|
-
borderTop: '1px solid !important',
|
|
1046
|
-
paddingTop: '1.5px !important'
|
|
1047
950
|
},
|
|
1048
|
-
'&
|
|
1049
|
-
|
|
951
|
+
'& sup': {
|
|
952
|
+
top: 0
|
|
1050
953
|
}
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
});
|
|
957
|
+
const InputAndKeypadContainer = (0, _styles.styled)('div')({
|
|
958
|
+
position: 'relative',
|
|
959
|
+
'& .mq-overarrow-inner': {
|
|
960
|
+
border: 'none !important',
|
|
961
|
+
padding: '0 !important'
|
|
962
|
+
},
|
|
963
|
+
'& .mq-overarrow-inner-right': {
|
|
964
|
+
display: 'none !important'
|
|
965
|
+
},
|
|
966
|
+
'& .mq-overarrow-inner-left': {
|
|
967
|
+
display: 'none !important'
|
|
968
|
+
},
|
|
969
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
970
|
+
minWidth: '1.23em',
|
|
971
|
+
'& *': {
|
|
972
|
+
lineHeight: '1 !important'
|
|
1051
973
|
},
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
correctAnswerShown: {
|
|
1056
|
-
padding: theme.spacing.unit,
|
|
1057
|
-
letterSpacing: '0.5px'
|
|
1058
|
-
},
|
|
1059
|
-
printCorrect: {
|
|
1060
|
-
border: "2px solid ".concat(_renderUi.color.correct(), " !important")
|
|
1061
|
-
},
|
|
1062
|
-
correct: {
|
|
1063
|
-
borderColor: "".concat(_renderUi.color.correct(), " !important")
|
|
1064
|
-
},
|
|
1065
|
-
incorrect: {
|
|
1066
|
-
borderColor: "".concat(_renderUi.color.incorrect(), " !important")
|
|
1067
|
-
},
|
|
1068
|
-
blockContainer: {
|
|
1069
|
-
margin: "".concat(theme.spacing.unit, "px !important"),
|
|
1070
|
-
display: 'inline-flex',
|
|
1071
|
-
border: '2px solid grey !important'
|
|
1072
|
-
},
|
|
1073
|
-
blockResponse: {
|
|
1074
|
-
color: 'grey',
|
|
1075
|
-
background: theme.palette.grey['A100'],
|
|
1076
|
-
fontSize: '0.8rem !important',
|
|
1077
|
-
padding: "".concat(theme.spacing.unit / 2, "px !important"),
|
|
1078
|
-
display: 'flex',
|
|
1079
|
-
alignItems: 'center',
|
|
1080
|
-
justifyContent: 'center',
|
|
1081
|
-
borderRight: "2px solid ".concat(_renderUi.color.disabled(), " !important"),
|
|
1082
|
-
flexShrink: 0,
|
|
1083
|
-
flexGrow: 0,
|
|
1084
|
-
flexBasis: 'auto' // take only the space needed for content + padding
|
|
1085
|
-
|
|
1086
|
-
},
|
|
1087
|
-
toggle: {
|
|
1088
|
-
color: _renderUi.color.text(),
|
|
1089
|
-
marginBottom: theme.spacing.unit * 2
|
|
1090
|
-
},
|
|
1091
|
-
blockMath: {
|
|
1092
|
-
color: _renderUi.color.text(),
|
|
1093
|
-
backgroundColor: _renderUi.color.background(),
|
|
1094
|
-
padding: "".concat(theme.spacing.unit / 2, "px !important"),
|
|
1095
|
-
display: 'flex',
|
|
1096
|
-
alignItems: 'center',
|
|
1097
|
-
justifyContent: 'center',
|
|
1098
|
-
flexGrow: 1,
|
|
1099
|
-
// take all the remaining space
|
|
1100
|
-
'& > .mq-math-mode': {
|
|
1101
|
-
'& > .mq-hasCursor': {
|
|
1102
|
-
'& > .mq-cursor': {
|
|
1103
|
-
display: 'none'
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
974
|
+
'&:before': {
|
|
975
|
+
top: '-0.4em',
|
|
976
|
+
left: '-1px'
|
|
1107
977
|
},
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
978
|
+
'&:after': {
|
|
979
|
+
top: '-2.4em',
|
|
980
|
+
right: '-1px'
|
|
1111
981
|
},
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
left: '-10000px',
|
|
1115
|
-
top: 'auto',
|
|
1116
|
-
width: '1px',
|
|
1117
|
-
height: '1px',
|
|
1118
|
-
overflow: 'hidden'
|
|
982
|
+
'&.mq-empty:after': {
|
|
983
|
+
top: '-0.45em'
|
|
1119
984
|
}
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
985
|
+
},
|
|
986
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
987
|
+
'&:before': {
|
|
988
|
+
top: '-0.4em',
|
|
989
|
+
right: '-1px'
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
'& .mq-longdiv-inner': {
|
|
993
|
+
borderTop: '1px solid !important',
|
|
994
|
+
paddingTop: '1.5px !important'
|
|
995
|
+
},
|
|
996
|
+
'& .mq-parallelogram': {
|
|
997
|
+
lineHeight: 0.85
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
const PrintContainer = (0, _styles.styled)('div')(({
|
|
1001
|
+
theme
|
|
1002
|
+
}) => ({
|
|
1003
|
+
marginBottom: theme.spacing(1),
|
|
1004
|
+
pointerEvents: 'none'
|
|
1005
|
+
}));
|
|
1006
|
+
const SrOnly = (0, _styles.styled)('h2')({
|
|
1007
|
+
position: 'absolute',
|
|
1008
|
+
left: '-10000px',
|
|
1009
|
+
top: 'auto',
|
|
1010
|
+
width: '1px',
|
|
1011
|
+
height: '1px',
|
|
1012
|
+
overflow: 'hidden'
|
|
1013
|
+
});
|
|
1014
|
+
const StyledCorrectAnswerToggle = (0, _styles.styled)(_correctAnswerToggle.default)(({
|
|
1015
|
+
theme
|
|
1016
|
+
}) => ({
|
|
1017
|
+
color: _renderUi.color.text(),
|
|
1018
|
+
marginBottom: theme.spacing(2)
|
|
1019
|
+
}));
|
|
1020
|
+
var _default = exports.default = Main;
|
|
1126
1021
|
//# sourceMappingURL=main.js.map
|