@pie-element/fraction-model 6.2.2-beta.6 → 6.2.2-beta.7
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 +4 -0
- package/configure/CHANGELOG.md +4 -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 +4 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_editableHtmlTipTap","_fractionModel","_Tooltip","_Info","_styles","_cardBar","_modelOptions","StyledFormSection","styled","FormSection","theme","marginBottom","spacing","StyledTooltip","Tooltip","fontSize","typography","whiteSpace","maxWidth","ErrorMessage","color","palette","error","main","marginTop","ModelErrorContainer","hasError","border","Label","Main","React","Component","constructor","props","_defineProperty2","default","correctResponse","model","onChange","oldModel","newModel","showDiag","length","setState","correctAnswerChangeDialog","open","text","Math","floor","random","state","render","configuration","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","title","prompt","modelOptions","mathMlOptions","errors","extraCSSRules","spellCheckEnabled","toolbarEditorPosition","toolbarOpts","position","getPluginProps","fractionModelChartKey","generateRandomKey","createElement","layout","ConfigLayout","dimensions","hideSettings","header","label","markup","activePlugins","pluginProps","inputConfiguration","spellCheck","languageCharactersProps","language","minHeight","onModelOptionsChange","info","disableFocusListener","disableTouchListener","placement","style","marginLeft","FractionModelChart","key","value","modelType","modelTypeSelected","noOfModels","maxModelSelected","partsPerModel","showLabel","showGraphLabels","onCorrectAnswerChange","AlertDialog","onConfirm","onClose","onConfirmText","onCloseText","exports","PropTypes","object","isRequired","onConfigurationChanged","func","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { FormSection, layout, AlertDialog } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html-tip-tap';\nimport { FractionModelChart } from '@pie-element/fraction-model';\nimport Tooltip from '@mui/material/Tooltip';\nimport Info from '@mui/icons-material/Info';\nimport { styled } from '@mui/material/styles';\n\nimport CardBar from './card-bar';\nimport ModelOptions from './model-options';\n\nconst StyledFormSection = styled(FormSection)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorMessage = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n marginTop: theme.spacing(1),\n}));\n\nconst ModelErrorContainer = styled('div')(({ theme, hasError }) => ({\n ...(hasError && {\n border: `2px solid ${theme.palette.error.main}`,\n }),\n}));\n\nconst Label = styled('label')(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n uploadSoundSupport: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n correctAnswerChangeDialog: {\n open: false,\n text: '',\n },\n };\n }\n\n /*\n * Method to handle correct answer change\n * @param {array} correctResponse - correct response\n * */\n onCorrectAnswerChange = (correctResponse) => {\n const { model, onChange } = this.props;\n model.correctResponse = correctResponse;\n onChange({ ...model });\n };\n\n /*\n * Method to handle model options change\n * @param {object} oldModel - old model\n * @param {object} newModel - new model\n * @param {boolean} showDiag - show dialog or not\n * */\n onModelOptionsChange = (oldModel, newModel, showDiag) => {\n const { onChange } = this.props;\n if (showDiag && oldModel.correctResponse.length > 0) {\n this.setState({\n correctAnswerChangeDialog: {\n open: true,\n oldModel: oldModel,\n newModel: newModel,\n text: 'Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?',\n },\n });\n } else {\n onChange({ ...newModel });\n }\n };\n\n /*\n * Method to generate random key\n * */\n generateRandomKey = () => {\n return Math.floor(Math.random() * 10000);\n };\n\n render() {\n const { model, onChange, configuration, imageSupport, uploadSoundSupport } = this.props;\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n title = {},\n prompt = {},\n modelOptions = {},\n mathMlOptions = {},\n } = configuration || {};\n\n const { errors = {}, extraCSSRules, spellCheckEnabled, toolbarEditorPosition } = model || {};\n\n const { correctAnswerChangeDialog } = this.state;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n const fractionModelChartKey = this.generateRandomKey();\n\n return (\n <layout.ConfigLayout extraCSSRules={extraCSSRules} dimensions={contentDimensions} hideSettings={true}>\n <CardBar header=\"Set Up\"></CardBar>\n\n <StyledFormSection label={title?.label || 'Title'}>\n <EditableHtml\n markup={model.title || ''}\n onChange={(title) => onChange({ title })}\n toolbarOpts={toolbarOpts}\n activePlugins={[\n 'bold',\n 'html',\n 'italic',\n 'underline',\n 'strikethrough',\n 'image',\n 'math',\n 'languageCharacters',\n 'responseArea',\n ]}\n pluginProps={getPluginProps(title?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledFormSection>\n\n <StyledFormSection label={prompt?.label || 'Question'}>\n <EditableHtml\n markup={model.prompt || ''}\n minHeight={60}\n onChange={(prompt) => onChange({ prompt })}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledFormSection>\n\n <FormSection>\n <ModelOptions model={model} onChange={this.onModelOptionsChange} modelOptions={modelOptions} />\n </FormSection>\n\n <FormSection> <CardBar\n header=\"Correct Answer\"\n info={\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={'The correct answer should include no more than one partially-filled model'}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </StyledTooltip>\n }\n ></CardBar>\n\n <br />\n <Label>\n Click/touch the number of parts to represent the correct fraction model\n </Label>\n <br />\n\n <ModelErrorContainer hasError={!!errors.correctResponse}>\n <FractionModelChart\n key={fractionModelChartKey}\n value={model.correctResponse}\n modelType={model.modelTypeSelected}\n noOfModels={model.maxModelSelected}\n partsPerModel={model.partsPerModel}\n showLabel={model.showGraphLabels}\n onChange={this.onCorrectAnswerChange}\n ></FractionModelChart>\n </ModelErrorContainer>\n\n {errors.correctResponse && <ErrorMessage>{errors.correctResponse}</ErrorMessage>}\n </FormSection>\n\n <AlertDialog\n open={correctAnswerChangeDialog.open}\n title=\"Warning\"\n text={correctAnswerChangeDialog.text}\n onConfirm={() => {\n let newModel = this.state.correctAnswerChangeDialog.newModel;\n newModel.correctResponse = [];\n onChange({ ...newModel });\n this.setState({\n correctAnswerChangeDialog: { open: false },\n });\n }}\n onClose={() => {\n const oldModel = this.state.correctAnswerChangeDialog.oldModel;\n onChange({ ...oldModel });\n this.setState({ correctAnswerChangeDialog: { open: false } });\n }}\n onConfirmText={'OK'}\n onCloseText={'Cancel'}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,KAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,QAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,aAAA,GAAAV,sBAAA,CAAAC,OAAA;AAEA,MAAMU,iBAAiB,GAAG,IAAAC,cAAM,EAACC,qBAAW,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5DC,YAAY,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,MAAMC,aAAa,GAAG,IAAAL,cAAM,EAACM,gBAAO,CAAC,CAAC,CAAC;EAAEJ;AAAM,CAAC,MAAM;EACpD,uBAAuB,EAAE;IACvBK,QAAQ,EAAEL,KAAK,CAACM,UAAU,CAACD,QAAQ,GAAG,CAAC;IACvCE,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC,CAAC;AAEH,MAAMC,YAAY,GAAG,IAAAX,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEE;AAAM,CAA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G,IAAI,CAACU,KAAK,CAACN,yBAAyB,CAACJ,QAAQ;QAC5DA,QAAQ,CAACJ,eAAe,GAAG,EAAE;QAC7BE,QAAQ,CAAC;UAAE,GAAGE;QAAS,CAAC,CAAC;QACzB,IAAI,CAACG,QAAQ,CAAC;UACZC,yBAAyB,EAAE;YAAEC,IAAI,EAAE;UAAM;QAC3C,CAAC,CAAC;MACJ,CAAE;MACF4D,OAAO,EAAEA,CAAA,KAAM;QACb,MAAMlE,QAAQ,GAAG,IAAI,CAACW,KAAK,CAACN,yBAAyB,CAACL,QAAQ;QAC9DD,QAAQ,CAAC;UAAE,GAAGC;QAAS,CAAC,CAAC;QACzB,IAAI,CAACI,QAAQ,CAAC;UAAEC,yBAAyB,EAAE;YAAEC,IAAI,EAAE;UAAM;QAAE,CAAC,CAAC;MAC/D,CAAE;MACF6D,aAAa,EAAE,IAAK;MACpBC,WAAW,EAAE;IAAS,CACvB,CACkB,CAAC;EAE1B;AACF;AAACC,OAAA,CAAA/E,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EA9LYN,IAAI,eACI;EACjBQ,KAAK,EAAEwE,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClC3D,aAAa,EAAEyD,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1CC,sBAAsB,EAAEH,kBAAS,CAACI,IAAI,CAACF,UAAU;EACjDzE,QAAQ,EAAEuE,kBAAS,CAACI,IAAI,CAACF,UAAU;EACnCzD,kBAAkB,EAAEuD,kBAAS,CAACC,MAAM,CAACC;AACvC,CAAC;AAAA,IAAAG,QAAA,GAAAN,OAAA,CAAAzE,OAAA,GAyLYN,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,144 @@
|
|
|
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.ModelOptions = 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 _numberTextField = require("./number-text-field");
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
14
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
15
|
+
var _cardBar = _interopRequireDefault(require("./card-bar"));
|
|
16
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
17
|
+
var _lodashEs = require("lodash-es");
|
|
18
|
+
const GroupInline = (0, _styles.styled)('div')({
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
gap: '20px'
|
|
22
|
+
});
|
|
23
|
+
const Group = (0, _styles.styled)('div')({
|
|
24
|
+
margin: '12px 0'
|
|
25
|
+
});
|
|
26
|
+
const InputLabel = (0, _styles.styled)('label')({
|
|
27
|
+
display: 'block',
|
|
28
|
+
marginBottom: '4px'
|
|
29
|
+
});
|
|
30
|
+
const StyledSelect = (0, _styles.styled)(_Select.default)({
|
|
31
|
+
width: '80px',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
height: '40px',
|
|
34
|
+
verticalAlign: 'top',
|
|
35
|
+
marginBottom: '8px',
|
|
36
|
+
'& .MuiSelect-select': {
|
|
37
|
+
paddingLeft: '10px'
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const CheckboxContainer = (0, _styles.styled)('div')({
|
|
41
|
+
marginLeft: '-15px'
|
|
42
|
+
});
|
|
43
|
+
const CheckboxLabel = (0, _styles.styled)('span')({
|
|
44
|
+
verticalAlign: 'middle'
|
|
45
|
+
});
|
|
46
|
+
class ModelOptions extends _react.default.Component {
|
|
47
|
+
constructor(props) {
|
|
48
|
+
super(props);
|
|
49
|
+
/**
|
|
50
|
+
* Function to trigger on change of dropdown value model type
|
|
51
|
+
* @param {string} value contains selection value
|
|
52
|
+
*/
|
|
53
|
+
(0, _defineProperty2.default)(this, "handleSelect", value => {
|
|
54
|
+
const {
|
|
55
|
+
model,
|
|
56
|
+
onChange
|
|
57
|
+
} = this.props;
|
|
58
|
+
model.modelTypeSelected = value?.target.value;
|
|
59
|
+
onChange(model, {
|
|
60
|
+
...model
|
|
61
|
+
}, false);
|
|
62
|
+
});
|
|
63
|
+
this.changeMaxModel = this.change.bind(this, 'max');
|
|
64
|
+
this.changePartModel = this.change.bind(this, 'part');
|
|
65
|
+
this.studentConfig = this.change.bind(this, 'student-config');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Function to trigger when DOM elements value change for Number type
|
|
70
|
+
* @param {string} key contains key of element
|
|
71
|
+
* @param {object} event contains event object
|
|
72
|
+
* @param {string} value contains value of DOM element
|
|
73
|
+
*/
|
|
74
|
+
change(key, event, value) {
|
|
75
|
+
const {
|
|
76
|
+
model,
|
|
77
|
+
onChange
|
|
78
|
+
} = this.props;
|
|
79
|
+
const oldModel = (0, _lodashEs.cloneDeep)(model);
|
|
80
|
+
let newModel = (0, _lodashEs.cloneDeep)(model);
|
|
81
|
+
let showDiag = false;
|
|
82
|
+
if (key === 'max') {
|
|
83
|
+
newModel.maxModelSelected = value;
|
|
84
|
+
showDiag = true;
|
|
85
|
+
} else if (key === 'part') {
|
|
86
|
+
newModel.partsPerModel = value;
|
|
87
|
+
showDiag = true;
|
|
88
|
+
} else if (key === 'student-config') {
|
|
89
|
+
newModel.allowedStudentConfig = value;
|
|
90
|
+
showDiag = false;
|
|
91
|
+
}
|
|
92
|
+
onChange(oldModel, newModel, showDiag);
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
const {
|
|
96
|
+
model,
|
|
97
|
+
modelOptions
|
|
98
|
+
} = this.props;
|
|
99
|
+
const {
|
|
100
|
+
maxOfModel,
|
|
101
|
+
partsPerModel,
|
|
102
|
+
modelTypeChoices
|
|
103
|
+
} = modelOptions;
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_cardBar.default, {
|
|
105
|
+
header: "Configure Fraction Model"
|
|
106
|
+
}), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(GroupInline, null, /*#__PURE__*/_react.default.createElement(Group, null, /*#__PURE__*/_react.default.createElement(InputLabel, null, "Model Type"), /*#__PURE__*/_react.default.createElement(StyledSelect, {
|
|
107
|
+
onChange: this.handleSelect,
|
|
108
|
+
value: model.modelTypeSelected,
|
|
109
|
+
MenuProps: {
|
|
110
|
+
transitionDuration: {
|
|
111
|
+
enter: 225,
|
|
112
|
+
exit: 195
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, modelTypeChoices.map((choice, index) => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
|
|
116
|
+
key: 'item_' + index,
|
|
117
|
+
value: choice.value
|
|
118
|
+
}, choice.label)))), /*#__PURE__*/_react.default.createElement(Group, null, /*#__PURE__*/_react.default.createElement(InputLabel, null, "Max # of Models"), /*#__PURE__*/_react.default.createElement(_numberTextField.MiniField, {
|
|
119
|
+
min: maxOfModel.min,
|
|
120
|
+
max: maxOfModel.max,
|
|
121
|
+
value: model.maxModelSelected,
|
|
122
|
+
name: "max-model",
|
|
123
|
+
onChange: this.changeMaxModel
|
|
124
|
+
})), /*#__PURE__*/_react.default.createElement(Group, null, /*#__PURE__*/_react.default.createElement(InputLabel, null, "Parts per Model"), /*#__PURE__*/_react.default.createElement(_numberTextField.MiniField, {
|
|
125
|
+
min: partsPerModel.min,
|
|
126
|
+
max: partsPerModel.max,
|
|
127
|
+
value: model.partsPerModel,
|
|
128
|
+
name: "model-parts",
|
|
129
|
+
onChange: this.changePartModel
|
|
130
|
+
}))), /*#__PURE__*/_react.default.createElement(CheckboxContainer, null, /*#__PURE__*/_react.default.createElement(_configUi.Checkbox, {
|
|
131
|
+
onChange: this.studentConfig,
|
|
132
|
+
checked: model.allowedStudentConfig,
|
|
133
|
+
label: ''
|
|
134
|
+
}), /*#__PURE__*/_react.default.createElement(CheckboxLabel, null, "Allow student to configure number of models and parts per model")));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.ModelOptions = ModelOptions;
|
|
138
|
+
(0, _defineProperty2.default)(ModelOptions, "propTypes", {
|
|
139
|
+
model: _propTypes.default.object.isRequired,
|
|
140
|
+
onChange: _propTypes.default.func,
|
|
141
|
+
modelOptions: _propTypes.default.object.isRequired
|
|
142
|
+
});
|
|
143
|
+
var _default = exports.default = ModelOptions;
|
|
144
|
+
//# sourceMappingURL=model-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-options.js","names":["_react","_interopRequireDefault","require","_propTypes","_numberTextField","_styles","_Select","_MenuItem","_cardBar","_configUi","_lodashEs","GroupInline","styled","alignItems","display","gap","Group","margin","InputLabel","marginBottom","StyledSelect","Select","width","height","verticalAlign","paddingLeft","CheckboxContainer","marginLeft","CheckboxLabel","ModelOptions","React","Component","constructor","props","_defineProperty2","default","value","model","onChange","modelTypeSelected","target","changeMaxModel","change","bind","changePartModel","studentConfig","key","event","oldModel","cloneDeep","newModel","showDiag","maxModelSelected","partsPerModel","allowedStudentConfig","render","modelOptions","maxOfModel","modelTypeChoices","createElement","header","handleSelect","MenuProps","transitionDuration","enter","exit","map","choice","index","label","MiniField","min","max","name","Checkbox","checked","exports","PropTypes","object","isRequired","func","_default"],"sources":["../src/model-options.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { MiniField } from './number-text-field';\nimport { styled } from '@mui/material/styles';\nimport Select from '@mui/material/Select';\nimport MenuItem from '@mui/material/MenuItem';\nimport CardBar from './card-bar';\nimport { Checkbox } from '@pie-lib/config-ui';\nimport { cloneDeep } from 'lodash-es';\n\nconst GroupInline = styled('div')({\n alignItems: 'center',\n display: 'flex',\n gap: '20px',\n});\n\nconst Group = styled('div')({\n margin: '12px 0',\n});\n\nconst InputLabel = styled('label')({\n display: 'block',\n marginBottom: '4px',\n});\n\nconst StyledSelect = styled(Select)({\n width: '80px',\n alignItems: 'center',\n height: '40px',\n verticalAlign: 'top',\n marginBottom: '8px',\n '& .MuiSelect-select': {\n paddingLeft: '10px',\n },\n});\n\nconst CheckboxContainer = styled('div')({\n marginLeft: '-15px',\n});\n\nconst CheckboxLabel = styled('span')({\n verticalAlign: 'middle',\n});\n\nexport class ModelOptions extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func,\n modelOptions: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.changeMaxModel = this.change.bind(this, 'max');\n this.changePartModel = this.change.bind(this, 'part');\n this.studentConfig = this.change.bind(this, 'student-config');\n }\n\n /**\n * Function to trigger when DOM elements value change for Number type\n * @param {string} key contains key of element\n * @param {object} event contains event object\n * @param {string} value contains value of DOM element\n */\n change(key, event, value) {\n const { model, onChange } = this.props;\n const oldModel = cloneDeep(model);\n let newModel = cloneDeep(model);\n let showDiag = false;\n if (key === 'max') {\n newModel.maxModelSelected = value;\n showDiag = true;\n } else if (key === 'part') {\n newModel.partsPerModel = value;\n showDiag = true;\n } else if (key === 'student-config') {\n newModel.allowedStudentConfig = value;\n showDiag = false;\n }\n onChange(oldModel, newModel, showDiag);\n }\n\n /**\n * Function to trigger on change of dropdown value model type\n * @param {string} value contains selection value\n */\n handleSelect = (value) => {\n const { model, onChange } = this.props;\n model.modelTypeSelected = value?.target.value;\n onChange(model, { ...model }, false);\n };\n\n render() {\n const { model, modelOptions } = this.props;\n const { maxOfModel, partsPerModel, modelTypeChoices } = modelOptions;\n\n return (\n <div>\n <CardBar header=\"Configure Fraction Model\"></CardBar>\n <br />\n <GroupInline>\n <Group>\n <InputLabel>Model Type</InputLabel>\n <StyledSelect\n onChange={this.handleSelect}\n value={model.modelTypeSelected}\n MenuProps={{\n transitionDuration: { enter: 225, exit: 195 }\n }}\n >\n {modelTypeChoices.map((choice, index) => (\n <MenuItem key={'item_' + index} value={choice.value}>\n {choice.label}\n </MenuItem>\n ))}\n </StyledSelect>\n </Group>\n <Group>\n <InputLabel>Max # of Models</InputLabel>\n <MiniField\n min={maxOfModel.min}\n max={maxOfModel.max}\n value={model.maxModelSelected}\n name=\"max-model\"\n onChange={this.changeMaxModel}\n />\n </Group>\n <Group>\n <InputLabel>Parts per Model</InputLabel>\n <MiniField\n min={partsPerModel.min}\n max={partsPerModel.max}\n value={model.partsPerModel}\n name=\"model-parts\"\n onChange={this.changePartModel}\n />\n </Group>\n </GroupInline>\n <CheckboxContainer>\n <Checkbox onChange={this.studentConfig} checked={model.allowedStudentConfig} label={''} />\n <CheckboxLabel>Allow student to configure number of models and parts per model</CheckboxLabel>\n </CheckboxContainer>\n </div>\n );\n }\n}\n\nexport default ModelOptions;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,QAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAEA,MAAMS,WAAW,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC;EAChCC,UAAU,EAAE,QAAQ;EACpBC,OAAO,EAAE,MAAM;EACfC,GAAG,EAAE;AACP,CAAC,CAAC;AAEF,MAAMC,KAAK,GAAG,IAAAJ,cAAM,EAAC,KAAK,CAAC,CAAC;EAC1BK,MAAM,EAAE;AACV,CAAC,CAAC;AAEF,MAAMC,UAAU,GAAG,IAA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,GAAI;MACvBC,GAAG,EAAEnB,aAAa,CAACmB,GAAI;MACvBpC,KAAK,EAAEC,KAAK,CAACgB,aAAc;MAC3BoB,IAAI,EAAC,aAAa;MAClBnC,QAAQ,EAAE,IAAI,CAACM;IAAgB,CAChC,CACI,CACI,CAAC,eACd5C,MAAA,CAAAmC,OAAA,CAAAwB,aAAA,CAACjC,iBAAiB,qBAChB1B,MAAA,CAAAmC,OAAA,CAAAwB,aAAA,CAAClD,SAAA,CAAAiE,QAAQ;MAACpC,QAAQ,EAAE,IAAI,CAACO,aAAc;MAAC8B,OAAO,EAAEtC,KAAK,CAACiB,oBAAqB;MAACe,KAAK,EAAE;IAAG,CAAE,CAAC,eAC1FrE,MAAA,CAAAmC,OAAA,CAAAwB,aAAA,CAAC/B,aAAa,QAAC,iEAA8E,CAC5E,CAChB,CAAC;EAEV;AACF;AAACgD,OAAA,CAAA/C,YAAA,GAAAA,YAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EArGYN,YAAY,eACJ;EACjBQ,KAAK,EAAEwC,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCzC,QAAQ,EAAEuC,kBAAS,CAACG,IAAI;EACxBxB,YAAY,EAAEqB,kBAAS,CAACC,MAAM,CAACC;AACjC,CAAC;AAAA,IAAAE,QAAA,GAAAL,OAAA,CAAAzC,OAAA,GAkGYN,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.NumberTextField = exports.MiniField = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
|
+
const StyledNTF = (0, _styles.styled)(_configUi.NumberTextField)(({
|
|
14
|
+
theme
|
|
15
|
+
}) => ({
|
|
16
|
+
marginLeft: theme.spacing(1)
|
|
17
|
+
}));
|
|
18
|
+
const MiniStyledNTF = (0, _styles.styled)(_configUi.NumberTextField)({
|
|
19
|
+
maxWidth: '120px',
|
|
20
|
+
width: '120px',
|
|
21
|
+
marginTop: '0',
|
|
22
|
+
'& [class^="MuiInputBase-root"]': {
|
|
23
|
+
height: 40,
|
|
24
|
+
fontSize: '14px'
|
|
25
|
+
},
|
|
26
|
+
'& [class^="MuiInputBase-input"]': {
|
|
27
|
+
padding: '18.5px 14px'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
class NumberTextField extends _react.default.Component {
|
|
31
|
+
render() {
|
|
32
|
+
const props = {
|
|
33
|
+
...this.props
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(StyledNTF, (0, _extends2.default)({}, props, {
|
|
36
|
+
variant: "outlined"
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.NumberTextField = NumberTextField;
|
|
41
|
+
(0, _defineProperty2.default)(NumberTextField, "propTypes", {});
|
|
42
|
+
const MiniField = exports.MiniField = /*#__PURE__*/_react.default.forwardRef((props, ref) => /*#__PURE__*/_react.default.createElement(MiniStyledNTF, (0, _extends2.default)({}, props, {
|
|
43
|
+
ref: ref,
|
|
44
|
+
variant: "outlined"
|
|
45
|
+
})));
|
|
46
|
+
var _default = exports.default = NumberTextField;
|
|
47
|
+
//# sourceMappingURL=number-text-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-text-field.js","names":["_configUi","require","_react","_interopRequireDefault","_styles","StyledNTF","styled","NTF","theme","marginLeft","spacing","MiniStyledNTF","maxWidth","width","marginTop","height","fontSize","padding","NumberTextField","React","Component","render","props","default","createElement","_extends2","variant","exports","_defineProperty2","MiniField","forwardRef","ref","_default"],"sources":["../src/number-text-field.jsx"],"sourcesContent":["import { NumberTextField as NTF } from '@pie-lib/config-ui';\nimport React from 'react';\nimport { styled } from '@mui/material/styles';\n\nconst StyledNTF = styled(NTF)(({ theme }) => ({\n marginLeft: theme.spacing(1),\n}));\n\nconst MiniStyledNTF = styled(NTF)({\n maxWidth: '120px',\n width: '120px',\n marginTop: '0',\n '& [class^=\"MuiInputBase-root\"]': {\n height: 40,\n fontSize: '14px',\n },\n '& [class^=\"MuiInputBase-input\"]': {\n padding: '18.5px 14px'\n }\n});\n\nexport class NumberTextField extends React.Component {\n static propTypes = {};\n\n render() {\n const props = { ...this.props };\n return <StyledNTF {...props} variant=\"outlined\" />;\n }\n}\n\nexport const MiniField = React.forwardRef((props, ref) => (\n <MiniStyledNTF {...props} ref={ref} variant=\"outlined\" />\n));\n\nexport default NumberTextField;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAMI,SAAS,GAAG,IAAAC,cAAM,EAACC,yBAAG,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5CC,UAAU,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEH,MAAMC,aAAa,GAAG,IAAAL,cAAM,EAACC,yBAAG,CAAC,CAAC;EAChCK,QAAQ,EAAE,OAAO;EACjBC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAE,GAAG;EACd,gCAAgC,EAAE;IAChCC,MAAM,EAAE,EAAE;IACVC,QAAQ,EAAE;EACZ,CAAC;EACD,iCAAiC,EAAE;IACjCC,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAEK,MAAMC,eAAe,SAASC,cAAK,CAACC,SAAS,CAAC;EAGnDC,MAAMA,CAAA,EAAG;IACP,MAAMC,KAAK,GAAG;MAAE,GAAG,IAAI,CAACA;IAAM,CAAC;IAC/B,oBAAOpB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAACnB,SAAS,MAAAoB,SAAA,CAAAF,OAAA,MAAKD,KAAK;MAAEI,OAAO,EAAC;IAAU,EAAE,CAAC;EACpD;AACF;AAACC,OAAA,CAAAT,eAAA,GAAAA,eAAA;AAAA,IAAAU,gBAAA,CAAAL,OAAA,EAPYL,eAAe,eACP,CAAC,CAAC;AAQhB,MAAMW,SAAS,GAAAF,OAAA,CAAAE,SAAA,gBAAGV,cAAK,CAACW,UAAU,CAAC,CAACR,KAAK,EAAES,GAAG,kBACnD7B,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAACb,aAAa,MAAAc,SAAA,CAAAF,OAAA,MAAKD,KAAK;EAAES,GAAG,EAAEA,GAAI;EAACL,OAAO,EAAC;AAAU,EAAE,CACzD,CAAC;AAAC,IAAAM,QAAA,GAAAL,OAAA,CAAAJ,OAAA,GAEYL,eAAe","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/fraction-model-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "5.4.0-beta.
|
|
4
|
+
"version": "5.4.0-beta.13",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@mui/icons-material": "^7.3.4",
|
|
12
12
|
"@mui/material": "^7.3.4",
|
|
13
13
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
14
|
-
"@pie-lib/config-ui": "13.0.22-beta.
|
|
15
|
-
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.
|
|
14
|
+
"@pie-lib/config-ui": "13.0.22-beta.2",
|
|
15
|
+
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.2",
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
17
|
"lodash-es": "^4.17.23",
|
|
18
18
|
"prop-types": "^15.8.1",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model-controller@5.4.0-beta.12...@pie-element/fraction-model-controller@5.4.0-beta.13) (2026-09-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/fraction-model-controller
|
|
9
|
+
|
|
6
10
|
# [5.4.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/fraction-model-controller@5.4.0-beta.11...@pie-element/fraction-model-controller@5.4.0-beta.12) (2026-09-24)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @pie-element/fraction-model-controller
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// Should be exactly the same as configure/defaults.js
|
|
8
|
+
var _default = exports.default = {
|
|
9
|
+
model: {
|
|
10
|
+
correctResponse: [],
|
|
11
|
+
title: '',
|
|
12
|
+
prompt: '',
|
|
13
|
+
modelTypeSelected: 'bar',
|
|
14
|
+
maxModelSelected: 1,
|
|
15
|
+
partsPerModel: 5,
|
|
16
|
+
allowedStudentConfig: false,
|
|
17
|
+
showGraphLabels: false
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["_default","exports","default","model","correctResponse","title","prompt","modelTypeSelected","maxModelSelected","partsPerModel","allowedStudentConfig","showGraphLabels"],"sources":["../src/defaults.js"],"sourcesContent":["// Should be exactly the same as configure/defaults.js\nexport 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};\n"],"mappings":";;;;;;AAAA;AAAA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe;EACbC,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;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.validate = exports.outcome = exports.model = exports.getResponseCorrectness = exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
8
|
+
var _lodashEs = require("lodash-es");
|
|
9
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
10
|
+
/*
|
|
11
|
+
* Function to check the correctness of the response
|
|
12
|
+
* @param {model} model contains the model object
|
|
13
|
+
* @param {answers} answers contains the answers object
|
|
14
|
+
* @param {env} env contains the environment object
|
|
15
|
+
* @returns {string} returns the correctness of the response
|
|
16
|
+
* */
|
|
17
|
+
const getResponseCorrectness = (model, answers, env = {}) => {
|
|
18
|
+
let correct;
|
|
19
|
+
if (model.allowedStudentConfig) {
|
|
20
|
+
correct = !!(answers.partsPerModel === model.partsPerModel && partialFillCheck(answers.response, model.partsPerModel) && numeratorCheck(model.correctResponse, answers.response));
|
|
21
|
+
} else {
|
|
22
|
+
correct = !!(partialFillCheck(answers.response, model.partsPerModel) && numeratorCheck(model.correctResponse, answers.response));
|
|
23
|
+
}
|
|
24
|
+
return correct ? 'correct' : 'incorrect';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Function to get the correctness of the response
|
|
29
|
+
* @param {question} question contains the question object
|
|
30
|
+
* @param {env} env contains the environment object
|
|
31
|
+
* @param {answers} answers contains the answers object
|
|
32
|
+
* @returns {string} returns the correctness
|
|
33
|
+
* */
|
|
34
|
+
exports.getResponseCorrectness = getResponseCorrectness;
|
|
35
|
+
const getCorrectness = (question, env, answers = {}) => {
|
|
36
|
+
if (env.mode === 'evaluate') {
|
|
37
|
+
return getResponseCorrectness(question, answers, env);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Function to get the outcome score
|
|
43
|
+
* @param {question} question contains the question object
|
|
44
|
+
* @param {env} env contains the environment object
|
|
45
|
+
* @param {answers} answers contains the answers object
|
|
46
|
+
* @returns {number} returns the score
|
|
47
|
+
* */
|
|
48
|
+
const getOutComeScore = (question, env, answers = {}) => {
|
|
49
|
+
const correctness = getCorrectness(question, env, answers);
|
|
50
|
+
return correctness === 'correct' ? 1 : 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Function to check outcome of the session
|
|
55
|
+
* @param {model} model contains the model object
|
|
56
|
+
* @param {session} session contains the session object
|
|
57
|
+
* @param {env} env contains the environment object
|
|
58
|
+
* @returns {Promise} returns the score
|
|
59
|
+
*/
|
|
60
|
+
const outcome = (model, session, env) => new Promise(resolve => {
|
|
61
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
62
|
+
resolve({
|
|
63
|
+
score: 0,
|
|
64
|
+
empty: true
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
if (env.mode !== 'evaluate') {
|
|
68
|
+
resolve({
|
|
69
|
+
score: undefined,
|
|
70
|
+
completed: undefined
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
resolve({
|
|
74
|
+
score: getOutComeScore(model, env, session.answers)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Function to check if the numerator of the response matches the numerator of the correct response
|
|
82
|
+
* @param {correctResponse} correctResponse contains the correct response object
|
|
83
|
+
* @param {response} response contains the response object
|
|
84
|
+
* @returns {boolean} returns true if the numerators match
|
|
85
|
+
* */
|
|
86
|
+
exports.outcome = outcome;
|
|
87
|
+
const numeratorCheck = (correctResponse, response) => {
|
|
88
|
+
let correctNumerator = 0;
|
|
89
|
+
let responseNumerator = 0;
|
|
90
|
+
for (let i = 0; i < correctResponse.length; i++) {
|
|
91
|
+
correctNumerator += correctResponse[i].value;
|
|
92
|
+
}
|
|
93
|
+
for (let i = 0; i < response.length; i++) {
|
|
94
|
+
responseNumerator += response[i].value;
|
|
95
|
+
}
|
|
96
|
+
return correctNumerator === responseNumerator;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* Function to check if the response contains more than one partially-filled model
|
|
101
|
+
* @param {response} response contains the response object
|
|
102
|
+
* @param {partsPerModel} partsPerModel contains the number of parts per model
|
|
103
|
+
* */
|
|
104
|
+
const partialFillCheck = (response, partsPerModel) => {
|
|
105
|
+
if (response.length > 0) {
|
|
106
|
+
let partialModelCount = 0;
|
|
107
|
+
response.forEach(selection => {
|
|
108
|
+
if (selection.value !== partsPerModel) {
|
|
109
|
+
partialModelCount++;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return partialModelCount <= 1;
|
|
113
|
+
} else {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
* Function to create a default model
|
|
120
|
+
* @param {model} model contains the model object
|
|
121
|
+
* */
|
|
122
|
+
const createDefaultModel = (model = {}) => ({
|
|
123
|
+
..._defaults.default.model,
|
|
124
|
+
...model
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
* Return the model object
|
|
129
|
+
* */
|
|
130
|
+
exports.createDefaultModel = createDefaultModel;
|
|
131
|
+
const model = (question, session, env) => {
|
|
132
|
+
return new Promise(resolve => {
|
|
133
|
+
session = session || {};
|
|
134
|
+
const model = createDefaultModel(question);
|
|
135
|
+
let correctness, score;
|
|
136
|
+
if ((!session || (0, _lodashEs.isEmpty)(session)) && env.mode === 'evaluate') {
|
|
137
|
+
correctness = 'unanswered';
|
|
138
|
+
score = '0%';
|
|
139
|
+
} else {
|
|
140
|
+
correctness = getCorrectness(model, env, session && session.answers);
|
|
141
|
+
score = `${getOutComeScore(model, env, session && session.answers) * 100}%`;
|
|
142
|
+
}
|
|
143
|
+
const correctInfo = {
|
|
144
|
+
score,
|
|
145
|
+
correctness
|
|
146
|
+
};
|
|
147
|
+
const out = {
|
|
148
|
+
env,
|
|
149
|
+
...model,
|
|
150
|
+
view: env.mode === 'view' || env.mode === 'evaluate'
|
|
151
|
+
};
|
|
152
|
+
if (env.mode === 'evaluate') {
|
|
153
|
+
Object.assign(out, {
|
|
154
|
+
correctness: correctInfo
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
resolve(out);
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* Function to create a correct response session
|
|
163
|
+
* @param {model} model contains the model object
|
|
164
|
+
* @param {env} env contains the environment object
|
|
165
|
+
* @returns {Promise} returns the correct response session
|
|
166
|
+
* */
|
|
167
|
+
exports.model = model;
|
|
168
|
+
const createCorrectResponseSession = (model, env) => {
|
|
169
|
+
return new Promise(resolve => {
|
|
170
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
171
|
+
const {
|
|
172
|
+
correctResponse,
|
|
173
|
+
maxModelSelected,
|
|
174
|
+
partsPerModel
|
|
175
|
+
} = model;
|
|
176
|
+
resolve({
|
|
177
|
+
answers: {
|
|
178
|
+
response: correctResponse,
|
|
179
|
+
noOfModel: maxModelSelected,
|
|
180
|
+
partsPerModel
|
|
181
|
+
},
|
|
182
|
+
id: '1'
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
resolve(null);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
* Function to validate the model
|
|
192
|
+
* @param {model} model contains the model object
|
|
193
|
+
* @param {config} config contains the config object
|
|
194
|
+
* */
|
|
195
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
196
|
+
const validate = (model = {}, config = {}) => {
|
|
197
|
+
const errors = {};
|
|
198
|
+
if (model.correctResponse.length === 0) {
|
|
199
|
+
errors.correctResponse = 'To save the item, at least one section must be marked as correct.';
|
|
200
|
+
}
|
|
201
|
+
if (model.correctResponse.length > 0) {
|
|
202
|
+
let partialModelCount = 0;
|
|
203
|
+
model.correctResponse.forEach(selection => {
|
|
204
|
+
if (selection.value !== model.partsPerModel) {
|
|
205
|
+
partialModelCount++;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
if (partialModelCount > 1) {
|
|
209
|
+
errors.correctResponse = 'The correct answer should include no more than one partially-filled model';
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return errors;
|
|
213
|
+
};
|
|
214
|
+
exports.validate = validate;
|
|
215
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodashEs","require","_defaults","_interopRequireDefault","getResponseCorrectness","model","answers","env","correct","allowedStudentConfig","partsPerModel","partialFillCheck","response","numeratorCheck","correctResponse","exports","getCorrectness","question","mode","getOutComeScore","correctness","outcome","session","Promise","resolve","isEmpty","score","empty","undefined","completed","correctNumerator","responseNumerator","i","length","value","partialModelCount","forEach","selection","createDefaultModel","defaults","correctInfo","out","view","Object","assign","createCorrectResponseSession","role","maxModelSelected","noOfModel","id","validate","config","errors"],"sources":["../src/index.js"],"sourcesContent":["import { isEmpty } from 'lodash-es';\nimport defaults from './defaults';\n\n/*\n * Function to check the correctness of the response\n * @param {model} model contains the model object\n * @param {answers} answers contains the answers object\n * @param {env} env contains the environment object\n * @returns {string} returns the correctness of the response\n * */\nexport const getResponseCorrectness = (model, answers, env = {}) => {\n let correct;\n if (model.allowedStudentConfig) {\n correct = !!(\n answers.partsPerModel === model.partsPerModel &&\n partialFillCheck(answers.response, model.partsPerModel) &&\n numeratorCheck(model.correctResponse, answers.response)\n );\n } else {\n correct = !!(\n partialFillCheck(answers.response, model.partsPerModel) && numeratorCheck(model.correctResponse, answers.response)\n );\n }\n return correct ? 'correct' : 'incorrect';\n};\n\n/*\n * Function to get the correctness of the response\n * @param {question} question contains the question object\n * @param {env} env contains the environment object\n * @param {answers} answers contains the answers object\n * @returns {string} returns the correctness\n * */\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\n/*\n * Function to get the outcome score\n * @param {question} question contains the question object\n * @param {env} env contains the environment object\n * @param {answers} answers contains the answers object\n * @returns {number} returns the score\n * */\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n return correctness === 'correct' ? 1 : 0;\n};\n\n/*\n * Function to check outcome of the session\n * @param {model} model contains the model object\n * @param {session} session contains the session object\n * @param {env} env contains the environment object\n * @returns {Promise} returns the score\n */\nexport const outcome = (model, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n resolve({ score: getOutComeScore(model, env, session.answers) });\n }\n }\n });\n\n/*\n * Function to check if the numerator of the response matches the numerator of the correct response\n * @param {correctResponse} correctResponse contains the correct response object\n * @param {response} response contains the response object\n * @returns {boolean} returns true if the numerators match\n * */\nconst numeratorCheck = (correctResponse, response) => {\n let correctNumerator = 0;\n let responseNumerator = 0;\n for (let i = 0; i < correctResponse.length; i++) {\n correctNumerator += correctResponse[i].value;\n }\n for (let i = 0; i < response.length; i++) {\n responseNumerator += response[i].value;\n }\n return correctNumerator === responseNumerator;\n};\n\n/*\n * Function to check if the response contains more than one partially-filled model\n * @param {response} response contains the response object\n * @param {partsPerModel} partsPerModel contains the number of parts per model\n * */\nconst partialFillCheck = (response, partsPerModel) => {\n if (response.length > 0) {\n let partialModelCount = 0;\n response.forEach((selection) => {\n if (selection.value !== partsPerModel) {\n partialModelCount++;\n }\n });\n return partialModelCount <= 1;\n } else {\n return false;\n }\n};\n\n/*\n * Function to create a default model\n * @param {model} model contains the model object\n * */\nexport const createDefaultModel = (model = {}) => ({\n ...defaults.model,\n ...model,\n});\n\n/*\n * Return the model object\n * */\nexport const model = (question, session, env) => {\n return new Promise((resolve) => {\n session = session || {};\n const model = createDefaultModel(question);\n let correctness, score;\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(model, env, session && session.answers);\n score = `${getOutComeScore(model, env, session && session.answers) * 100}%`;\n }\n const correctInfo = {\n score,\n correctness,\n };\n const out = {\n env,\n ...model,\n view: env.mode === 'view' || env.mode === 'evaluate',\n };\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctness: correctInfo,\n });\n }\n resolve(out);\n });\n};\n\n/*\n * Function to create a correct response session\n * @param {model} model contains the model object\n * @param {env} env contains the environment object\n * @returns {Promise} returns the correct response session\n * */\nexport const createCorrectResponseSession = (model, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctResponse, maxModelSelected, partsPerModel } = model;\n resolve({\n answers: {\n response: correctResponse,\n noOfModel: maxModelSelected,\n partsPerModel,\n },\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n/*\n * Function to validate the model\n * @param {model} model contains the model object\n * @param {config} config contains the config object\n * */\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n if (model.correctResponse.length === 0) {\n errors.correctResponse = 'To save the item, at least one section must be marked as correct.';\n }\n if (model.correctResponse.length > 0) {\n let partialModelCount = 0;\n model.correctResponse.forEach((selection) => {\n if (selection.value !== model.partsPerModel) {\n partialModelCount++;\n }\n });\n if (partialModelCount > 1) {\n errors.correctResponse = 'The correct answer should include no more than one partially-filled model';\n }\n }\n return errors;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAGA,CAACC,KAAK,EAAEC,OAAO,EAAEC,GAAG,GAAG,CAAC,CAAC,KAAK;EAClE,IAAIC,OAAO;EACX,IAAIH,KAAK,CAACI,oBAAoB,EAAE;IAC9BD,OAAO,GAAG,CAAC,EACTF,OAAO,CAACI,aAAa,KAAKL,KAAK,CAACK,aAAa,IAC7CC,gBAAgB,CAACL,OAAO,CAACM,QAAQ,EAAEP,KAAK,CAACK,aAAa,CAAC,IACvDG,cAAc,CAACR,KAAK,CAACS,eAAe,EAAER,OAAO,CAACM,QAAQ,CAAC,CACxD;EACH,CAAC,MAAM;IACLJ,OAAO,GAAG,CAAC,EACTG,gBAAgB,CAACL,OAAO,CAACM,QAAQ,EAAEP,KAAK,CAACK,aAAa,CAAC,IAAIG,cAAc,CAACR,KAAK,CAACS,eAAe,EAAER,OAAO,CAACM,QAAQ,CAAC,CACnH;EACH;EACA,OAAOJ,OAAO,GAAG,SAAS,GAAG,WAAW;AAC1C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAO,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAOA,MAAMY,cAAc,GAAGA,CAACC,QAAQ,EAAEV,GAAG,EAAED,OAAO,GAAG,CAAC,CA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