@pie-element/fraction-model 1.1.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.json +1 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE.md +5 -0
- package/README.md +18 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +12 -0
- package/configure/lib/card-bar.js +78 -0
- package/configure/lib/card-bar.js.map +1 -0
- package/configure/lib/defaults.js +103 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +225 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +302 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/model-options.js +221 -0
- package/configure/lib/model-options.js.map +1 -0
- package/configure/lib/number-text-field.js +103 -0
- package/configure/lib/number-text-field.js.map +1 -0
- package/configure/package.json +20 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +11 -0
- package/controller/lib/defaults.js +21 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +260 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +18 -0
- package/docs/config-schema.json +975 -0
- package/docs/config-schema.json.md +718 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +6 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +123 -0
- package/docs/pie-schema.json.md +93 -0
- package/lib/answer-fraction.js +161 -0
- package/lib/answer-fraction.js.map +1 -0
- package/lib/fraction-model-chart.js +343 -0
- package/lib/fraction-model-chart.js.map +1 -0
- package/lib/index.js +131 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +248 -0
- package/lib/main.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<fraction-model pie-id="1"></fraction-model>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"correctResponse": {
|
|
5
|
+
"description": "Array of ResponseObject for correct response",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"description": "Model for the",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"title": "ResponseObject",
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"id": {
|
|
14
|
+
"description": "Indicates the response id for bar or pie model",
|
|
15
|
+
"type": "number",
|
|
16
|
+
"title": "id"
|
|
17
|
+
},
|
|
18
|
+
"value": {
|
|
19
|
+
"description": "Indicates the selected response sector for model value",
|
|
20
|
+
"type": "number",
|
|
21
|
+
"title": "value"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"id",
|
|
26
|
+
"value"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"title": "correctResponse"
|
|
30
|
+
},
|
|
31
|
+
"title": {
|
|
32
|
+
"description": "The title prompt of the item",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"title": "title"
|
|
35
|
+
},
|
|
36
|
+
"question": {
|
|
37
|
+
"description": "The question prompt or item stem",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"title": "question"
|
|
40
|
+
},
|
|
41
|
+
"modelTypeSelected": {
|
|
42
|
+
"description": "Indicates if the model type should be Bar or Pie model",
|
|
43
|
+
"default": ": 'bar'",
|
|
44
|
+
"enum": [
|
|
45
|
+
"bar",
|
|
46
|
+
"pie"
|
|
47
|
+
],
|
|
48
|
+
"type": "string",
|
|
49
|
+
"title": "modelTypeSelected"
|
|
50
|
+
},
|
|
51
|
+
"maxModelSelected": {
|
|
52
|
+
"description": "Indicates max no of models to be selected",
|
|
53
|
+
"default": ": 1",
|
|
54
|
+
"type": "number",
|
|
55
|
+
"title": "maxModelSelected"
|
|
56
|
+
},
|
|
57
|
+
"partsPerModel": {
|
|
58
|
+
"description": "Indicates parts per model to be selected",
|
|
59
|
+
"default": ": 5",
|
|
60
|
+
"type": "number",
|
|
61
|
+
"title": "partsPerModel"
|
|
62
|
+
},
|
|
63
|
+
"allowedStudentConfig": {
|
|
64
|
+
"description": "Indicates if student can configure no of models and parts per model",
|
|
65
|
+
"default": ": false",
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"title": "allowedStudentConfig"
|
|
68
|
+
},
|
|
69
|
+
"showGraphLabels": {
|
|
70
|
+
"description": "Determines if graph labels visible or not",
|
|
71
|
+
"default": ": false",
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"title": "showGraphLabels"
|
|
74
|
+
},
|
|
75
|
+
"language": {
|
|
76
|
+
"description": "Indicates the language of the component\nSupported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX",
|
|
77
|
+
"type": "string",
|
|
78
|
+
"title": "language"
|
|
79
|
+
},
|
|
80
|
+
"id": {
|
|
81
|
+
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"title": "id"
|
|
84
|
+
},
|
|
85
|
+
"element": {
|
|
86
|
+
"description": "The html Element tag name",
|
|
87
|
+
"type": "string",
|
|
88
|
+
"title": "element"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"required": [
|
|
92
|
+
"correctResponse",
|
|
93
|
+
"element",
|
|
94
|
+
"id",
|
|
95
|
+
"question",
|
|
96
|
+
"title"
|
|
97
|
+
],
|
|
98
|
+
"definitions": {
|
|
99
|
+
"ResponseObject": {
|
|
100
|
+
"description": "Model for the",
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"title": "ResponseObject",
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"id": {
|
|
106
|
+
"description": "Indicates the response id for bar or pie model",
|
|
107
|
+
"type": "number",
|
|
108
|
+
"title": "id"
|
|
109
|
+
},
|
|
110
|
+
"value": {
|
|
111
|
+
"description": "Indicates the selected response sector for model value",
|
|
112
|
+
"type": "number",
|
|
113
|
+
"title": "value"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"required": [
|
|
117
|
+
"id",
|
|
118
|
+
"value"
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
123
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
The schema defines the following properties:
|
|
2
|
+
|
|
3
|
+
# `correctResponse` (array, required)
|
|
4
|
+
|
|
5
|
+
Array of ResponseObject for correct response
|
|
6
|
+
|
|
7
|
+
The object is an array with all elements of the type `object`.
|
|
8
|
+
|
|
9
|
+
The array object has the following properties:
|
|
10
|
+
|
|
11
|
+
## `id` (number, required)
|
|
12
|
+
|
|
13
|
+
Indicates the response id for bar or pie model
|
|
14
|
+
|
|
15
|
+
## `value` (number, required)
|
|
16
|
+
|
|
17
|
+
Indicates the selected response sector for model value
|
|
18
|
+
|
|
19
|
+
# `title` (string, required)
|
|
20
|
+
|
|
21
|
+
The title prompt of the item
|
|
22
|
+
|
|
23
|
+
# `question` (string, required)
|
|
24
|
+
|
|
25
|
+
The question prompt or item stem
|
|
26
|
+
|
|
27
|
+
# `modelTypeSelected` (string, enum)
|
|
28
|
+
|
|
29
|
+
Indicates if the model type should be Bar or Pie model
|
|
30
|
+
|
|
31
|
+
This element must be one of the following enum values:
|
|
32
|
+
|
|
33
|
+
* `bar`
|
|
34
|
+
* `pie`
|
|
35
|
+
|
|
36
|
+
Default: `": 'bar'"`
|
|
37
|
+
|
|
38
|
+
# `maxModelSelected` (number)
|
|
39
|
+
|
|
40
|
+
Indicates max no of models to be selected
|
|
41
|
+
|
|
42
|
+
Default: `": 1"`
|
|
43
|
+
|
|
44
|
+
# `partsPerModel` (number)
|
|
45
|
+
|
|
46
|
+
Indicates parts per model to be selected
|
|
47
|
+
|
|
48
|
+
Default: `": 5"`
|
|
49
|
+
|
|
50
|
+
# `allowedStudentConfig` (boolean)
|
|
51
|
+
|
|
52
|
+
Indicates if student can configure no of models and parts per model
|
|
53
|
+
|
|
54
|
+
Default: `": false"`
|
|
55
|
+
|
|
56
|
+
# `showGraphLabels` (boolean)
|
|
57
|
+
|
|
58
|
+
Determines if graph labels visible or not
|
|
59
|
+
|
|
60
|
+
Default: `": false"`
|
|
61
|
+
|
|
62
|
+
# `language` (string)
|
|
63
|
+
|
|
64
|
+
Indicates the language of the component
|
|
65
|
+
Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
|
|
66
|
+
|
|
67
|
+
# `id` (string, required)
|
|
68
|
+
|
|
69
|
+
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
70
|
+
|
|
71
|
+
# `element` (string, required)
|
|
72
|
+
|
|
73
|
+
The html Element tag name
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
# Sub Schemas
|
|
78
|
+
|
|
79
|
+
The schema defines the following additional types:
|
|
80
|
+
|
|
81
|
+
## `ResponseObject` (object)
|
|
82
|
+
|
|
83
|
+
Model for the
|
|
84
|
+
|
|
85
|
+
Properties of the `ResponseObject` object:
|
|
86
|
+
|
|
87
|
+
### `id` (number, required)
|
|
88
|
+
|
|
89
|
+
Indicates the response id for bar or pie model
|
|
90
|
+
|
|
91
|
+
### `value` (number, required)
|
|
92
|
+
|
|
93
|
+
Indicates the selected response sector for model value
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.AnswerFraction = void 0;
|
|
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
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _styles = require("@material-ui/core/styles");
|
|
29
|
+
|
|
30
|
+
var _core = require("@material-ui/core");
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
var AnswerFraction = /*#__PURE__*/function (_React$Component) {
|
|
41
|
+
(0, _inherits2["default"])(AnswerFraction, _React$Component);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(AnswerFraction);
|
|
44
|
+
|
|
45
|
+
function AnswerFraction() {
|
|
46
|
+
var _this;
|
|
47
|
+
|
|
48
|
+
(0, _classCallCheck2["default"])(this, AnswerFraction);
|
|
49
|
+
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
55
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onValueChange", function (key) {
|
|
56
|
+
return function (event) {
|
|
57
|
+
var _this$props = _this.props,
|
|
58
|
+
onAnswerChange = _this$props.onAnswerChange,
|
|
59
|
+
answers = _this$props.answers;
|
|
60
|
+
|
|
61
|
+
var newAnswers = _objectSpread({}, answers);
|
|
62
|
+
|
|
63
|
+
newAnswers[key] = parseInt(event.target.value);
|
|
64
|
+
onAnswerChange(newAnswers);
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
(0, _createClass2["default"])(AnswerFraction, [{
|
|
71
|
+
key: "render",
|
|
72
|
+
value: function render() {
|
|
73
|
+
var _this$props2 = this.props,
|
|
74
|
+
model = _this$props2.model,
|
|
75
|
+
classes = _this$props2.classes,
|
|
76
|
+
showCorrect = _this$props2.showCorrect,
|
|
77
|
+
answers = _this$props2.answers,
|
|
78
|
+
disabled = _this$props2.disabled;
|
|
79
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, model.allowedStudentConfig && /*#__PURE__*/_react["default"].createElement("div", {
|
|
80
|
+
className: classes.groupInline
|
|
81
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
82
|
+
className: classes.group
|
|
83
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
84
|
+
htmlFor: 'preview_number-of-models',
|
|
85
|
+
className: classes.inputLabel
|
|
86
|
+
}, "Number of Models"), /*#__PURE__*/_react["default"].createElement(_core.TextField, {
|
|
87
|
+
className: classes.textField,
|
|
88
|
+
id: "preview_number-of-models",
|
|
89
|
+
inputProps: {
|
|
90
|
+
min: 1,
|
|
91
|
+
max: model.maxModelSelected
|
|
92
|
+
},
|
|
93
|
+
name: "preview_number-of-models",
|
|
94
|
+
onChange: this.onValueChange('noOfModel'),
|
|
95
|
+
type: "number",
|
|
96
|
+
variant: "outlined",
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
value: showCorrect ? model.maxModelSelected : answers.noOfModel
|
|
99
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
100
|
+
className: classes.group
|
|
101
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
102
|
+
htmlFor: 'preview_parts-per-model',
|
|
103
|
+
className: classes.inputLabel
|
|
104
|
+
}, "Parts per Model"), /*#__PURE__*/_react["default"].createElement(_core.TextField, {
|
|
105
|
+
className: classes.textField,
|
|
106
|
+
id: "preview_parts-per-model",
|
|
107
|
+
inputProps: {
|
|
108
|
+
min: 1,
|
|
109
|
+
max: 9
|
|
110
|
+
},
|
|
111
|
+
name: "preview_parts-per-model",
|
|
112
|
+
onChange: this.onValueChange('partsPerModel'),
|
|
113
|
+
type: "number",
|
|
114
|
+
variant: "outlined",
|
|
115
|
+
disabled: disabled,
|
|
116
|
+
value: showCorrect ? model.partsPerModel : answers.partsPerModel
|
|
117
|
+
}))));
|
|
118
|
+
}
|
|
119
|
+
}]);
|
|
120
|
+
return AnswerFraction;
|
|
121
|
+
}(_react["default"].Component);
|
|
122
|
+
|
|
123
|
+
exports.AnswerFraction = AnswerFraction;
|
|
124
|
+
(0, _defineProperty2["default"])(AnswerFraction, "propTypes", {
|
|
125
|
+
classes: _propTypes["default"].object.isRequired,
|
|
126
|
+
model: _propTypes["default"].object.isRequired,
|
|
127
|
+
disabled: _propTypes["default"].bool.isRequired,
|
|
128
|
+
showCorrect: _propTypes["default"].bool.isRequired,
|
|
129
|
+
onAnswerChange: _propTypes["default"].func.isRequired,
|
|
130
|
+
answers: _propTypes["default"].object.isRequired
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
var styles = function styles() {
|
|
134
|
+
return {
|
|
135
|
+
groupInline: {
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
display: 'flex',
|
|
138
|
+
gap: '20px'
|
|
139
|
+
},
|
|
140
|
+
group: {
|
|
141
|
+
margin: '12px 0'
|
|
142
|
+
},
|
|
143
|
+
inputLabel: {
|
|
144
|
+
display: 'block',
|
|
145
|
+
marginBottom: '4px'
|
|
146
|
+
},
|
|
147
|
+
textField: {
|
|
148
|
+
width: '120px',
|
|
149
|
+
maxHeight: '40px',
|
|
150
|
+
'& [class^="MuiInputBase-root"]': {
|
|
151
|
+
height: 40,
|
|
152
|
+
fontSize: '14px'
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var _default = (0, _styles.withStyles)(styles)(AnswerFraction);
|
|
159
|
+
|
|
160
|
+
exports["default"] = _default;
|
|
161
|
+
//# sourceMappingURL=answer-fraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/answer-fraction.jsx"],"names":["AnswerFraction","key","event","props","onAnswerChange","answers","newAnswers","parseInt","target","value","model","classes","showCorrect","disabled","allowedStudentConfig","groupInline","group","inputLabel","textField","min","max","maxModelSelected","onValueChange","noOfModel","partsPerModel","React","Component","PropTypes","object","isRequired","bool","func","styles","alignItems","display","gap","margin","marginBottom","width","maxHeight","height","fontSize"],"mappings":"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","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { TextField } from '@material-ui/core';\n\nexport class AnswerFraction extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n onAnswerChange: PropTypes.func.isRequired,\n answers: PropTypes.object.isRequired,\n };\n\n /**\n * Function to trigger when value change from number selection\n * @param {string} key contains event change object\n * @returns updated answer change object\n */\n onValueChange = (key) => (event) => {\n const { onAnswerChange, answers } = this.props;\n const newAnswers = { ...answers };\n\n newAnswers[key] = parseInt(event.target.value);\n onAnswerChange(newAnswers);\n };\n\n render() {\n const { model, classes, showCorrect, answers, disabled } = this.props;\n\n return (\n <div>\n {model.allowedStudentConfig && (\n <div className={classes.groupInline}>\n <div className={classes.group}>\n <label htmlFor={'preview_number-of-models'} className={classes.inputLabel}>\n Number of Models\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_number-of-models\"\n inputProps={{ min: 1, max: model.maxModelSelected }}\n name=\"preview_number-of-models\"\n onChange={this.onValueChange('noOfModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.maxModelSelected : answers.noOfModel}\n />\n </div>\n <div className={classes.group}>\n <label htmlFor={'preview_parts-per-model'} className={classes.inputLabel}>\n Parts per Model\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_parts-per-model\"\n inputProps={{ min: 1, max: 9 }}\n name=\"preview_parts-per-model\"\n onChange={this.onValueChange('partsPerModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.partsPerModel : answers.partsPerModel}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n}\n\nconst styles = () => ({\n groupInline: {\n alignItems: 'center',\n display: 'flex',\n gap: '20px',\n },\n group: {\n margin: '12px 0',\n },\n inputLabel: {\n display: 'block',\n marginBottom: '4px',\n },\n textField: {\n width: '120px',\n maxHeight: '40px',\n '& [class^=\"MuiInputBase-root\"]': {\n height: 40,\n fontSize: '14px',\n },\n },\n});\n\nexport default withStyles(styles)(AnswerFraction);\n"],"file":"answer-fraction.js"}
|