@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
774 lines (769 loc) • 33.9 kB
JavaScript
/** @jsx jsx */ function _array_like_to_array(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _array_without_holes(arr) {
if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function _assert_this_initialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _call_super(_this, derived, args) {
derived = _get_prototype_of(derived);
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _create_class(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _get_prototype_of(o) {
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _set_prototype_of(subClass, superClass);
}
function _iterable_to_array(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _non_iterable_spread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_define_property(target, key, source[key]);
});
}
return target;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _object_spread_props(target, source) {
source = source != null ? source : {};
if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _possible_constructor_return(self, call) {
if (call && (_type_of(call) === "object" || typeof call === "function")) {
return call;
}
return _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _set_prototype_of(o, p);
}
function _to_consumable_array(arr) {
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _unsupported_iterable_to_array(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function _is_native_reflect_construct() {
try {
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch (_) {}
return (_is_native_reflect_construct = function() {
return !!result;
})();
}
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
import { Component } from 'react';
import PropTypes from 'prop-types';
import update from 'immutability-helper';
import sortBy from 'lodash/sortBy';
import get from 'lodash/get';
import omit from 'lodash/omit';
import NumberInput from '@instructure/quiz-number-input';
import { PresentationContent, ScreenReaderContent } from '@instructure/ui-a11y-content';
import { Text } from '@instructure/ui-text';
import { Table } from '@instructure/ui-table';
import { jsx } from '@instructure/emotion';
import { isScientificNotation } from '@instructure/quiz-scientific-notation';
import QuestionSettingsContainer from '../../common/edit/components/QuestionSettingsContainer';
import QuestionContainer from '../../common/edit/components/QuestionContainer';
import * as util from './util';
import FormulaSection from './FormulaSection';
import GenerateSolutionsService from './GenerateSolutionsService';
import VariableInput from './VariableInput';
import { mathjsIsLoaded, loadMathjs } from '../common/util';
import { toErrors } from '../../../util/instUIMessages';
import { variablesFromItemBody, parseFormulaDecimalSeparator } from '../../../util/formula';
import FormulaInteractionType from '../../../records/interactions/formula';
import withEditTools from '../../../util/withEditTools';
import withAsyncDeps from '../../../util/withAsyncDeps';
import generateStyle from './styles';
import generateComponentTheme from './theme';
import t from '@instructure/quiz-i18n/format-message';
import QuestionSettingsPanel from '../../common/edit/components/QuestionSettingsPanel';
import CalculatorOptionWithOqaatAlert from '../../common/edit/components/CalculatorOptionWithOqaatAlert';
import { withStyleOverrides, FormFieldGroup } from '@instructure/quiz-common';
/**
---
category: Formula
---
Formula Edit component
```jsx_example
class Example extends React.Component {
render () {
const variables = 'abcdefghijklmnopqrstuvwxyz'.split('')
const exampleProps = {
itemBody: variables.map(v => `\`${v}\``).join('+'),
scoringData: {
value: {
answerCount: '10',
answerPrecision: 0,
formula: variables.join('+'),
generatedSolutions: [],
numeric: {
marginType: 'absolute',
margin: 1,
},
scientificNotation: false,
variables: variables.map(char => ({
name: char,
min: 90000,
max: 99999,
precision: 0
}))
}
},
overrideEditableForRegrading: false,
additionalOptions: [{
key: 'outcomes',
title: 'Align to Outcomes',
component: 'Placeholder'
}]
}
return (
<FormulaEdit {...exampleProps} {...this.props} />
)
}
}
<SettingsSwitcher locales={LOCALES}>
<EditStateProvider>
<Example />
</EditStateProvider>
</SettingsSwitcher>
```
**/ var formatNumber = function(n) {
return isScientificNotation(n) ? n : Number(n);
};
var normalizeVariables = function(variables) {
return variables.map(function(group) {
return _object_spread_props(_object_spread({}, group), {
min: formatNumber(group.min),
max: formatNumber(group.max),
precision: Number(group.precision)
});
});
};
var FormulaEdit = /*#__PURE__*/ function(Component) {
"use strict";
_inherits(FormulaEdit, Component);
function FormulaEdit(props) {
_class_call_check(this, FormulaEdit);
var _this;
_this = _call_super(this, FormulaEdit, [
props
]), // ==============================
// HOOKS FOR GENERATING SOLUTIONS
// ==============================
_define_property(_this, "serviceOnStart", function() {
_this.setState({
status: util.STATUS_RUNNING
});
}), _define_property(_this, "serviceOnComplete", function(status) {
return function(solutions) {
_this.setState({
status: status
});
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: solutions
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
var message = util.buildSolutionsGeneratedMessage(status, solutions.length);
_this.props.notifyScreenreader("".concat(t('Solutions updated.'), " ").concat(message));
};
}), _define_property(_this, "serviceOnCancel", function() {
_this.setState({
status: util.STATUS_CANCELED
});
}), // ====================
// INPUT EVENT HANDLERS
// ====================
_define_property(_this, "handleCalculatorTypeChange", function(e, value) {
_this.props.changeItemState({
calculatorType: value
});
}), _define_property(_this, "handleItemBodyChange", function(itemBody) {
var newVariableNames = variablesFromItemBody(itemBody);
var oldVariables = _this.props.scoringData.value.variables;
var newVariables = [];
newVariableNames.forEach(function(variableName) {
var defaultVariable = {
name: variableName,
min: 0,
max: 10,
precision: 0
};
var newVariable = oldVariables.find(function(v) {
return v.name === variableName;
}) || defaultVariable;
newVariables.push(newVariable);
});
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
variables: {
$set: sortBy(newVariables, function(v) {
return v.name;
})
}
}
});
_this.props.changeItemState({
itemBody: itemBody,
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
}), _define_property(_this, "handleVariableChange", function(variableIdx, field) {
return function(value) {
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
variables: _define_property({}, variableIdx, _define_property({}, field, {
$set: value
}))
}
});
_this.props.changeItemState({
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
};
}), _define_property(_this, "handlePrecisionChange", function(variableIdx) {
return function(e, value, normalized) {
if (normalized === null) return;
var variable = _this.props.scoringData.value.variables[variableIdx];
if (normalized == variable.precision) return; // intentional double-equals
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
variables: _define_property({}, variableIdx, {
$set: {
name: variable.name,
precision: normalized,
min: util.toPrecision(variable.min, normalized),
max: util.toPrecision(variable.max, normalized)
}
})
}
});
_this.props.changeItemState({
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
};
}), _define_property(_this, "handleFormulaChange", function(e) {
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
formula: {
$set: e.target.value
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
}), _define_property(_this, "handleMarginOfErrorTypeChange", function(e, param) {
var value = param.value;
var scoringData = update(_this.props.scoringData, {
value: {
numeric: {
marginType: {
$set: value
}
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
}), _define_property(_this, "handleMarginOfErrorChange", function(e, value, normalizedValue) {
if (normalizedValue == _this.props.scoringData.value.numeric.margin) return; // intentional double-equals
var scoringData = update(_this.props.scoringData, {
value: {
numeric: {
margin: {
$set: Number(normalizedValue).toString()
}
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
}), _define_property(_this, "handleScientificNotationChange", function(e) {
var scientificNotation = !_this.props.scoringData.value.scientificNotation;
// The numeric scoring algorithm doesn't support scientific notation for margin of error
var numeric = scientificNotation ? {
type: 'exactResponse'
} : {
type: 'marginOfError',
marginType: 'absolute',
margin: 0
};
var scoringData = _object_spread_props(_object_spread({}, _this.props.scoringData), {
value: _object_spread_props(_object_spread({}, _this.props.scoringData.value), {
generatedSolutions: [],
numeric: numeric,
scientificNotation: scientificNotation
})
});
_this.props.changeItemState({
scoringData: scoringData
});
}), _define_property(_this, "handleAnswerCountChange", function(e, answerCount) {
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
answerCount: {
$set: answerCount
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
}), _define_property(_this, "handleAnswerPrecisionChange", function(_e, _answerPrecision, answerPrecisionNormalized) {
var answerPrecision = Number(answerPrecisionNormalized);
if (answerPrecision === Number(_this.props.scoringData.value.answerPrecision || 0)) return;
var scoringData = update(_this.props.scoringData, {
value: {
generatedSolutions: {
$set: []
},
answerPrecision: {
$set: answerPrecision
}
}
});
_this.props.changeItemState({
scoringData: scoringData
});
_this.generateSolutionsService.cancel();
}), _define_property(_this, "handleGenerateSolutions", function() {
var _this_props_scoringData_value = _this.props.scoringData.value, answerCount = _this_props_scoringData_value.answerCount, answerPrecision = _this_props_scoringData_value.answerPrecision, variables = _this_props_scoringData_value.variables, formula = _this_props_scoringData_value.formula, scientificNotation = _this_props_scoringData_value.scientificNotation;
var parsedAnswerCount = parseInt(answerCount, 10) || 0;
var scoringDataSetupErrors = _this.scoringDataSetupErrors();
if (Object.keys(scoringDataSetupErrors).length > 0) {
_this.notifyScreenreaderOfSetupErrors(scoringDataSetupErrors);
_this.setState({
status: util.STATUS_FORMULA_SETUP_INVALID
});
return;
} else if (_this.state.status === util.STATUS_FORMULA_SETUP_INVALID) {
_this.setState({
status: util.STATUS_STOPPED
});
}
_this.generateSolutionsService.start(parsedAnswerCount, normalizeVariables(variables), parseFormulaDecimalSeparator(_this.getLocale(), formula), answerPrecision, scientificNotation);
}), _define_property(_this, "getLocale", function() {
return _this.context.locale || 'en-US';
}), // ===================
// RENDERING FUNCTIONS
// ===================
_define_property(_this, "renderVariable", function(variableRecord, idx) {
var variableName = variableRecord.name;
var precision = Number(variableRecord.precision);
var errorPath = [
'scoringData',
'value',
'variables',
idx
];
return /*#__PURE__*/ jsx(Table.Row, {
key: variableName
}, /*#__PURE__*/ jsx(Table.RowHeader, null, /*#__PURE__*/ jsx(PresentationContent, null, variableName), /*#__PURE__*/ jsx(ScreenReaderContent, {
tabIndex: 0
}, t('Variable {variable}', {
variable: variableName
}))), /*#__PURE__*/ jsx(Table.Cell, null, /*#__PURE__*/ jsx(VariableInput, {
disabled: _this.props.overrideEditableForRegrading,
decimalPrecision: precision,
messages: toErrors(_this.errorsFor(_to_consumable_array(errorPath).concat([
'min'
]))),
onUpdate: _this.handleVariableChange(idx, 'min'),
value: variableRecord.min,
width: "6rem",
renderLabel: /*#__PURE__*/ jsx(ScreenReaderContent, null, t('Minimum value for variable {variable}', {
variable: variableName
}))
})), /*#__PURE__*/ jsx(Table.Cell, null, /*#__PURE__*/ jsx(VariableInput, {
disabled: _this.props.overrideEditableForRegrading,
decimalPrecision: precision,
messages: toErrors(_this.errorsFor(_to_consumable_array(errorPath).concat([
'max'
]))),
onUpdate: _this.handleVariableChange(idx, 'max'),
value: variableRecord.max,
width: "6rem",
renderLabel: /*#__PURE__*/ jsx(ScreenReaderContent, null, t('Maximum value for variable {variable}', {
variable: variableName
}))
})), /*#__PURE__*/ jsx(Table.Cell, null, /*#__PURE__*/ jsx(NumberInput, {
disabled: _this.props.overrideEditableForRegrading,
max: 10,
messages: toErrors(_this.errorsFor(_to_consumable_array(errorPath).concat([
'precision'
]))),
min: 0,
onChange: _this.handlePrecisionChange(idx),
showArrows: true,
step: 1,
value: variableRecord.precision,
width: "6rem",
renderLabel: /*#__PURE__*/ jsx(ScreenReaderContent, null, t('decimals of precision for variable {variable}', {
variable: variableName
}))
})));
});
_this.generateSolutionsService = new GenerateSolutionsService({
onStart: _this.serviceOnStart,
onSuccess: _this.serviceOnComplete(util.STATUS_STOPPED),
onFailure: _this.serviceOnComplete(util.STATUS_FAILED),
onCancel: _this.serviceOnCancel
});
_this.state = {
status: util.STATUS_STOPPED
};
return _this;
}
_create_class(FormulaEdit, [
{
// =================
// UTILITY FUNCTIONS
// =================
key: "scoringDataSetupErrors",
value: function scoringDataSetupErrors() {
var scoringDataErrors = get(this.errors(), [
'scoringData',
'value'
], {});
return omit(scoringDataErrors, [
'generatedSolutions'
]);
}
},
{
key: "notifyScreenreaderOfSetupErrors",
value: function notifyScreenreaderOfSetupErrors(sdSetupErrors) {
var _this = this;
var vars = Object.keys(sdSetupErrors.variables || {}).map(function(v) {
return _this.props.scoringData.value.variables[v].name.replace(/`/g, '');
});
var errorMsg;
if (vars.length > 0) {
errorMsg = t('variables containing errors: {vars}', {
vars: vars.join(', ')
});
}
if (this.props.scoringData.value.variables.length === 0) {
errorMsg = t('must define at least one variable');
}
if (errorMsg) {
this.props.notifyScreenreader(t('The following error prevented generating solutions: {errorMsg}', {
errorMsg: errorMsg
}));
}
}
},
{
key: "renderVariablesTable",
value: function renderVariablesTable() {
var variables = normalizeVariables(this.props.scoringData.value.variables);
return /*#__PURE__*/ jsx(Table, {
caption: ""
}, /*#__PURE__*/ jsx(Table.Body, null, /*#__PURE__*/ jsx(Table.Row, null, /*#__PURE__*/ jsx(Table.ColHeader, {
id: "formula-edit-variable"
}, t('Variable')), /*#__PURE__*/ jsx(Table.ColHeader, {
id: "formula-edit-min"
}, /*#__PURE__*/ jsx(ScreenReaderContent, null, t('Minimum Value')), /*#__PURE__*/ jsx(PresentationContent, null, /*#__PURE__*/ jsx("div", {
title: t('Minimum Value')
}, t('Min')))), /*#__PURE__*/ jsx(Table.ColHeader, {
id: "formula-edit-max"
}, /*#__PURE__*/ jsx(ScreenReaderContent, null, t('Maximum Value')), /*#__PURE__*/ jsx(PresentationContent, null, /*#__PURE__*/ jsx("div", {
title: t('Maximum Value')
}, t('Max')))), /*#__PURE__*/ jsx(Table.ColHeader, {
id: "formula-edit-decimals"
}, t('Decimals'))), variables.map(this.renderVariable)));
}
},
{
key: "errorsFor",
value: function errorsFor(path) {
if (!this.props.errorsAreShowing && this.state.status !== util.STATUS_FORMULA_SETUP_INVALID) {
return [];
}
return get(this.errors(), path, []);
}
},
{
key: "errors",
value: function errors() {
return new FormulaInteractionType(_object_spread_props(_object_spread({}, omit(this.props, [
'getErrors',
'scoringData'
])), {
scoringData: this.props.scoringData
})).getErrors();
}
},
{
key: "renderOptionsDescription",
value: function renderOptionsDescription() {
return /*#__PURE__*/ jsx(ScreenReaderContent, null, t('Formula options'));
}
},
{
key: "render",
value: function render() {
return /*#__PURE__*/ jsx("div", null, /*#__PURE__*/ jsx("div", null, /*#__PURE__*/ jsx(Text, {
color: "primary"
}, t('Enter your question, build a formula, and generate a set of possible answer' + ' combinations. Students will see the question with a randomly selected set' + ' of variables filled in and have to type the correct numerical answer.'))), /*#__PURE__*/ jsx("div", {
css: this.props.styles.sectionHeading
}, /*#__PURE__*/ jsx(Text, {
size: "large"
}, t('Question'))), /*#__PURE__*/ jsx("div", {
css: this.props.styles.instructions
}, /*#__PURE__*/ jsx(Text, {
color: "primary"
}, t('You can define variables by typing variable names surrounded by backticks (e.g., "what is 5 plus `x`?")'))), /*#__PURE__*/ jsx(QuestionContainer, {
disabled: this.props.overrideEditableForRegrading,
enableRichContentEditor: this.props.enableRichContentEditor,
itemBody: this.props.itemBody,
onDescriptionChange: this.handleItemBodyChange,
onModalClose: this.props.onModalClose,
onModalOpen: this.props.onModalOpen,
openImportModal: this.props.openImportModal,
stemErrors: this.errorsFor([
'itemBody'
]),
textareaRef: this.handleStemRef
}, /*#__PURE__*/ jsx("div", {
css: this.props.styles.sectionHeading
}, /*#__PURE__*/ jsx(Text, {
size: "large"
}, t('Answers'))), /*#__PURE__*/ jsx("div", {
css: this.props.styles.instructions
}, /*#__PURE__*/ jsx(Text, {
color: "primary"
}, t('Once you have entered your variables above, you should see them' + ' listed below. You can specify the range of possible values for' + ' each variable below.'))), /*#__PURE__*/ jsx("div", {
"data-section": "variable_definitions"
}, this.renderVariablesTable()), /*#__PURE__*/ jsx("div", {
"data-section": "formula"
}, /*#__PURE__*/ jsx(FormulaSection, {
locale: this.getLocale(),
formulaErrors: this.errorsFor([
'scoringData',
'value',
'formula'
]),
generatedSolutionsErrors: this.errorsFor([
'scoringData',
'value',
'generatedSolutions',
'$errors'
]),
handleAnswerCountChange: this.handleAnswerCountChange,
handleAnswerPrecisionChange: this.handleAnswerPrecisionChange,
handleFormulaChange: this.handleFormulaChange,
handleGenerateSolutions: this.handleGenerateSolutions,
handleMarginOfErrorTypeChange: this.handleMarginOfErrorTypeChange,
handleMarginOfErrorChange: this.handleMarginOfErrorChange,
handleScientificNotationChange: this.handleScientificNotationChange,
overrideEditableForRegrading: this.props.overrideEditableForRegrading,
scoringData: this.props.scoringData,
status: this.state.status
}))), /*#__PURE__*/ jsx(QuestionSettingsContainer, {
additionalOptions: this.props.additionalOptions
}, this.props.showCalculatorOption && /*#__PURE__*/ jsx(QuestionSettingsPanel, {
label: t('Options'),
defaultExpanded: true
}, /*#__PURE__*/ jsx(FormFieldGroup, {
rowSpacing: "small",
description: this.renderOptionsDescription()
}, /*#__PURE__*/ jsx(CalculatorOptionWithOqaatAlert, {
disabled: this.props.overrideEditableForRegrading,
calculatorValue: this.props.calculatorType,
onCalculatorTypeChange: this.handleCalculatorTypeChange,
oqaatChecked: this.props.oneQuestionAtATime,
onOqaatChange: this.props.setOneQuestionAtATime
})))));
}
}
]);
return FormulaEdit;
}(Component);
_define_property(FormulaEdit, "displayName", 'FormulaEdit');
_define_property(FormulaEdit, "componentId", "Quizzes".concat(FormulaEdit.displayName));
_define_property(FormulaEdit, "interactionType", FormulaInteractionType);
_define_property(FormulaEdit, "propTypes", _object_spread_props(_object_spread({
additionalOptions: PropTypes.array,
calculatorType: PropTypes.string,
changeItemState: PropTypes.func,
enableRichContentEditor: PropTypes.bool,
errorsAreShowing: PropTypes.bool,
interactionData: PropTypes.object,
itemBody: PropTypes.string,
notifyScreenreader: PropTypes.func.isRequired,
onModalClose: PropTypes.func,
onModalOpen: PropTypes.func,
oneQuestionAtATime: PropTypes.bool,
openImportModal: PropTypes.func,
overrideEditableForRegrading: PropTypes.bool,
properties: PropTypes.object,
scoringData: PropTypes.object,
setOneQuestionAtATime: PropTypes.func
}, withEditTools.injectedProps), {
styles: PropTypes.object,
showCalculatorOption: PropTypes.bool,
separatorConfig: PropTypes.shape({
decimalSeparator: PropTypes.string,
thousandSeparator: PropTypes.string
})
}));
_define_property(FormulaEdit, "defaultProps", {
additionalOptions: [],
calculatorType: 'none',
enableRichContentEditor: true,
oneQuestionAtATime: false,
overrideEditableForRegrading: false,
setOneQuestionAtATime: Function.prototype,
changeItemState: void 0,
errorsAreShowing: void 0,
interactionData: void 0,
itemBody: void 0,
onModalClose: void 0,
onModalOpen: void 0,
openImportModal: void 0,
properties: void 0,
scoringData: void 0,
showCalculatorOption: true
});
_define_property(FormulaEdit, "contextTypes", {
locale: PropTypes.string
});
export { FormulaEdit as default };
FormulaEdit = _ts_decorate([
withAsyncDeps(mathjsIsLoaded, loadMathjs),
withEditTools,
withStyleOverrides(generateStyle, generateComponentTheme)
], FormulaEdit);