@pie-element/math-inline 5.9.10 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/configure/CHANGELOG.md +33 -0
- package/configure/lib/configure.js +10 -2
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +10 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +13 -3
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/package.json +5 -5
- package/docs/config-schema.json +63 -0
- package/docs/config-schema.json.md +49 -1
- package/docs/pie-schema.json +21 -0
- package/docs/pie-schema.json.md +16 -0
- package/lib/simple-question-block.js +36 -30
- package/lib/simple-question-block.js.map +1 -1
- package/package.json +6 -6
- package/module/configure.js +0 -1568
- package/module/controller.js +0 -1424
- package/module/demo.js +0 -48
- package/module/element.js +0 -1258
- package/module/index.html +0 -21
- package/module/manifest.json +0 -18
- package/module/print-demo.js +0 -86
- package/module/print.html +0 -18
- package/module/print.js +0 -1109
package/module/print.js
DELETED
|
@@ -1,1109 +0,0 @@
|
|
|
1
|
-
import {_dll_react, _dll_classnames, _dll_material_ui__core_styles, _dll_prop_types, _dll_pie_lib__render_ui, _dll_pie_lib__correct_answer_toggle, _dll_material_ui__core, _dll_lodash, _dll_react_dom, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.17/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.5/module/index.js";
|
|
3
|
-
import {_dll_pie_lib__math_toolbar, _dll_pie_lib__math_input, _dll_pie_framework__mathquill} from "../../../@pie-lib/math-edit-module@^1.2.4/module/index.js";
|
|
4
|
-
const ResponseTypes = {
|
|
5
|
-
advanced: 'Advanced Multi',
|
|
6
|
-
simple: 'Simple'
|
|
7
|
-
};
|
|
8
|
-
const React$2 = _dll_react;
|
|
9
|
-
const cx$1 = _dll_classnames;
|
|
10
|
-
const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
|
|
11
|
-
const PropTypes$1 = _dll_prop_types;
|
|
12
|
-
const {color: color$1} = _dll_pie_lib__render_ui;
|
|
13
|
-
const {MathToolbar: MathToolbar} = _dll_pie_lib__math_toolbar;
|
|
14
|
-
const {mq: mq$1} = _dll_pie_lib__math_input;
|
|
15
|
-
const _jsxFileName$1 = "/home/circleci/repo/packages/math-inline/src/simple-question-block.jsx";
|
|
16
|
-
class SimpleQuestionBlockRaw extends React$2.Component {
|
|
17
|
-
constructor(...args) {
|
|
18
|
-
super(...args);
|
|
19
|
-
SimpleQuestionBlockRaw.prototype.__init.call(this);
|
|
20
|
-
SimpleQuestionBlockRaw.prototype.__init2.call(this);
|
|
21
|
-
SimpleQuestionBlockRaw.prototype.__init3.call(this);
|
|
22
|
-
}
|
|
23
|
-
static __initStatic() {
|
|
24
|
-
this.propTypes = {
|
|
25
|
-
classes: PropTypes$1.object,
|
|
26
|
-
onSimpleResponseChange: PropTypes$1.func,
|
|
27
|
-
model: PropTypes$1.object.isRequired,
|
|
28
|
-
emptyResponse: PropTypes$1.bool,
|
|
29
|
-
session: PropTypes$1.object.isRequired,
|
|
30
|
-
showCorrect: PropTypes$1.bool
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
__init() {
|
|
34
|
-
this.state = {
|
|
35
|
-
showKeypad: true
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
__init2() {
|
|
39
|
-
this.onFocus = () => this.setState({
|
|
40
|
-
showKeypad: true
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
__init3() {
|
|
44
|
-
this.onBlur = e => {
|
|
45
|
-
const {relatedTarget, currentTarget} = e || ({});
|
|
46
|
-
if (!relatedTarget || !currentTarget || relatedTarget.offsetParent !== currentTarget.offsetParent) {
|
|
47
|
-
this.setState({
|
|
48
|
-
showKeypad: false
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
render() {
|
|
54
|
-
const {classes, model, showCorrect, session, emptyResponse, onSimpleResponseChange} = this.props;
|
|
55
|
-
const {config, disabled, correctness, view} = model || ({});
|
|
56
|
-
if (!config) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const correct = correctness && correctness.correct;
|
|
60
|
-
const {responses, equationEditor} = config;
|
|
61
|
-
return React$2.createElement('div', {
|
|
62
|
-
className: classes.expression,
|
|
63
|
-
__self: this,
|
|
64
|
-
__source: {
|
|
65
|
-
fileName: _jsxFileName$1,
|
|
66
|
-
lineNumber: 54
|
|
67
|
-
}
|
|
68
|
-
}, showCorrect || disabled ? React$2.createElement('div', {
|
|
69
|
-
className: cx$1(classes.static, {
|
|
70
|
-
[classes.incorrect]: !emptyResponse && !correct && !showCorrect,
|
|
71
|
-
[classes.correct]: !emptyResponse && (correct || showCorrect)
|
|
72
|
-
}),
|
|
73
|
-
__self: this,
|
|
74
|
-
__source: {
|
|
75
|
-
fileName: _jsxFileName$1,
|
|
76
|
-
lineNumber: 56
|
|
77
|
-
}
|
|
78
|
-
}, React$2.createElement(mq$1.Static, {
|
|
79
|
-
latex: showCorrect ? responses && responses.length && responses[0].answer : session.response || '',
|
|
80
|
-
__self: this,
|
|
81
|
-
__source: {
|
|
82
|
-
fileName: _jsxFileName$1,
|
|
83
|
-
lineNumber: 62
|
|
84
|
-
}
|
|
85
|
-
})) : React$2.createElement(MathToolbar, {
|
|
86
|
-
classNames: {
|
|
87
|
-
editor: classes.responseEditor
|
|
88
|
-
},
|
|
89
|
-
latex: session.response || '',
|
|
90
|
-
keypadMode: equationEditor,
|
|
91
|
-
onChange: onSimpleResponseChange,
|
|
92
|
-
onDone: () => {},
|
|
93
|
-
onFocus: this.onFocus,
|
|
94
|
-
onBlur: this.onBlur,
|
|
95
|
-
controlledKeypad: true,
|
|
96
|
-
showKeypad: this.state.showKeypad,
|
|
97
|
-
hideDoneButton: true,
|
|
98
|
-
__self: this,
|
|
99
|
-
__source: {
|
|
100
|
-
fileName: _jsxFileName$1,
|
|
101
|
-
lineNumber: 69
|
|
102
|
-
}
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
SimpleQuestionBlockRaw.__initStatic();
|
|
107
|
-
const SimpleQuestionBlock = withStyles$1(theme => ({
|
|
108
|
-
responseEditor: {
|
|
109
|
-
display: 'flex',
|
|
110
|
-
justifyContent: 'center',
|
|
111
|
-
width: 'auto',
|
|
112
|
-
maxWidth: 'fit-content',
|
|
113
|
-
height: 'auto',
|
|
114
|
-
textAlign: 'left',
|
|
115
|
-
padding: theme.spacing.unit,
|
|
116
|
-
'&.mq-math-mode': {
|
|
117
|
-
border: `1px solid ${color$1.primaryLight()}`
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
expression: {
|
|
121
|
-
marginTop: theme.spacing.unit * 2,
|
|
122
|
-
marginBottom: theme.spacing.unit * 2,
|
|
123
|
-
padding: theme.spacing.unit
|
|
124
|
-
},
|
|
125
|
-
static: {
|
|
126
|
-
color: color$1.text(),
|
|
127
|
-
background: color$1.background(),
|
|
128
|
-
border: `1px solid ${color$1.primaryLight()}`,
|
|
129
|
-
width: 'fit-content',
|
|
130
|
-
fontSize: '1rem',
|
|
131
|
-
padding: theme.spacing.unit / 2,
|
|
132
|
-
'& > .mq-math-mode': {
|
|
133
|
-
'& > .mq-hasCursor': {
|
|
134
|
-
'& > .mq-cursor': {
|
|
135
|
-
display: 'none'
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
correct: {
|
|
141
|
-
border: `2px solid ${color$1.correct()} !important`,
|
|
142
|
-
padding: theme.spacing.unit,
|
|
143
|
-
letterSpacing: '0.5px'
|
|
144
|
-
},
|
|
145
|
-
incorrect: {
|
|
146
|
-
border: `2px solid ${color$1.incorrect()} !important`,
|
|
147
|
-
padding: theme.spacing.unit,
|
|
148
|
-
letterSpacing: '0.5px'
|
|
149
|
-
}
|
|
150
|
-
}))(SimpleQuestionBlockRaw);
|
|
151
|
-
const React$1 = _dll_react;
|
|
152
|
-
const PropTypes = _dll_prop_types;
|
|
153
|
-
const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
|
|
154
|
-
const {Feedback: Feedback} = _dll_pie_lib__render_ui;
|
|
155
|
-
const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
|
|
156
|
-
const {Readable: Readable} = _dll_pie_lib__render_ui;
|
|
157
|
-
const {hasText: hasText} = _dll_pie_lib__render_ui;
|
|
158
|
-
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
|
|
159
|
-
const {color: color} = _dll_pie_lib__render_ui;
|
|
160
|
-
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
161
|
-
const {Tooltip: Tooltip} = _dll_material_ui__core;
|
|
162
|
-
const {isEqual: isEqual} = _dll_lodash;
|
|
163
|
-
const {isEmpty: isEmpty} = _dll_lodash;
|
|
164
|
-
const cx = _dll_classnames;
|
|
165
|
-
const {mq: mq} = _dll_pie_lib__math_input;
|
|
166
|
-
const {HorizontalKeypad: HorizontalKeypad} = _dll_pie_lib__math_input;
|
|
167
|
-
const {updateSpans: updateSpans} = _dll_pie_lib__math_input;
|
|
168
|
-
const MathQuill = _dll_pie_framework__mathquill;
|
|
169
|
-
const {renderMath: renderMath$1} = _dll_pie_lib__math_rendering;
|
|
170
|
-
const _jsxFileName = "/home/circleci/repo/packages/math-inline/src/main.jsx";
|
|
171
|
-
function _optionalChain(ops) {
|
|
172
|
-
let lastAccessLHS = undefined;
|
|
173
|
-
let value = ops[0];
|
|
174
|
-
let i = 1;
|
|
175
|
-
while (i < ops.length) {
|
|
176
|
-
const op = ops[i];
|
|
177
|
-
const fn = ops[i + 1];
|
|
178
|
-
i += 2;
|
|
179
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
183
|
-
lastAccessLHS = value;
|
|
184
|
-
value = fn(value);
|
|
185
|
-
} else if (op === 'call' || op === 'optionalCall') {
|
|
186
|
-
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
187
|
-
lastAccessLHS = undefined;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return value;
|
|
191
|
-
}
|
|
192
|
-
let registered = false;
|
|
193
|
-
const NEWLINE_LATEX = /\\newline/g;
|
|
194
|
-
const REGEX = /{{response}}/gm;
|
|
195
|
-
const DEFAULT_KEYPAD_VARIANT = 6;
|
|
196
|
-
const IS_SAFARI = (/^((?!chrome|android).)*safari/i).test(navigator.userAgent);
|
|
197
|
-
function generateAdditionalKeys(keyData = []) {
|
|
198
|
-
return keyData.map(key => ({
|
|
199
|
-
name: key,
|
|
200
|
-
latex: key,
|
|
201
|
-
write: key,
|
|
202
|
-
label: key
|
|
203
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
function getKeyPadWidth(additionalKeys = [], equationEditor) {
|
|
206
|
-
return Math.floor(additionalKeys.length / 5) * 30 + (equationEditor === 'miscellaneous' ? 600 : 500);
|
|
207
|
-
}
|
|
208
|
-
function prepareForStatic(model, state) {
|
|
209
|
-
const {config, disabled} = model || ({});
|
|
210
|
-
const {expression, responses, printMode, alwaysShowCorrect} = config || ({});
|
|
211
|
-
if (config && expression) {
|
|
212
|
-
const modelExpression = expression;
|
|
213
|
-
if (state.showCorrect) {
|
|
214
|
-
return responses && responses.length && responses[0].answer;
|
|
215
|
-
}
|
|
216
|
-
let answerBlocks = 1;
|
|
217
|
-
return (modelExpression || '').replace(REGEX, function () {
|
|
218
|
-
const answer = state.session.answers[`r${answerBlocks}`];
|
|
219
|
-
if (printMode && !alwaysShowCorrect) {
|
|
220
|
-
const blankSpace = ('\\ \\ ').repeat(30) + '\\newline ';
|
|
221
|
-
return `\\MathQuillMathField[r${answerBlocks++}]{${blankSpace.repeat(3)}}`;
|
|
222
|
-
}
|
|
223
|
-
if (disabled) {
|
|
224
|
-
return `\\embed{answerBlock}[r${answerBlocks++}]`;
|
|
225
|
-
}
|
|
226
|
-
return `\\MathQuillMathField[r${answerBlocks++}]{${answer && answer.value || ''}}`;
|
|
227
|
-
}).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
class Main extends React$1.Component {
|
|
231
|
-
static __initStatic() {
|
|
232
|
-
this.propTypes = {
|
|
233
|
-
classes: PropTypes.object,
|
|
234
|
-
session: PropTypes.object.isRequired,
|
|
235
|
-
onSessionChange: PropTypes.func,
|
|
236
|
-
model: PropTypes.object.isRequired
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
constructor(props) {
|
|
240
|
-
super(props);
|
|
241
|
-
Main.prototype.__init.call(this);
|
|
242
|
-
Main.prototype.__init2.call(this);
|
|
243
|
-
Main.prototype.__init3.call(this);
|
|
244
|
-
Main.prototype.__init4.call(this);
|
|
245
|
-
Main.prototype.__init5.call(this);
|
|
246
|
-
Main.prototype.__init6.call(this);
|
|
247
|
-
Main.prototype.__init7.call(this);
|
|
248
|
-
Main.prototype.__init8.call(this);
|
|
249
|
-
Main.prototype.__init9.call(this);
|
|
250
|
-
Main.prototype.__init10.call(this);
|
|
251
|
-
Main.prototype.__init11.call(this);
|
|
252
|
-
Main.prototype.__init12.call(this);
|
|
253
|
-
const answers = {};
|
|
254
|
-
if (props.model.config && props.model.config.expression) {
|
|
255
|
-
let answerBlocks = 1;
|
|
256
|
-
(props.model.config.expression || '').replace(REGEX, () => {
|
|
257
|
-
answers[`r${answerBlocks}`] = {
|
|
258
|
-
value: props.session && props.session.answers && props.session.answers[`r${answerBlocks}`] && props.session.answers[`r${answerBlocks}`].value || ''
|
|
259
|
-
};
|
|
260
|
-
answerBlocks += 1;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
this.state = {
|
|
264
|
-
session: {
|
|
265
|
-
...props.session,
|
|
266
|
-
answers
|
|
267
|
-
},
|
|
268
|
-
activeAnswerBlock: '',
|
|
269
|
-
showCorrect: this.props.model.config.alwaysShowCorrect || false
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
UNSAFE_componentWillMount() {
|
|
273
|
-
const {classes} = this.props;
|
|
274
|
-
if (typeof window !== 'undefined') {
|
|
275
|
-
let MQ = MathQuill.getInterface(2);
|
|
276
|
-
if (!registered) {
|
|
277
|
-
MQ.registerEmbed('answerBlock', data => {
|
|
278
|
-
return {
|
|
279
|
-
htmlString: `<div class="${classes.blockContainer}">
|
|
280
|
-
<div class="${classes.blockResponse}" id="${data}Index">R</div>
|
|
281
|
-
<div class="${classes.blockMath}">
|
|
282
|
-
<span id="${data}"></span>
|
|
283
|
-
</div>
|
|
284
|
-
</div>`,
|
|
285
|
-
text: () => 'text',
|
|
286
|
-
latex: () => `\\embed{answerBlock}[${data}]`
|
|
287
|
-
};
|
|
288
|
-
});
|
|
289
|
-
registered = true;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
__init() {
|
|
294
|
-
this.handleAnswerBlockDomUpdate = () => {
|
|
295
|
-
const {model, classes} = this.props;
|
|
296
|
-
const {session, showCorrect} = this.state;
|
|
297
|
-
const answers = session.answers;
|
|
298
|
-
if (this.root && model.disabled && !showCorrect) {
|
|
299
|
-
Object.keys(answers).forEach(answerId => {
|
|
300
|
-
const el = this.root.querySelector(`#${answerId}`);
|
|
301
|
-
const indexEl = this.root.querySelector(`#${answerId}Index`);
|
|
302
|
-
if (el) {
|
|
303
|
-
let MQ = MathQuill.getInterface(2);
|
|
304
|
-
const answer = answers[answerId];
|
|
305
|
-
el.textContent = answer && answer.value || '';
|
|
306
|
-
if (!model.view) ; else {
|
|
307
|
-
el.parentElement.parentElement.classList.remove(classes.correct);
|
|
308
|
-
el.parentElement.parentElement.classList.remove(classes.incorrect);
|
|
309
|
-
}
|
|
310
|
-
MQ.StaticMath(el);
|
|
311
|
-
indexEl.textContent = 'R';
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
renderMath$1(this.root);
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
componentDidUpdate() {
|
|
319
|
-
this.handleAnswerBlockDomUpdate();
|
|
320
|
-
}
|
|
321
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
322
|
-
const {config} = this.props.model;
|
|
323
|
-
const {config: nextConfig = {}} = nextProps.model || ({});
|
|
324
|
-
if (config.env && config.env.mode !== 'evaluate' || nextConfig.env && nextConfig.env.mode !== 'evaluate') {
|
|
325
|
-
this.setState({
|
|
326
|
-
...this.state.session,
|
|
327
|
-
showCorrect: false
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
if (nextConfig.alwaysShowCorrect) {
|
|
331
|
-
this.setState({
|
|
332
|
-
showCorrect: true
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
if (config && config.responses && config.responses.length !== nextConfig.responses.length || !config && nextConfig && nextConfig.responses || config && nextConfig && config.expression !== nextConfig.expression) {
|
|
336
|
-
const newAnswers = {};
|
|
337
|
-
const answers = this.state.session.answers;
|
|
338
|
-
let answerBlocks = 1;
|
|
339
|
-
(nextConfig.expression || '').replace(REGEX, () => {
|
|
340
|
-
newAnswers[`r${answerBlocks}`] = {
|
|
341
|
-
value: answers && answers[`r${answerBlocks}`] && answers[`r${answerBlocks}`].value || ''
|
|
342
|
-
};
|
|
343
|
-
answerBlocks++;
|
|
344
|
-
});
|
|
345
|
-
this.setState(state => ({
|
|
346
|
-
session: {
|
|
347
|
-
...state.session,
|
|
348
|
-
completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
|
|
349
|
-
answers: newAnswers
|
|
350
|
-
}
|
|
351
|
-
}), this.handleAnswerBlockDomUpdate);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
shouldComponentUpdate(nextProps, nextState) {
|
|
355
|
-
const sameModel = isEqual(this.props.model, nextProps.model);
|
|
356
|
-
const sameState = isEqual(this.state, nextState);
|
|
357
|
-
return !sameModel || !sameState;
|
|
358
|
-
}
|
|
359
|
-
componentDidMount() {
|
|
360
|
-
this.handleAnswerBlockDomUpdate();
|
|
361
|
-
setTimeout(() => renderMath$1(this.root), 100);
|
|
362
|
-
}
|
|
363
|
-
__init2() {
|
|
364
|
-
this.onDone = () => {};
|
|
365
|
-
}
|
|
366
|
-
__init3() {
|
|
367
|
-
this.onSimpleResponseChange = response => {
|
|
368
|
-
this.setState(state => ({
|
|
369
|
-
session: {
|
|
370
|
-
...state.session,
|
|
371
|
-
response
|
|
372
|
-
}
|
|
373
|
-
}), this.callOnSessionChange);
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
__init4() {
|
|
377
|
-
this.onSubFieldFocus = id => {
|
|
378
|
-
this.setState({
|
|
379
|
-
activeAnswerBlock: id
|
|
380
|
-
});
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
__init5() {
|
|
384
|
-
this.toNodeData = data => {
|
|
385
|
-
if (!data) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const {type, value} = data;
|
|
389
|
-
if (type === 'command' || type === 'cursor') {
|
|
390
|
-
return data;
|
|
391
|
-
} else if (type === 'answer') {
|
|
392
|
-
return {
|
|
393
|
-
type: 'answer',
|
|
394
|
-
...data
|
|
395
|
-
};
|
|
396
|
-
} else if (value === 'clear') {
|
|
397
|
-
return {
|
|
398
|
-
type: 'clear'
|
|
399
|
-
};
|
|
400
|
-
} else {
|
|
401
|
-
return {
|
|
402
|
-
type: 'write',
|
|
403
|
-
value
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
__init6() {
|
|
409
|
-
this.setInput = input => {
|
|
410
|
-
this.input = input;
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
__init7() {
|
|
414
|
-
this.onClick = data => {
|
|
415
|
-
const c = this.toNodeData(data);
|
|
416
|
-
if (c.type === 'clear') {
|
|
417
|
-
this.input.clear();
|
|
418
|
-
} else if (c.type === 'command') {
|
|
419
|
-
if (Array.isArray(c.value)) {
|
|
420
|
-
c.value.forEach(vv => {
|
|
421
|
-
this.input.cmd(vv);
|
|
422
|
-
});
|
|
423
|
-
} else {
|
|
424
|
-
this.input.cmd(c.value);
|
|
425
|
-
}
|
|
426
|
-
} else if (c.type === 'cursor') {
|
|
427
|
-
this.input.keystroke(c.value);
|
|
428
|
-
} else {
|
|
429
|
-
this.input.write(c.value);
|
|
430
|
-
}
|
|
431
|
-
this.input.focus();
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
__init8() {
|
|
435
|
-
this.callOnSessionChange = () => {
|
|
436
|
-
const {onSessionChange} = this.props;
|
|
437
|
-
if (onSessionChange) {
|
|
438
|
-
onSessionChange(this.state.session);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
__init9() {
|
|
443
|
-
this.toggleShowCorrect = show => {
|
|
444
|
-
this.setState({
|
|
445
|
-
showCorrect: show
|
|
446
|
-
}, this.handleAnswerBlockDomUpdate);
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
__init10() {
|
|
450
|
-
this.subFieldChanged = (name, subfieldValue) => {
|
|
451
|
-
updateSpans();
|
|
452
|
-
if (name) {
|
|
453
|
-
this.setState(state => ({
|
|
454
|
-
session: {
|
|
455
|
-
...state.session,
|
|
456
|
-
completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
|
|
457
|
-
answers: {
|
|
458
|
-
...state.session.answers,
|
|
459
|
-
[name]: {
|
|
460
|
-
value: subfieldValue
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}), this.callOnSessionChange);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
__init11() {
|
|
469
|
-
this.getFieldName = (changeField, fields) => {
|
|
470
|
-
const {answers} = this.state.session;
|
|
471
|
-
if (Object.keys(answers || ({})).length) {
|
|
472
|
-
const keys = Object.keys(answers);
|
|
473
|
-
return keys.find(k => {
|
|
474
|
-
const tf = fields[k];
|
|
475
|
-
return tf && tf.id == changeField.id;
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
__init12() {
|
|
481
|
-
this.onBlur = e => {
|
|
482
|
-
const {relatedTarget, currentTarget} = e || ({});
|
|
483
|
-
if (!relatedTarget || !currentTarget || !IS_SAFARI && !_optionalChain([relatedTarget, 'optionalAccess', _13 => _13.offsetParent, 'optionalAccess', _14 => _14.children, 'access', _15 => _15[0], 'optionalAccess', _16 => _16.attributes, 'optionalAccess', _17 => _17['data-keypad']]) || IS_SAFARI && !_optionalChain([relatedTarget, 'optionalAccess', _18 => _18.offsetParent, 'optionalAccess', _19 => _19.children, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.children, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.attributes, 'optionalAccess', _24 => _24['data-keypad']])) {
|
|
484
|
-
this.setState({
|
|
485
|
-
activeAnswerBlock: ''
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
setTooltipRef(ref) {
|
|
491
|
-
setTimeout(() => {
|
|
492
|
-
if (ref && IS_SAFARI) {
|
|
493
|
-
const div = document.querySelector('[role=\'tooltip\']');
|
|
494
|
-
if (div) {
|
|
495
|
-
const el = div.firstChild;
|
|
496
|
-
el.setAttribute('tabindex', '-1');
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}, 1);
|
|
500
|
-
}
|
|
501
|
-
render() {
|
|
502
|
-
const {model, classes} = this.props;
|
|
503
|
-
const {activeAnswerBlock, showCorrect, session} = this.state;
|
|
504
|
-
const {config, correctness, disabled, view, teacherInstructions, rationale, feedback, animationsDisabled, printMode, alwaysShowCorrect} = model || ({});
|
|
505
|
-
if (!config) {
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
const {showNote, note, prompt, responses, responseType, equationEditor, customKeys, env: {mode, role} = {}} = config || ({});
|
|
509
|
-
const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;
|
|
510
|
-
const emptyResponse = isEmpty(responses);
|
|
511
|
-
const showCorrectAnswerToggle = !emptyResponse && correctness && correctness.correctness !== 'correct';
|
|
512
|
-
const tooltipModeEnabled = disabled && correctness;
|
|
513
|
-
const additionalKeys = generateAdditionalKeys(customKeys);
|
|
514
|
-
const correct = correctness && correctness.correct;
|
|
515
|
-
const staticLatex = prepareForStatic(model, this.state) || '';
|
|
516
|
-
const viewMode = disabled && !correctness;
|
|
517
|
-
const studentPrintMode = printMode && !alwaysShowCorrect;
|
|
518
|
-
const printView = React$1.createElement('div', {
|
|
519
|
-
className: classes.printContainer,
|
|
520
|
-
__self: this,
|
|
521
|
-
__source: {
|
|
522
|
-
fileName: _jsxFileName,
|
|
523
|
-
lineNumber: 411
|
|
524
|
-
}
|
|
525
|
-
}, React$1.createElement(mq.Static, {
|
|
526
|
-
ref: mqStatic => this.mqStatic = mqStatic || this.mqStatic,
|
|
527
|
-
latex: staticLatex,
|
|
528
|
-
onSubFieldChange: this.subFieldChanged,
|
|
529
|
-
getFieldName: this.getFieldName,
|
|
530
|
-
setInput: this.setInput,
|
|
531
|
-
onSubFieldFocus: this.onSubFieldFocus,
|
|
532
|
-
onBlur: this.onBlur,
|
|
533
|
-
__self: this,
|
|
534
|
-
__source: {
|
|
535
|
-
fileName: _jsxFileName,
|
|
536
|
-
lineNumber: 412
|
|
537
|
-
}
|
|
538
|
-
}));
|
|
539
|
-
const midContent = React$1.createElement('div', {
|
|
540
|
-
className: classes.main,
|
|
541
|
-
__self: this,
|
|
542
|
-
__source: {
|
|
543
|
-
fileName: _jsxFileName,
|
|
544
|
-
lineNumber: 424
|
|
545
|
-
}
|
|
546
|
-
}, prompt && React$1.createElement('div', {
|
|
547
|
-
className: classes.content,
|
|
548
|
-
__self: this,
|
|
549
|
-
__source: {
|
|
550
|
-
fileName: _jsxFileName,
|
|
551
|
-
lineNumber: 426
|
|
552
|
-
}
|
|
553
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
554
|
-
prompt: prompt,
|
|
555
|
-
__self: this,
|
|
556
|
-
__source: {
|
|
557
|
-
fileName: _jsxFileName,
|
|
558
|
-
lineNumber: 427
|
|
559
|
-
}
|
|
560
|
-
})), studentPrintMode ? printView : React$1.createElement(Readable, {
|
|
561
|
-
false: true,
|
|
562
|
-
__self: this,
|
|
563
|
-
__source: {
|
|
564
|
-
fileName: _jsxFileName,
|
|
565
|
-
lineNumber: 430
|
|
566
|
-
}
|
|
567
|
-
}, React$1.createElement('div', {
|
|
568
|
-
className: classes.inputAndKeypadContainer,
|
|
569
|
-
__self: this,
|
|
570
|
-
__source: {
|
|
571
|
-
fileName: _jsxFileName,
|
|
572
|
-
lineNumber: 431
|
|
573
|
-
}
|
|
574
|
-
}, responseType === ResponseTypes.simple && React$1.createElement(SimpleQuestionBlock, {
|
|
575
|
-
onSimpleResponseChange: this.onSimpleResponseChange,
|
|
576
|
-
showCorrect: showCorrect,
|
|
577
|
-
emptyResponse: emptyResponse,
|
|
578
|
-
model: model,
|
|
579
|
-
session: session,
|
|
580
|
-
__self: this,
|
|
581
|
-
__source: {
|
|
582
|
-
fileName: _jsxFileName,
|
|
583
|
-
lineNumber: 433
|
|
584
|
-
}
|
|
585
|
-
}), responseType === ResponseTypes.advanced && React$1.createElement('div', {
|
|
586
|
-
className: cx(classes.expression, {
|
|
587
|
-
[classes.incorrect]: !emptyResponse && !correct && !showCorrect,
|
|
588
|
-
[classes.correct]: !emptyResponse && (correct || showCorrect),
|
|
589
|
-
[classes.showCorrectness]: !emptyResponse && disabled && correctness && !view,
|
|
590
|
-
[classes.correctAnswerShown]: showCorrect,
|
|
591
|
-
[classes.printCorrect]: printMode && alwaysShowCorrect
|
|
592
|
-
}),
|
|
593
|
-
__self: this,
|
|
594
|
-
__source: {
|
|
595
|
-
fileName: _jsxFileName,
|
|
596
|
-
lineNumber: 442
|
|
597
|
-
}
|
|
598
|
-
}, React$1.createElement(Tooltip, {
|
|
599
|
-
ref: ref => this.setTooltipRef(ref),
|
|
600
|
-
interactive: true,
|
|
601
|
-
open: !!activeAnswerBlock,
|
|
602
|
-
classes: {
|
|
603
|
-
tooltip: classes.keypadTooltip,
|
|
604
|
-
popper: classes.keypadTooltipPopper
|
|
605
|
-
},
|
|
606
|
-
title: Object.keys(session.answers).map(answerId => answerId === activeAnswerBlock && !(showCorrect || disabled) && React$1.createElement('div', {
|
|
607
|
-
'data-keypad': true,
|
|
608
|
-
key: answerId,
|
|
609
|
-
className: classes.responseContainer,
|
|
610
|
-
style: {
|
|
611
|
-
width: getKeyPadWidth(additionalKeys, equationEditor)
|
|
612
|
-
},
|
|
613
|
-
__self: this,
|
|
614
|
-
__source: {
|
|
615
|
-
fileName: _jsxFileName,
|
|
616
|
-
lineNumber: 463
|
|
617
|
-
}
|
|
618
|
-
}, React$1.createElement(HorizontalKeypad, {
|
|
619
|
-
additionalKeys: additionalKeys,
|
|
620
|
-
mode: equationEditor || DEFAULT_KEYPAD_VARIANT,
|
|
621
|
-
onClick: this.onClick,
|
|
622
|
-
__self: this,
|
|
623
|
-
__source: {
|
|
624
|
-
fileName: _jsxFileName,
|
|
625
|
-
lineNumber: 472
|
|
626
|
-
}
|
|
627
|
-
})) || null),
|
|
628
|
-
__self: this,
|
|
629
|
-
__source: {
|
|
630
|
-
fileName: _jsxFileName,
|
|
631
|
-
lineNumber: 451
|
|
632
|
-
}
|
|
633
|
-
}, React$1.createElement(mq.Static, {
|
|
634
|
-
ref: mqStatic => this.mqStatic = mqStatic || this.mqStatic,
|
|
635
|
-
latex: staticLatex,
|
|
636
|
-
onSubFieldChange: this.subFieldChanged,
|
|
637
|
-
getFieldName: this.getFieldName,
|
|
638
|
-
setInput: this.setInput,
|
|
639
|
-
onSubFieldFocus: this.onSubFieldFocus,
|
|
640
|
-
onBlur: this.onBlur,
|
|
641
|
-
__self: this,
|
|
642
|
-
__source: {
|
|
643
|
-
fileName: _jsxFileName,
|
|
644
|
-
lineNumber: 482
|
|
645
|
-
}
|
|
646
|
-
}))))), viewMode && teacherInstructions && hasText(teacherInstructions) && React$1.createElement(React$1.Fragment, {
|
|
647
|
-
__self: this,
|
|
648
|
-
__source: {
|
|
649
|
-
fileName: _jsxFileName,
|
|
650
|
-
lineNumber: 498
|
|
651
|
-
}
|
|
652
|
-
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
653
|
-
labels: {
|
|
654
|
-
hidden: 'Show Teacher Instructions',
|
|
655
|
-
visible: 'Hide Teacher Instructions'
|
|
656
|
-
},
|
|
657
|
-
__self: this,
|
|
658
|
-
__source: {
|
|
659
|
-
fileName: _jsxFileName,
|
|
660
|
-
lineNumber: 499
|
|
661
|
-
}
|
|
662
|
-
}, React$1.createElement('div', {
|
|
663
|
-
dangerouslySetInnerHTML: {
|
|
664
|
-
__html: teacherInstructions
|
|
665
|
-
},
|
|
666
|
-
__self: this,
|
|
667
|
-
__source: {
|
|
668
|
-
fileName: _jsxFileName,
|
|
669
|
-
lineNumber: 502
|
|
670
|
-
}
|
|
671
|
-
})) : React$1.createElement('div', {
|
|
672
|
-
dangerouslySetInnerHTML: {
|
|
673
|
-
__html: teacherInstructions
|
|
674
|
-
},
|
|
675
|
-
__self: this,
|
|
676
|
-
__source: {
|
|
677
|
-
fileName: _jsxFileName,
|
|
678
|
-
lineNumber: 503
|
|
679
|
-
}
|
|
680
|
-
}), React$1.createElement('br', {
|
|
681
|
-
__self: this,
|
|
682
|
-
__source: {
|
|
683
|
-
fileName: _jsxFileName,
|
|
684
|
-
lineNumber: 504
|
|
685
|
-
}
|
|
686
|
-
})), viewMode && rationale && hasText(rationale) && React$1.createElement(React$1.Fragment, {
|
|
687
|
-
__self: this,
|
|
688
|
-
__source: {
|
|
689
|
-
fileName: _jsxFileName,
|
|
690
|
-
lineNumber: 510
|
|
691
|
-
}
|
|
692
|
-
}, !animationsDisabled ? React$1.createElement(Collapsible, {
|
|
693
|
-
labels: {
|
|
694
|
-
hidden: 'Show Rationale',
|
|
695
|
-
visible: 'Hide Rationale'
|
|
696
|
-
},
|
|
697
|
-
__self: this,
|
|
698
|
-
__source: {
|
|
699
|
-
fileName: _jsxFileName,
|
|
700
|
-
lineNumber: 511
|
|
701
|
-
}
|
|
702
|
-
}, React$1.createElement('div', {
|
|
703
|
-
dangerouslySetInnerHTML: {
|
|
704
|
-
__html: rationale
|
|
705
|
-
},
|
|
706
|
-
__self: this,
|
|
707
|
-
__source: {
|
|
708
|
-
fileName: _jsxFileName,
|
|
709
|
-
lineNumber: 514
|
|
710
|
-
}
|
|
711
|
-
})) : React$1.createElement('div', {
|
|
712
|
-
dangerouslySetInnerHTML: {
|
|
713
|
-
__html: rationale
|
|
714
|
-
},
|
|
715
|
-
__self: this,
|
|
716
|
-
__source: {
|
|
717
|
-
fileName: _jsxFileName,
|
|
718
|
-
lineNumber: 515
|
|
719
|
-
}
|
|
720
|
-
})), viewMode && displayNote && React$1.createElement('div', {
|
|
721
|
-
className: classes.note,
|
|
722
|
-
dangerouslySetInnerHTML: {
|
|
723
|
-
__html: `<strong>Note:</strong> ${note}`
|
|
724
|
-
},
|
|
725
|
-
__self: this,
|
|
726
|
-
__source: {
|
|
727
|
-
fileName: _jsxFileName,
|
|
728
|
-
lineNumber: 521
|
|
729
|
-
}
|
|
730
|
-
}));
|
|
731
|
-
if (tooltipModeEnabled && (showCorrectAnswerToggle || teacherInstructions || rationale || feedback)) {
|
|
732
|
-
return React$1.createElement(Tooltip, {
|
|
733
|
-
interactive: true,
|
|
734
|
-
classes: {
|
|
735
|
-
tooltip: classes.tooltip,
|
|
736
|
-
popper: classes.tooltipPopper
|
|
737
|
-
},
|
|
738
|
-
title: React$1.createElement('div', {
|
|
739
|
-
__self: this,
|
|
740
|
-
__source: {
|
|
741
|
-
fileName: _jsxFileName,
|
|
742
|
-
lineNumber: 539
|
|
743
|
-
}
|
|
744
|
-
}, React$1.createElement('div', {
|
|
745
|
-
className: classes.main,
|
|
746
|
-
__self: this,
|
|
747
|
-
__source: {
|
|
748
|
-
fileName: _jsxFileName,
|
|
749
|
-
lineNumber: 540
|
|
750
|
-
}
|
|
751
|
-
}, showCorrectAnswerToggle && React$1.createElement(CorrectAnswerToggle, {
|
|
752
|
-
className: classes.toggle,
|
|
753
|
-
show: true,
|
|
754
|
-
toggled: showCorrect,
|
|
755
|
-
onToggle: this.toggleShowCorrect,
|
|
756
|
-
__self: this,
|
|
757
|
-
__source: {
|
|
758
|
-
fileName: _jsxFileName,
|
|
759
|
-
lineNumber: 542
|
|
760
|
-
}
|
|
761
|
-
})), teacherInstructions && hasText(teacherInstructions) && [React$1.createElement(Collapsible, {
|
|
762
|
-
key: "collapsible",
|
|
763
|
-
labels: {
|
|
764
|
-
hidden: 'Show Teacher Instructions',
|
|
765
|
-
visible: 'Hide Teacher Instructions'
|
|
766
|
-
},
|
|
767
|
-
className: classes.collapsible,
|
|
768
|
-
__self: this,
|
|
769
|
-
__source: {
|
|
770
|
-
fileName: _jsxFileName,
|
|
771
|
-
lineNumber: 551
|
|
772
|
-
}
|
|
773
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
774
|
-
prompt: teacherInstructions,
|
|
775
|
-
__self: this,
|
|
776
|
-
__source: {
|
|
777
|
-
fileName: _jsxFileName,
|
|
778
|
-
lineNumber: 559
|
|
779
|
-
}
|
|
780
|
-
})), React$1.createElement('br', {
|
|
781
|
-
key: "br",
|
|
782
|
-
__self: this,
|
|
783
|
-
__source: {
|
|
784
|
-
fileName: _jsxFileName,
|
|
785
|
-
lineNumber: 561
|
|
786
|
-
}
|
|
787
|
-
})], rationale && hasText(rationale) && [React$1.createElement(Collapsible, {
|
|
788
|
-
key: "collapsible",
|
|
789
|
-
labels: {
|
|
790
|
-
hidden: 'Show Rationale',
|
|
791
|
-
visible: 'Hide Rationale'
|
|
792
|
-
},
|
|
793
|
-
__self: this,
|
|
794
|
-
__source: {
|
|
795
|
-
fileName: _jsxFileName,
|
|
796
|
-
lineNumber: 564
|
|
797
|
-
}
|
|
798
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
799
|
-
prompt: rationale,
|
|
800
|
-
__self: this,
|
|
801
|
-
__source: {
|
|
802
|
-
fileName: _jsxFileName,
|
|
803
|
-
lineNumber: 571
|
|
804
|
-
}
|
|
805
|
-
})), React$1.createElement('br', {
|
|
806
|
-
key: "br",
|
|
807
|
-
__self: this,
|
|
808
|
-
__source: {
|
|
809
|
-
fileName: _jsxFileName,
|
|
810
|
-
lineNumber: 573
|
|
811
|
-
}
|
|
812
|
-
})], displayNote && hasText(note) && [React$1.createElement(Collapsible, {
|
|
813
|
-
key: "collapsible",
|
|
814
|
-
labels: {
|
|
815
|
-
hidden: 'Show Note',
|
|
816
|
-
visible: 'Hide Note'
|
|
817
|
-
},
|
|
818
|
-
__self: this,
|
|
819
|
-
__source: {
|
|
820
|
-
fileName: _jsxFileName,
|
|
821
|
-
lineNumber: 576
|
|
822
|
-
}
|
|
823
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
824
|
-
prompt: note,
|
|
825
|
-
__self: this,
|
|
826
|
-
__source: {
|
|
827
|
-
fileName: _jsxFileName,
|
|
828
|
-
lineNumber: 583
|
|
829
|
-
}
|
|
830
|
-
})), React$1.createElement('br', {
|
|
831
|
-
key: "br",
|
|
832
|
-
__self: this,
|
|
833
|
-
__source: {
|
|
834
|
-
fileName: _jsxFileName,
|
|
835
|
-
lineNumber: 585
|
|
836
|
-
}
|
|
837
|
-
})], feedback && React$1.createElement(Feedback, {
|
|
838
|
-
correctness: correctness.correctness,
|
|
839
|
-
feedback: feedback,
|
|
840
|
-
__self: this,
|
|
841
|
-
__source: {
|
|
842
|
-
fileName: _jsxFileName,
|
|
843
|
-
lineNumber: 588
|
|
844
|
-
}
|
|
845
|
-
})),
|
|
846
|
-
__self: this,
|
|
847
|
-
__source: {
|
|
848
|
-
fileName: _jsxFileName,
|
|
849
|
-
lineNumber: 532
|
|
850
|
-
}
|
|
851
|
-
}, React$1.createElement('div', {
|
|
852
|
-
className: classes.mainContainer,
|
|
853
|
-
ref: r => this.root = r || this.root,
|
|
854
|
-
__self: this,
|
|
855
|
-
__source: {
|
|
856
|
-
fileName: _jsxFileName,
|
|
857
|
-
lineNumber: 596
|
|
858
|
-
}
|
|
859
|
-
}, midContent));
|
|
860
|
-
}
|
|
861
|
-
return React$1.createElement('div', {
|
|
862
|
-
className: classes.mainContainer,
|
|
863
|
-
ref: r => this.root = r || this.root,
|
|
864
|
-
__self: this,
|
|
865
|
-
__source: {
|
|
866
|
-
fileName: _jsxFileName,
|
|
867
|
-
lineNumber: 606
|
|
868
|
-
}
|
|
869
|
-
}, midContent);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
Main.__initStatic();
|
|
873
|
-
const styles = theme => ({
|
|
874
|
-
mainContainer: {
|
|
875
|
-
display: 'inline-block'
|
|
876
|
-
},
|
|
877
|
-
tooltip: {
|
|
878
|
-
background: `${color.primaryLight()} !important`,
|
|
879
|
-
color: color.text(),
|
|
880
|
-
padding: theme.spacing.unit * 2,
|
|
881
|
-
border: `1px solid ${color.secondary()}`,
|
|
882
|
-
fontSize: '16px',
|
|
883
|
-
'& :not(.MathJax) > table tr': {
|
|
884
|
-
'&:nth-child(2n)': {
|
|
885
|
-
backgroundColor: 'unset !important'
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
},
|
|
889
|
-
tooltipPopper: {
|
|
890
|
-
opacity: 1
|
|
891
|
-
},
|
|
892
|
-
keypadTooltip: {
|
|
893
|
-
fontSize: 'initial',
|
|
894
|
-
background: 'transparent',
|
|
895
|
-
width: '600px',
|
|
896
|
-
marginTop: 0,
|
|
897
|
-
paddingTop: 0
|
|
898
|
-
},
|
|
899
|
-
keypadTooltipPopper: {
|
|
900
|
-
background: 'transparent',
|
|
901
|
-
width: '650px',
|
|
902
|
-
opacity: 1
|
|
903
|
-
},
|
|
904
|
-
main: {
|
|
905
|
-
width: '100%',
|
|
906
|
-
position: 'relative',
|
|
907
|
-
padding: theme.spacing.unit / 2,
|
|
908
|
-
backgroundColor: color.background(),
|
|
909
|
-
color: color.text()
|
|
910
|
-
},
|
|
911
|
-
title: {
|
|
912
|
-
fontSize: '1.1rem',
|
|
913
|
-
display: 'block',
|
|
914
|
-
marginTop: theme.spacing.unit * 2,
|
|
915
|
-
marginBottom: theme.spacing.unit
|
|
916
|
-
},
|
|
917
|
-
content: {
|
|
918
|
-
marginTop: theme.spacing.unit * 2
|
|
919
|
-
},
|
|
920
|
-
note: {
|
|
921
|
-
paddingTop: '15px'
|
|
922
|
-
},
|
|
923
|
-
collapsible: {
|
|
924
|
-
marginTop: theme.spacing.unit * 2
|
|
925
|
-
},
|
|
926
|
-
responseContainer: {
|
|
927
|
-
zIndex: 10,
|
|
928
|
-
minWidth: '400px',
|
|
929
|
-
marginTop: theme.spacing.unit * 2
|
|
930
|
-
},
|
|
931
|
-
expression: {
|
|
932
|
-
maxWidth: 'fit-content',
|
|
933
|
-
'& > .mq-math-mode': {
|
|
934
|
-
'& > .mq-root-block': {
|
|
935
|
-
'& > .mq-editable-field': {
|
|
936
|
-
minWidth: '10px',
|
|
937
|
-
margin: theme.spacing.unit * 2 / 3,
|
|
938
|
-
padding: theme.spacing.unit / 4
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
'& sup': {
|
|
942
|
-
top: 0
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
},
|
|
946
|
-
inputAndKeypadContainer: {
|
|
947
|
-
position: 'relative',
|
|
948
|
-
'& .mq-overarrow-inner': {
|
|
949
|
-
border: 'none !important',
|
|
950
|
-
padding: '0 !important'
|
|
951
|
-
},
|
|
952
|
-
'& .mq-overarrow-inner-right': {
|
|
953
|
-
display: 'none !important'
|
|
954
|
-
},
|
|
955
|
-
'& .mq-overarrow-inner-left': {
|
|
956
|
-
display: 'none !important'
|
|
957
|
-
},
|
|
958
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
959
|
-
minWidth: '1.23em',
|
|
960
|
-
'& *': {
|
|
961
|
-
lineHeight: '1 !important'
|
|
962
|
-
},
|
|
963
|
-
'&:before': {
|
|
964
|
-
top: '-0.4em',
|
|
965
|
-
left: '-1px'
|
|
966
|
-
},
|
|
967
|
-
'&:after': {
|
|
968
|
-
top: '-2.4em',
|
|
969
|
-
right: '-1px'
|
|
970
|
-
},
|
|
971
|
-
'&.mq-empty:after': {
|
|
972
|
-
top: '-0.45em'
|
|
973
|
-
}
|
|
974
|
-
},
|
|
975
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
976
|
-
'&:before': {
|
|
977
|
-
top: '-0.4em',
|
|
978
|
-
right: '-1px'
|
|
979
|
-
}
|
|
980
|
-
},
|
|
981
|
-
'& .mq-longdiv-inner': {
|
|
982
|
-
borderTop: '1px solid !important',
|
|
983
|
-
paddingTop: '1.5px !important'
|
|
984
|
-
},
|
|
985
|
-
'& .mq-parallelogram': {
|
|
986
|
-
lineHeight: 0.85
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
showCorrectness: {
|
|
990
|
-
border: '2px solid'
|
|
991
|
-
},
|
|
992
|
-
correctAnswerShown: {
|
|
993
|
-
padding: theme.spacing.unit,
|
|
994
|
-
letterSpacing: '0.5px'
|
|
995
|
-
},
|
|
996
|
-
printCorrect: {
|
|
997
|
-
border: `2px solid ${color.correct()} !important`
|
|
998
|
-
},
|
|
999
|
-
correct: {
|
|
1000
|
-
borderColor: `${color.correct()} !important`
|
|
1001
|
-
},
|
|
1002
|
-
incorrect: {
|
|
1003
|
-
borderColor: `${color.incorrect()} !important`
|
|
1004
|
-
},
|
|
1005
|
-
blockContainer: {
|
|
1006
|
-
margin: `${theme.spacing.unit}px !important`,
|
|
1007
|
-
display: 'inline-flex',
|
|
1008
|
-
border: '2px solid grey !important'
|
|
1009
|
-
},
|
|
1010
|
-
blockResponse: {
|
|
1011
|
-
flex: 2,
|
|
1012
|
-
color: 'grey',
|
|
1013
|
-
background: 'lightgrey',
|
|
1014
|
-
fontSize: '0.8rem !important',
|
|
1015
|
-
padding: `${theme.spacing.unit / 2}px !important`,
|
|
1016
|
-
display: 'flex',
|
|
1017
|
-
alignItems: 'center',
|
|
1018
|
-
justifyContent: 'center',
|
|
1019
|
-
borderRight: `2px solid ${color.disabled()} !important`
|
|
1020
|
-
},
|
|
1021
|
-
toggle: {
|
|
1022
|
-
color: color.text()
|
|
1023
|
-
},
|
|
1024
|
-
blockMath: {
|
|
1025
|
-
color: color.text(),
|
|
1026
|
-
backgroundColor: color.background(),
|
|
1027
|
-
padding: `${theme.spacing.unit / 2}px !important`,
|
|
1028
|
-
display: 'flex',
|
|
1029
|
-
alignItems: 'center',
|
|
1030
|
-
justifyContent: 'center',
|
|
1031
|
-
flex: 8,
|
|
1032
|
-
'& > .mq-math-mode': {
|
|
1033
|
-
'& > .mq-hasCursor': {
|
|
1034
|
-
'& > .mq-cursor': {
|
|
1035
|
-
display: 'none'
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
},
|
|
1040
|
-
printContainer: {
|
|
1041
|
-
marginBottom: '10px',
|
|
1042
|
-
pointerEvents: 'none'
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
var Main$1 = withStyles(styles)(Main);
|
|
1046
|
-
const React = _dll_react;
|
|
1047
|
-
const ReactDOM = _dll_react_dom;
|
|
1048
|
-
const {debounce: debounce} = _dll_lodash;
|
|
1049
|
-
const debug = _dll_debug;
|
|
1050
|
-
const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
|
|
1051
|
-
const log = debug('pie-element:math-inline:print');
|
|
1052
|
-
const preparePrintModel = (model, opts) => {
|
|
1053
|
-
const instr = opts.role === 'instructor';
|
|
1054
|
-
model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
|
|
1055
|
-
model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
|
|
1056
|
-
model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;
|
|
1057
|
-
model.showTeacherInstructions = instr;
|
|
1058
|
-
model.alwaysShowCorrect = instr;
|
|
1059
|
-
model.printMode = true;
|
|
1060
|
-
model.feedback = undefined;
|
|
1061
|
-
model.expression = model.expression || '{{response}}';
|
|
1062
|
-
model.animationsDisabled = true;
|
|
1063
|
-
return {
|
|
1064
|
-
...model,
|
|
1065
|
-
disabled: true,
|
|
1066
|
-
config: {
|
|
1067
|
-
...model,
|
|
1068
|
-
env: {
|
|
1069
|
-
mode: instr ? 'evaluate' : model.mode,
|
|
1070
|
-
role: opts.role
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
};
|
|
1075
|
-
class MathInlinePrint extends HTMLElement {
|
|
1076
|
-
constructor() {
|
|
1077
|
-
super();
|
|
1078
|
-
this._options = null;
|
|
1079
|
-
this._model = null;
|
|
1080
|
-
this._session = [];
|
|
1081
|
-
this._rerender = debounce(() => {
|
|
1082
|
-
if (this._model && this._session) {
|
|
1083
|
-
const printModel = preparePrintModel(this._model, this._options);
|
|
1084
|
-
const element = this._options && React.createElement(Main$1, {
|
|
1085
|
-
model: printModel,
|
|
1086
|
-
session: {}
|
|
1087
|
-
});
|
|
1088
|
-
ReactDOM.render(element, this, () => {
|
|
1089
|
-
log('render complete - render math');
|
|
1090
|
-
renderMath(this);
|
|
1091
|
-
});
|
|
1092
|
-
} else {
|
|
1093
|
-
log('skip');
|
|
1094
|
-
}
|
|
1095
|
-
}, 50, {
|
|
1096
|
-
leading: false,
|
|
1097
|
-
trailing: true
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
set options(o) {
|
|
1101
|
-
this._options = o;
|
|
1102
|
-
}
|
|
1103
|
-
set model(s) {
|
|
1104
|
-
this._model = s;
|
|
1105
|
-
this._rerender();
|
|
1106
|
-
}
|
|
1107
|
-
connectedCallback() {}
|
|
1108
|
-
}
|
|
1109
|
-
export {MathInlinePrint as default};
|