@pie-element/fraction-model 6.2.2-beta.6 → 6.2.2-beta.8
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 +8 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/lib/card-bar.js +57 -0
- package/configure/lib/card-bar.js.map +1 -0
- package/configure/lib/defaults.js +114 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +164 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +253 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/model-options.js +144 -0
- package/configure/lib/model-options.js.map +1 -0
- package/configure/lib/number-text-field.js +47 -0
- package/configure/lib/number-text-field.js.map +1 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/defaults.js +20 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +215 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/answer-fraction.js +109 -0
- package/lib/answer-fraction.js.map +1 -0
- package/lib/fraction-model-chart.js +279 -0
- package/lib/fraction-model-chart.js.map +1 -0
- package/lib/index.js +92 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +203 -0
- package/lib/main.js.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.2.2-beta.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model@6.2.2-beta.7...@pie-element/fraction-model@6.2.2-beta.8) (2026-09-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/fraction-model
|
|
9
|
+
|
|
10
|
+
## [6.2.2-beta.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model@6.2.2-beta.6...@pie-element/fraction-model@6.2.2-beta.7) (2026-09-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/fraction-model
|
|
13
|
+
|
|
6
14
|
## [6.2.2-beta.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model@6.2.2-beta.5...@pie-element/fraction-model@6.2.2-beta.6) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/fraction-model
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.4.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model-configure@5.4.0-beta.13...@pie-element/fraction-model-configure@5.4.0-beta.14) (2026-09-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/fraction-model-configure
|
|
9
|
+
|
|
10
|
+
# [5.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model-configure@5.4.0-beta.12...@pie-element/fraction-model-configure@5.4.0-beta.13) (2026-09-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/fraction-model-configure
|
|
13
|
+
|
|
6
14
|
# [5.4.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model-configure@5.4.0-beta.11...@pie-element/fraction-model-configure@5.4.0-beta.12) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/fraction-model-configure
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _styles = require("@mui/material/styles");
|
|
11
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
12
|
+
var _HelpOutline = _interopRequireDefault(require("@mui/icons-material/HelpOutline"));
|
|
13
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
14
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
15
|
+
const StyledCardBar = (0, _styles.styled)('div')({
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'space-between'
|
|
18
|
+
});
|
|
19
|
+
const FlexContainer = (0, _styles.styled)('div')({
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center'
|
|
22
|
+
});
|
|
23
|
+
const StyledIconButton = (0, _styles.styled)(_IconButton.default)({
|
|
24
|
+
margin: 0,
|
|
25
|
+
padding: 0
|
|
26
|
+
});
|
|
27
|
+
const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
|
|
28
|
+
theme
|
|
29
|
+
}) => ({
|
|
30
|
+
'& .MuiTooltip-tooltip': {
|
|
31
|
+
fontSize: theme.typography.fontSize - 2
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
const CardBar = props => {
|
|
35
|
+
const {
|
|
36
|
+
header,
|
|
37
|
+
children,
|
|
38
|
+
mini,
|
|
39
|
+
info
|
|
40
|
+
} = props;
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(StyledCardBar, null, /*#__PURE__*/_react.default.createElement(FlexContainer, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
42
|
+
variant: mini ? 'h6' : 'h5'
|
|
43
|
+
}, header), info), children && /*#__PURE__*/_react.default.createElement(StyledTooltip, {
|
|
44
|
+
title: children
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(StyledIconButton, {
|
|
46
|
+
"aria-label": "Delete",
|
|
47
|
+
size: "large"
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement(_HelpOutline.default, null))));
|
|
49
|
+
};
|
|
50
|
+
CardBar.propTypes = {
|
|
51
|
+
mini: _propTypes.default.bool,
|
|
52
|
+
header: _propTypes.default.string,
|
|
53
|
+
children: _propTypes.default.node,
|
|
54
|
+
info: _propTypes.default.any
|
|
55
|
+
};
|
|
56
|
+
var _default = exports.default = CardBar;
|
|
57
|
+
//# sourceMappingURL=card-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-bar.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_Tooltip","_HelpOutline","_IconButton","_Typography","StyledCardBar","styled","display","justifyContent","FlexContainer","alignItems","StyledIconButton","IconButton","margin","padding","StyledTooltip","Tooltip","theme","fontSize","typography","CardBar","props","header","children","mini","info","default","createElement","variant","title","size","propTypes","PropTypes","bool","string","node","any","_default","exports"],"sources":["../src/card-bar.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport Tooltip from '@mui/material/Tooltip';\nimport HelpIcon from '@mui/icons-material/HelpOutline';\nimport IconButton from '@mui/material/IconButton';\nimport Typography from '@mui/material/Typography';\n\nconst StyledCardBar = styled('div')({\n display: 'flex',\n justifyContent: 'space-between',\n});\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledIconButton = styled(IconButton)({\n margin: 0,\n padding: 0,\n});\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n },\n}));\n\nconst CardBar = (props) => {\n const { header, children, mini, info } = props;\n\n return (\n <StyledCardBar>\n <FlexContainer>\n <Typography variant={mini ? 'h6' : 'h5'}>{header}</Typography>\n {info}\n </FlexContainer>\n {children && (\n <StyledTooltip title={children}>\n <StyledIconButton aria-label=\"Delete\" size=\"large\">\n <HelpIcon />\n </StyledIconButton>\n </StyledTooltip>\n )}\n </StyledCardBar>\n );\n};\n\nCardBar.propTypes = {\n mini: PropTypes.bool,\n header: PropTypes.string,\n children: PropTypes.node,\n info: PropTypes.any,\n};\n\nexport default CardBar;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAP,sBAAA,CAAAC,OAAA;AAEA,MAAMO,aAAa,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC;EAClCC,OAAO,EAAE,MAAM;EACfC,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,aAAa,GAAG,IAAAH,cAAM,EAAC,KAAK,CAAC,CAAC;EAClCC,OAAO,EAAE,MAAM;EACfG,UAAU,EAAE;AACd,CAAC,CAAC;AAEF,MAAMC,gBAAgB,GAAG,IAAAL,cAAM,EAACM,mBAAU,CAAC,CAAC;EAC1CC,MAAM,EAAE,CAAC;EACTC,OAAO,EAAE;AACX,CAAC,CAAC;AAEF,MAAMC,aAAa,GAAG,IAAAT,cAAM,EAACU,gBAAO,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACpD,uBAAuB,EAAE;IACvBC,QAAQ,EAAED,KAAK,CAACE,UAAU,CAACD,QAAQ,GAAG;EACxC;AACF,CAAC,CAAC,CAAC;AAEH,MAAME,OAAO,GAAIC,KAAK,IAAK;EACzB,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC;EAAK,CAAC,GAAGJ,KAAK;EAE9C,oBACEzB,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAACtB,aAAa,qBACZT,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAAClB,aAAa,qBACZb,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAACvB,WAAA,CAAAsB,OAAU;IAACE,OAAO,EAAEJ,IAAI,GAAG,IAAI,GAAG;EAAK,GAAEF,MAAmB,CAAC,EAC7DG,IACY,CAAC,EACfF,QAAQ,iBACP3B,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAACZ,aAAa;IAACc,KAAK,EAAEN;EAAS,gBAC7B3B,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAAChB,gBAAgB;IAAC,cAAW,QAAQ;IAACmB,IAAI,EAAC;EAAO,gBAChDlC,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAACzB,YAAA,CAAAwB,OAAQ,MAAE,CACK,CACL,CAEJ,CAAC;AAEpB,CAAC;AAEDN,OAAO,CAACW,SAAS,GAAG;EAClBP,IAAI,EAAEQ,kBAAS,CAACC,IAAI;EACpBX,MAAM,EAAEU,kBAAS,CAACE,MAAM;EACxBX,QAAQ,EAAES,kBAAS,CAACG,IAAI;EACxBV,IAAI,EAAEO,kBAAS,CAACI;AAClB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEaN,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
model: {
|
|
9
|
+
correctResponse: [],
|
|
10
|
+
title: '',
|
|
11
|
+
prompt: '',
|
|
12
|
+
modelTypeSelected: 'bar',
|
|
13
|
+
maxModelSelected: 1,
|
|
14
|
+
partsPerModel: 5,
|
|
15
|
+
allowedStudentConfig: false,
|
|
16
|
+
showGraphLabels: false
|
|
17
|
+
},
|
|
18
|
+
configuration: {
|
|
19
|
+
baseInputConfiguration: {
|
|
20
|
+
h3: {
|
|
21
|
+
disabled: true
|
|
22
|
+
},
|
|
23
|
+
audio: {
|
|
24
|
+
disabled: false
|
|
25
|
+
},
|
|
26
|
+
video: {
|
|
27
|
+
disabled: false
|
|
28
|
+
},
|
|
29
|
+
image: {
|
|
30
|
+
disabled: false
|
|
31
|
+
},
|
|
32
|
+
textAlign: {
|
|
33
|
+
disabled: true
|
|
34
|
+
},
|
|
35
|
+
showParagraphs: {
|
|
36
|
+
disabled: false
|
|
37
|
+
},
|
|
38
|
+
separateParagraphs: {
|
|
39
|
+
disabled: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
title: {
|
|
43
|
+
label: 'Title',
|
|
44
|
+
settings: true,
|
|
45
|
+
enabled: true,
|
|
46
|
+
inputConfiguration: {
|
|
47
|
+
audio: {
|
|
48
|
+
disabled: false
|
|
49
|
+
},
|
|
50
|
+
video: {
|
|
51
|
+
disabled: false
|
|
52
|
+
},
|
|
53
|
+
image: {
|
|
54
|
+
disabled: false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
prompt: {
|
|
59
|
+
label: 'Question',
|
|
60
|
+
settings: true,
|
|
61
|
+
enabled: true,
|
|
62
|
+
inputConfiguration: {
|
|
63
|
+
audio: {
|
|
64
|
+
disabled: false
|
|
65
|
+
},
|
|
66
|
+
video: {
|
|
67
|
+
disabled: false
|
|
68
|
+
},
|
|
69
|
+
image: {
|
|
70
|
+
disabled: false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
modelOptions: {
|
|
75
|
+
maxOfModel: {
|
|
76
|
+
min: 1,
|
|
77
|
+
max: 9,
|
|
78
|
+
default: 1
|
|
79
|
+
},
|
|
80
|
+
partsPerModel: {
|
|
81
|
+
min: 1,
|
|
82
|
+
max: 9,
|
|
83
|
+
default: 5
|
|
84
|
+
},
|
|
85
|
+
modelTypeChoices: [{
|
|
86
|
+
value: 'bar',
|
|
87
|
+
label: 'Bar'
|
|
88
|
+
}, {
|
|
89
|
+
value: 'pie',
|
|
90
|
+
label: 'Pie'
|
|
91
|
+
}]
|
|
92
|
+
},
|
|
93
|
+
mathMlOptions: {
|
|
94
|
+
mmlOutput: false,
|
|
95
|
+
mmlEditing: false
|
|
96
|
+
},
|
|
97
|
+
language: {
|
|
98
|
+
settings: false,
|
|
99
|
+
label: 'Specify Language',
|
|
100
|
+
enabled: false
|
|
101
|
+
},
|
|
102
|
+
languageChoices: {
|
|
103
|
+
label: 'Language Choices',
|
|
104
|
+
options: []
|
|
105
|
+
},
|
|
106
|
+
spellCheck: {
|
|
107
|
+
label: 'Spellcheck',
|
|
108
|
+
settings: false,
|
|
109
|
+
enabled: true
|
|
110
|
+
},
|
|
111
|
+
settingsPanelDisabled: true
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["model","correctResponse","title","prompt","modelTypeSelected","maxModelSelected","partsPerModel","allowedStudentConfig","showGraphLabels","configuration","baseInputConfiguration","h3","disabled","audio","video","image","textAlign","showParagraphs","separateParagraphs","label","settings","enabled","inputConfiguration","modelOptions","maxOfModel","min","max","default","modelTypeChoices","value","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options","spellCheck","settingsPanelDisabled"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n model: {\n correctResponse: [],\n title: '',\n prompt: '',\n modelTypeSelected: 'bar',\n maxModelSelected: 1,\n partsPerModel: 5,\n allowedStudentConfig: false,\n showGraphLabels: false,\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n title: {\n label: 'Title',\n settings: true,\n enabled: true,\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n prompt: {\n label: 'Question',\n settings: true,\n enabled: true,\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n modelOptions: {\n maxOfModel: {\n min: 1,\n max: 9,\n default: 1,\n },\n partsPerModel: {\n min: 1,\n max: 9,\n default: 5,\n },\n modelTypeChoices: [\n { value: 'bar', label: 'Bar' },\n { value: 'pie', label: 'Pie' },\n ],\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n settingsPanelDisabled: true,\n },\n};\n"],"mappings":";;;;;;iCAAe;EACbA,KAAK,EAAE;IACLC,eAAe,EAAE,EAAE;IACnBC,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,iBAAiB,EAAE,KAAK;IACxBC,gBAAgB,EAAE,CAAC;IACnBC,aAAa,EAAE,CAAC;IAChBC,oBAAoB,EAAE,KAAK;IAC3BC,eAAe,EAAE;EACnB,CAAC;EACDC,aAAa,EAAE;IACbC,sBAAsB,EAAE;MACtBC,EAAE,EAAE;QAAEC,QAAQ,EAAE;MAAK,CAAC;MACtBC,KAAK,EAAE;QAAED,QAAQ,EAAE;MAAM,CAAC;MAC1BE,KAAK,EAAE;QAAEF,QAAQ,EAAE;MAAM,CAAC;MAC1BG,KAAK,EAAE;QAAEH,QAAQ,EAAE;MAAM,CAAC;MAC1BI,SAAS,EAAE;QAAEJ,QAAQ,EAAE;MAAK,CAAC;MAC7BK,cAAc,EAAE;QAAEL,QAAQ,EAAE;MAAM,CAAC;MACnCM,kBAAkB,EAAE;QAAEN,QAAQ,EAAE;MAAK;IACvC,CAAC;IACDV,KAAK,EAAE;MACLiB,KAAK,EAAE,OAAO;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,kBAAkB,EAAE;QACl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164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _client = require("react-dom/client");
|
|
11
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
12
|
+
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
13
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
14
|
+
class FractionModelConfigure extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "resetModelAfterConfigurationIsSet", () => {
|
|
18
|
+
// In environments that use pie-player-components, model is set before configuration.
|
|
19
|
+
// This is the reason why sometimes the model gets altered non-reversible
|
|
20
|
+
// (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)
|
|
21
|
+
// Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset
|
|
22
|
+
// the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called
|
|
23
|
+
const pieAuthors = document.querySelectorAll('pie-author');
|
|
24
|
+
this.hasPlayerAsParent = Array.from(pieAuthors).some(author => author.contains(this));
|
|
25
|
+
if (this.hasPlayerAsParent) {
|
|
26
|
+
if (this._modelCopy) {
|
|
27
|
+
this._model = this._modelCopy;
|
|
28
|
+
} else {
|
|
29
|
+
delete this._modelCopy;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
(0, _defineProperty2.default)(this, "onChange", o => {
|
|
34
|
+
this._model = {
|
|
35
|
+
...this._model,
|
|
36
|
+
...o
|
|
37
|
+
};
|
|
38
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model));
|
|
39
|
+
this.render();
|
|
40
|
+
});
|
|
41
|
+
this._root = null;
|
|
42
|
+
this._model = FractionModelConfigure.createDefaultModel();
|
|
43
|
+
this._configuration = _defaults.default.configuration;
|
|
44
|
+
}
|
|
45
|
+
set model(m) {
|
|
46
|
+
this._model = FractionModelConfigure.createDefaultModel(m);
|
|
47
|
+
this.render();
|
|
48
|
+
}
|
|
49
|
+
set configuration(c) {
|
|
50
|
+
const newConfiguration = {
|
|
51
|
+
..._defaults.default.configuration,
|
|
52
|
+
...c
|
|
53
|
+
};
|
|
54
|
+
this._configuration = newConfiguration;
|
|
55
|
+
this.resetModelAfterConfigurationIsSet();
|
|
56
|
+
|
|
57
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
58
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
59
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
60
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
61
|
+
if (newConfiguration?.language?.enabled) {
|
|
62
|
+
if (newConfiguration?.languageChoices?.options?.length) {
|
|
63
|
+
this._model.language = newConfiguration?.languageChoices.options[0].value;
|
|
64
|
+
}
|
|
65
|
+
} else if (newConfiguration.language.settings && this._model.language) {
|
|
66
|
+
this._configuration.language.enabled = true;
|
|
67
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
68
|
+
this._configuration.languageChoices.options = [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// check if the language is already included in the languageChoices.options array
|
|
72
|
+
// and if not, then add it.
|
|
73
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
74
|
+
this._configuration.languageChoices.options.push({
|
|
75
|
+
value: this._model.language,
|
|
76
|
+
label: this._model.language
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
delete this._model.language;
|
|
81
|
+
}
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
connectedCallback() {
|
|
85
|
+
this.render();
|
|
86
|
+
}
|
|
87
|
+
modelChanged(m) {
|
|
88
|
+
this._model = m;
|
|
89
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model), true);
|
|
90
|
+
this.render();
|
|
91
|
+
}
|
|
92
|
+
onConfigurationChanged(c) {
|
|
93
|
+
this._configuration = c;
|
|
94
|
+
this.render();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {done, progress, file} handler
|
|
100
|
+
*/
|
|
101
|
+
insertImage(handler) {
|
|
102
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
103
|
+
}
|
|
104
|
+
onDeleteImage(src, done) {
|
|
105
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
106
|
+
}
|
|
107
|
+
insertSound(handler) {
|
|
108
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
109
|
+
}
|
|
110
|
+
onDeleteSound(src, done) {
|
|
111
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
if (this._model) {
|
|
115
|
+
const el = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
116
|
+
classes: {},
|
|
117
|
+
model: this._model,
|
|
118
|
+
configuration: this._configuration,
|
|
119
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
120
|
+
onChange: this.onChange,
|
|
121
|
+
imageSupport: {
|
|
122
|
+
add: this.insertImage.bind(this),
|
|
123
|
+
delete: this.onDeleteImage.bind(this)
|
|
124
|
+
},
|
|
125
|
+
uploadSoundSupport: {
|
|
126
|
+
add: this.insertSound.bind(this),
|
|
127
|
+
delete: this.onDeleteSound.bind(this)
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (!this._root) {
|
|
131
|
+
this._root = (0, _client.createRoot)(this);
|
|
132
|
+
}
|
|
133
|
+
this._root.render(el);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
disconnectedCallback() {
|
|
137
|
+
if (this._root) {
|
|
138
|
+
this._root.unmount();
|
|
139
|
+
this._root = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.default = FractionModelConfigure;
|
|
144
|
+
/**
|
|
145
|
+
* This function makes sure you set the default values on the model
|
|
146
|
+
* @param model
|
|
147
|
+
* @returns model
|
|
148
|
+
*/
|
|
149
|
+
(0, _defineProperty2.default)(FractionModelConfigure, "createDefaultModel", (model = {}) => {
|
|
150
|
+
const c = _defaults.default.configuration;
|
|
151
|
+
let language = model.language || '';
|
|
152
|
+
if (!language && c.language && c.language.enabled) {
|
|
153
|
+
if (c.languageChoices?.options?.length) {
|
|
154
|
+
language = c.languageChoices.options[0].value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const normalizedModel = {
|
|
158
|
+
..._defaults.default.model,
|
|
159
|
+
...model,
|
|
160
|
+
language
|
|
161
|
+
};
|
|
162
|
+
return normalizedModel;
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_main","_pieConfigureEvents","_defaults","FractionModelConfigure","HTMLElement","constructor","_defineProperty2","default","pieAuthors","document","querySelectorAll","hasPlayerAsParent","Array","from","some","author","contains","_modelCopy","_model","o","dispatchEvent","ModelUpdatedEvent","render","_root","createDefaultModel","_configuration","defaultValues","configuration","model","m","c","newConfiguration","resetModelAfterConfigurationIsSet","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","connectedCallback","modelChanged","onConfigurationChanged","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","el","React","createElement","Main","classes","onChange","imageSupport","add","bind","delete","uploadSoundSupport","createRoot","disconnectedCallback","unmount","exports","normalizedModel"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Main from './main';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport defaultValues from './defaults';\n\nexport default class FractionModelConfigure extends HTMLElement {\n /**\n * This function makes sure you set the default values on the model\n * @param model\n * @returns model\n */\n static createDefaultModel = (model = {}) => {\n const c = defaultValues.configuration;\n let language = model.language || '';\n\n if (!language && c.language && c.language.enabled) {\n if (c.languageChoices?.options?.length) {\n language = c.languageChoices.options[0].value;\n }\n }\n\n const normalizedModel = {\n ...defaultValues.model,\n ...model,\n language,\n };\n\n return normalizedModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._model = FractionModelConfigure.createDefaultModel();\n this._configuration = defaultValues.configuration;\n }\n\n set model(m) {\n this._model = FractionModelConfigure.createDefaultModel(m);\n this.render();\n }\n\n set configuration(c) {\n const newConfiguration = {\n ...defaultValues.configuration,\n ...c,\n };\n this._configuration = newConfiguration;\n\n this.resetModelAfterConfigurationIsSet();\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n this.render();\n }\n\n resetModelAfterConfigurationIsSet = () => {\n // In environments that use pie-player-components, model is set before configuration.\n // This is the reason why sometimes the model gets altered non-reversible\n // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)\n // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset\n // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called\n const pieAuthors = document.querySelectorAll('pie-author');\n this.hasPlayerAsParent = Array.from(pieAuthors).some((author) => author.contains(this));\n\n if (this.hasPlayerAsParent) {\n if (this._modelCopy) {\n this._model = this._modelCopy;\n } else {\n delete this._modelCopy;\n }\n }\n };\n\n connectedCallback() {\n this.render();\n }\n\n modelChanged(m) {\n this._model = m;\n this.dispatchEvent(new ModelUpdatedEvent(this._model), true);\n this.render();\n }\n\n onChange = (o) => {\n this._model = { ...this._model, ...o };\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n this.render();\n };\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this.render();\n }\n\n /**\n *\n * @param {done, progress, file} handler\n */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n render() {\n if (this._model) {\n const el = React.createElement(Main, {\n classes: {},\n model: this._model,\n configuration: this._configuration,\n onConfigurationChanged: this.onConfigurationChanged,\n onChange: this.onChange,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAOA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEe,MAAMK,sBAAsB,SAASC,WAAW,CAAC;EAyB9DC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,6CAiD0B,MAAM;MACxC;MACA;MACA;MACA;MACA;MACA,MAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,YAAY,CAAC;MAC1D,IAAI,CAACC,iBAAiB,GAAGC,KAAK,CAACC,IAAI,CAACL,UAAU,CAAC,CAACM,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,QAAQ,CAAC,IAAI,CAAC,CAAC;MAEvF,IAAI,IAAI,CAACL,iBAAiB,EAAE;QAC1B,IAAI,IAAI,CAACM,UAAU,EAAE;UACnB,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,UAAU;QAC/B,CAAC,MAAM;UACL,OAAO,IAAI,CAACA,UAAU;QACxB;MACF;IACF,CAAC;IAAA,IAAAX,gBAAA,CAAAC,OAAA,oBAYWY,CAAC,IAAK;MAChB,IAAI,CAACD,MAAM,GAAG;QAAE,GAAG,IAAI,CAACA,MAAM;QAAE,GAAGC;MAAE,CAAC;MACtC,IAAI,CAACC,aAAa,CAAC,IAAIC,qCAAiB,CAAC,IAAI,CAACH,MAAM,CAAC,CAAC;MACtD,IAAI,CAACI,MAAM,CAAC,CAAC;IACf,CAAC;IAhFC,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACL,MAAM,GAAGf,sBAAsB,CAACqB,kBAAkB,CA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EAAE;EAEnC,IAAI,CAACA,QAAQ,IAAIH,CAAC,CAACG,QAAQ,IAAIH,CAAC,CAACG,QAAQ,CAACC,OAAO,EAAE;IACjD,IAAIJ,CAAC,CAACK,eAAe,EAAEC,OAAO,EAAEC,MAAM,EAAE;MACtCJ,QAAQ,GAAGH,CAAC,CAACK,eAAe,CAACC,OAAO,CAAC,CAAC,CAAC,CAACE,KAAK;IAC/C;EACF;EAEA,MAAMmC,eAAe,GAAG;IACtB,GAAG/C,iBAAa,CAACE,KAAK;IACtB,GAAGA,KAAK;IACRK;EACF,CAAC;EAED,OAAOwC,eAAe;AACxB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Main = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
12
|
+
var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
|
|
13
|
+
var _fractionModel = require("@pie-element/fraction-model");
|
|
14
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
15
|
+
var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
|
|
16
|
+
var _styles = require("@mui/material/styles");
|
|
17
|
+
var _cardBar = _interopRequireDefault(require("./card-bar"));
|
|
18
|
+
var _modelOptions = _interopRequireDefault(require("./model-options"));
|
|
19
|
+
const StyledFormSection = (0, _styles.styled)(_configUi.FormSection)(({
|
|
20
|
+
theme
|
|
21
|
+
}) => ({
|
|
22
|
+
marginBottom: theme.spacing(4)
|
|
23
|
+
}));
|
|
24
|
+
const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
|
|
25
|
+
theme
|
|
26
|
+
}) => ({
|
|
27
|
+
'& .MuiTooltip-tooltip': {
|
|
28
|
+
fontSize: theme.typography.fontSize - 2,
|
|
29
|
+
whiteSpace: 'pre',
|
|
30
|
+
maxWidth: '500px'
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
const ErrorMessage = (0, _styles.styled)('div')(({
|
|
34
|
+
theme
|
|
35
|
+
}) => ({
|
|
36
|
+
fontSize: theme.typography.fontSize - 2,
|
|
37
|
+
color: theme.palette.error.main,
|
|
38
|
+
marginTop: theme.spacing(1)
|
|
39
|
+
}));
|
|
40
|
+
const ModelErrorContainer = (0, _styles.styled)('div')(({
|
|
41
|
+
theme,
|
|
42
|
+
hasError
|
|
43
|
+
}) => ({
|
|
44
|
+
...(hasError && {
|
|
45
|
+
border: `2px solid ${theme.palette.error.main}`
|
|
46
|
+
})
|
|
47
|
+
}));
|
|
48
|
+
const Label = (0, _styles.styled)('label')(({
|
|
49
|
+
theme
|
|
50
|
+
}) => ({
|
|
51
|
+
marginBottom: theme.spacing(4)
|
|
52
|
+
}));
|
|
53
|
+
class Main extends _react.default.Component {
|
|
54
|
+
constructor(props) {
|
|
55
|
+
super(props);
|
|
56
|
+
/*
|
|
57
|
+
* Method to handle correct answer change
|
|
58
|
+
* @param {array} correctResponse - correct response
|
|
59
|
+
* */
|
|
60
|
+
(0, _defineProperty2.default)(this, "onCorrectAnswerChange", correctResponse => {
|
|
61
|
+
const {
|
|
62
|
+
model,
|
|
63
|
+
onChange
|
|
64
|
+
} = this.props;
|
|
65
|
+
model.correctResponse = correctResponse;
|
|
66
|
+
onChange({
|
|
67
|
+
...model
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
/*
|
|
71
|
+
* Method to handle model options change
|
|
72
|
+
* @param {object} oldModel - old model
|
|
73
|
+
* @param {object} newModel - new model
|
|
74
|
+
* @param {boolean} showDiag - show dialog or not
|
|
75
|
+
* */
|
|
76
|
+
(0, _defineProperty2.default)(this, "onModelOptionsChange", (oldModel, newModel, showDiag) => {
|
|
77
|
+
const {
|
|
78
|
+
onChange
|
|
79
|
+
} = this.props;
|
|
80
|
+
if (showDiag && oldModel.correctResponse.length > 0) {
|
|
81
|
+
this.setState({
|
|
82
|
+
correctAnswerChangeDialog: {
|
|
83
|
+
open: true,
|
|
84
|
+
oldModel: oldModel,
|
|
85
|
+
newModel: newModel,
|
|
86
|
+
text: 'Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
onChange({
|
|
91
|
+
...newModel
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
/*
|
|
96
|
+
* Method to generate random key
|
|
97
|
+
* */
|
|
98
|
+
(0, _defineProperty2.default)(this, "generateRandomKey", () => {
|
|
99
|
+
return Math.floor(Math.random() * 10000);
|
|
100
|
+
});
|
|
101
|
+
this.state = {
|
|
102
|
+
correctAnswerChangeDialog: {
|
|
103
|
+
open: false,
|
|
104
|
+
text: ''
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
render() {
|
|
109
|
+
const {
|
|
110
|
+
model,
|
|
111
|
+
onChange,
|
|
112
|
+
configuration,
|
|
113
|
+
imageSupport,
|
|
114
|
+
uploadSoundSupport
|
|
115
|
+
} = this.props;
|
|
116
|
+
const {
|
|
117
|
+
baseInputConfiguration = {},
|
|
118
|
+
contentDimensions = {},
|
|
119
|
+
title = {},
|
|
120
|
+
prompt = {},
|
|
121
|
+
modelOptions = {},
|
|
122
|
+
mathMlOptions = {}
|
|
123
|
+
} = configuration || {};
|
|
124
|
+
const {
|
|
125
|
+
errors = {},
|
|
126
|
+
extraCSSRules,
|
|
127
|
+
spellCheckEnabled,
|
|
128
|
+
toolbarEditorPosition
|
|
129
|
+
} = model || {};
|
|
130
|
+
const {
|
|
131
|
+
correctAnswerChangeDialog
|
|
132
|
+
} = this.state;
|
|
133
|
+
const toolbarOpts = {
|
|
134
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
135
|
+
};
|
|
136
|
+
const getPluginProps = (props = {}) => ({
|
|
137
|
+
...baseInputConfiguration,
|
|
138
|
+
...props
|
|
139
|
+
});
|
|
140
|
+
const fractionModelChartKey = this.generateRandomKey();
|
|
141
|
+
return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
|
|
142
|
+
extraCSSRules: extraCSSRules,
|
|
143
|
+
dimensions: contentDimensions,
|
|
144
|
+
hideSettings: true
|
|
145
|
+
}, /*#__PURE__*/_react.default.createElement(_cardBar.default, {
|
|
146
|
+
header: "Set Up"
|
|
147
|
+
}), /*#__PURE__*/_react.default.createElement(StyledFormSection, {
|
|
148
|
+
label: title?.label || 'Title'
|
|
149
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
150
|
+
markup: model.title || '',
|
|
151
|
+
onChange: title => onChange({
|
|
152
|
+
title
|
|
153
|
+
}),
|
|
154
|
+
toolbarOpts: toolbarOpts,
|
|
155
|
+
activePlugins: ['bold', 'html', 'italic', 'underline', 'strikethrough', 'image', 'math', 'languageCharacters', 'responseArea'],
|
|
156
|
+
pluginProps: getPluginProps(title?.inputConfiguration),
|
|
157
|
+
spellCheck: spellCheckEnabled,
|
|
158
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
159
|
+
languageCharactersProps: [{
|
|
160
|
+
language: 'spanish'
|
|
161
|
+
}, {
|
|
162
|
+
language: 'special'
|
|
163
|
+
}],
|
|
164
|
+
mathMlOptions: mathMlOptions
|
|
165
|
+
})), /*#__PURE__*/_react.default.createElement(StyledFormSection, {
|
|
166
|
+
label: prompt?.label || 'Question'
|
|
167
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
168
|
+
markup: model.prompt || '',
|
|
169
|
+
minHeight: 60,
|
|
170
|
+
onChange: prompt => onChange({
|
|
171
|
+
prompt
|
|
172
|
+
}),
|
|
173
|
+
toolbarOpts: toolbarOpts,
|
|
174
|
+
pluginProps: getPluginProps(prompt?.inputConfiguration),
|
|
175
|
+
spellCheck: spellCheckEnabled,
|
|
176
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
177
|
+
imageSupport: imageSupport,
|
|
178
|
+
languageCharactersProps: [{
|
|
179
|
+
language: 'spanish'
|
|
180
|
+
}, {
|
|
181
|
+
language: 'special'
|
|
182
|
+
}],
|
|
183
|
+
mathMlOptions: mathMlOptions
|
|
184
|
+
})), /*#__PURE__*/_react.default.createElement(_configUi.FormSection, null, /*#__PURE__*/_react.default.createElement(_modelOptions.default, {
|
|
185
|
+
model: model,
|
|
186
|
+
onChange: this.onModelOptionsChange,
|
|
187
|
+
modelOptions: modelOptions
|
|
188
|
+
})), /*#__PURE__*/_react.default.createElement(_configUi.FormSection, null, " ", /*#__PURE__*/_react.default.createElement(_cardBar.default, {
|
|
189
|
+
header: "Correct Answer",
|
|
190
|
+
info: /*#__PURE__*/_react.default.createElement(StyledTooltip, {
|
|
191
|
+
disableFocusListener: true,
|
|
192
|
+
disableTouchListener: true,
|
|
193
|
+
placement: 'right',
|
|
194
|
+
title: 'The correct answer should include no more than one partially-filled model'
|
|
195
|
+
}, /*#__PURE__*/_react.default.createElement(_Info.default, {
|
|
196
|
+
fontSize: 'small',
|
|
197
|
+
color: 'primary',
|
|
198
|
+
style: {
|
|
199
|
+
marginLeft: '8px'
|
|
200
|
+
}
|
|
201
|
+
}))
|
|
202
|
+
}), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(Label, null, "Click/touch the number of parts to represent the correct fraction model"), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(ModelErrorContainer, {
|
|
203
|
+
hasError: !!errors.correctResponse
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement(_fractionModel.FractionModelChart, {
|
|
205
|
+
key: fractionModelChartKey,
|
|
206
|
+
value: model.correctResponse,
|
|
207
|
+
modelType: model.modelTypeSelected,
|
|
208
|
+
noOfModels: model.maxModelSelected,
|
|
209
|
+
partsPerModel: model.partsPerModel,
|
|
210
|
+
showLabel: model.showGraphLabels,
|
|
211
|
+
onChange: this.onCorrectAnswerChange
|
|
212
|
+
})), errors.correctResponse && /*#__PURE__*/_react.default.createElement(ErrorMessage, null, errors.correctResponse)), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
|
|
213
|
+
open: correctAnswerChangeDialog.open,
|
|
214
|
+
title: "Warning",
|
|
215
|
+
text: correctAnswerChangeDialog.text,
|
|
216
|
+
onConfirm: () => {
|
|
217
|
+
let newModel = this.state.correctAnswerChangeDialog.newModel;
|
|
218
|
+
newModel.correctResponse = [];
|
|
219
|
+
onChange({
|
|
220
|
+
...newModel
|
|
221
|
+
});
|
|
222
|
+
this.setState({
|
|
223
|
+
correctAnswerChangeDialog: {
|
|
224
|
+
open: false
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
onClose: () => {
|
|
229
|
+
const oldModel = this.state.correctAnswerChangeDialog.oldModel;
|
|
230
|
+
onChange({
|
|
231
|
+
...oldModel
|
|
232
|
+
});
|
|
233
|
+
this.setState({
|
|
234
|
+
correctAnswerChangeDialog: {
|
|
235
|
+
open: false
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
onConfirmText: 'OK',
|
|
240
|
+
onCloseText: 'Cancel'
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.Main = Main;
|
|
245
|
+
(0, _defineProperty2.default)(Main, "propTypes", {
|
|
246
|
+
model: _propTypes.default.object.isRequired,
|
|
247
|
+
configuration: _propTypes.default.object.isRequired,
|
|
248
|
+
onConfigurationChanged: _propTypes.default.func.isRequired,
|
|
249
|
+
onChange: _propTypes.default.func.isRequired,
|
|
250
|
+
uploadSoundSupport: _propTypes.default.object.isRequired
|
|
251
|
+
});
|
|
252
|
+
var _default = exports.default = Main;
|
|
253
|
+
//# sourceMappingURL=main.js.map
|