@pie-element/fraction-model 0.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/dist/author/card-bar.d.ts +21 -0
- package/dist/author/card-bar.d.ts.map +1 -0
- package/dist/author/card-bar.js +40 -0
- package/dist/author/defaults.d.ts +114 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +84 -0
- package/dist/author/index.d.ts +45 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +88 -0
- package/dist/author/main.d.ts +26 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +156 -0
- package/dist/author/model-options.d.ts +33 -0
- package/dist/author/model-options.d.ts.map +1 -0
- package/dist/author/model-options.js +85 -0
- package/dist/author/number-text-field.d.ts +16 -0
- package/dist/author/number-text-field.d.ts.map +1 -0
- package/dist/author/number-text-field.js +20 -0
- package/dist/controller/defaults.d.ts +22 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +13 -0
- package/dist/controller/index.d.ts +24 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +68 -0
- package/dist/delivery/answer-fraction.d.ts +28 -0
- package/dist/delivery/answer-fraction.d.ts.map +1 -0
- package/dist/delivery/answer-fraction.js +69 -0
- package/dist/delivery/fraction-model-chart.d.ts +12 -0
- package/dist/delivery/fraction-model-chart.d.ts.map +1 -0
- package/dist/delivery/fraction-model-chart.js +154 -0
- package/dist/delivery/index.d.ts +23 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +54 -0
- package/dist/delivery/main.d.ts +39 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +136 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +179 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/package.json +70 -0
- package/src/author/card-bar.tsx +67 -0
- package/src/author/defaults.ts +88 -0
- package/src/author/index.ts +187 -0
- package/src/author/main.tsx +243 -0
- package/src/author/model-options.tsx +158 -0
- package/src/author/number-text-field.tsx +42 -0
- package/src/controller/defaults.ts +23 -0
- package/src/controller/index.ts +207 -0
- package/src/delivery/answer-fraction.tsx +113 -0
- package/src/delivery/fraction-model-chart.tsx +261 -0
- package/src/delivery/index.ts +96 -0
- package/src/delivery/main.tsx +256 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/fraction-model/configure/src/model-options.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { MiniField } from './number-text-field.js';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import Select from '@mui/material/Select';
|
|
16
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
17
|
+
import CardBar from './card-bar.js';
|
|
18
|
+
import { Checkbox } from '@pie-lib/config-ui';
|
|
19
|
+
import { cloneDeep } from 'lodash-es';
|
|
20
|
+
|
|
21
|
+
const GroupInline: any = styled('div')({
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
gap: '20px',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const Group: any = styled('div')({
|
|
28
|
+
margin: '12px 0',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const InputLabel: any = styled('label')({
|
|
32
|
+
display: 'block',
|
|
33
|
+
marginBottom: '4px',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const StyledSelect: any = styled(Select)({
|
|
37
|
+
width: '80px',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
height: '40px',
|
|
40
|
+
verticalAlign: 'top',
|
|
41
|
+
marginBottom: '8px',
|
|
42
|
+
'& .MuiSelect-select': {
|
|
43
|
+
paddingLeft: '10px',
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const CheckboxContainer: any = styled('div')({
|
|
48
|
+
marginLeft: '-15px',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const CheckboxLabel: any = styled('span')({
|
|
52
|
+
verticalAlign: 'middle',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export class ModelOptions extends React.Component {
|
|
56
|
+
static propTypes = {
|
|
57
|
+
model: PropTypes.object.isRequired,
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
modelOptions: PropTypes.object.isRequired,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
constructor(props) {
|
|
63
|
+
super(props);
|
|
64
|
+
this.changeMaxModel = this.change.bind(this, 'max');
|
|
65
|
+
this.changePartModel = this.change.bind(this, 'part');
|
|
66
|
+
this.studentConfig = this.change.bind(this, 'student-config');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Function to trigger when DOM elements value change for Number type
|
|
71
|
+
* @param {string} key contains key of element
|
|
72
|
+
* @param {object} event contains event object
|
|
73
|
+
* @param {string} value contains value of DOM element
|
|
74
|
+
*/
|
|
75
|
+
change(key, event, value) {
|
|
76
|
+
const { model, onChange } = this.props;
|
|
77
|
+
const oldModel = cloneDeep(model);
|
|
78
|
+
let newModel = cloneDeep(model);
|
|
79
|
+
let showDiag = false;
|
|
80
|
+
if (key === 'max') {
|
|
81
|
+
newModel.maxModelSelected = value;
|
|
82
|
+
showDiag = true;
|
|
83
|
+
} else if (key === 'part') {
|
|
84
|
+
newModel.partsPerModel = value;
|
|
85
|
+
showDiag = true;
|
|
86
|
+
} else if (key === 'student-config') {
|
|
87
|
+
newModel.allowedStudentConfig = value;
|
|
88
|
+
showDiag = false;
|
|
89
|
+
}
|
|
90
|
+
onChange(oldModel, newModel, showDiag);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Function to trigger on change of dropdown value model type
|
|
95
|
+
* @param {string} value contains selection value
|
|
96
|
+
*/
|
|
97
|
+
handleSelect: any = (value) => {
|
|
98
|
+
const { model, onChange } = this.props;
|
|
99
|
+
model.modelTypeSelected = value?.target.value;
|
|
100
|
+
onChange(model, { ...model }, false);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
render() {
|
|
104
|
+
const { model, modelOptions } = this.props;
|
|
105
|
+
const { maxOfModel, partsPerModel, modelTypeChoices } = modelOptions;
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div>
|
|
109
|
+
<CardBar header="Configure Fraction Model"></CardBar>
|
|
110
|
+
<br />
|
|
111
|
+
<GroupInline>
|
|
112
|
+
<Group>
|
|
113
|
+
<InputLabel>Model Type</InputLabel>
|
|
114
|
+
<StyledSelect
|
|
115
|
+
onChange={this.handleSelect}
|
|
116
|
+
value={model.modelTypeSelected}
|
|
117
|
+
MenuProps={{
|
|
118
|
+
transitionDuration: { enter: 225, exit: 195 }
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{modelTypeChoices.map((choice, index) => (
|
|
122
|
+
<MenuItem key={'item_' + index} value={choice.value}>
|
|
123
|
+
{choice.label}
|
|
124
|
+
</MenuItem>
|
|
125
|
+
))}
|
|
126
|
+
</StyledSelect>
|
|
127
|
+
</Group>
|
|
128
|
+
<Group>
|
|
129
|
+
<InputLabel>Max # of Models</InputLabel>
|
|
130
|
+
<MiniField
|
|
131
|
+
min={maxOfModel.min}
|
|
132
|
+
max={maxOfModel.max}
|
|
133
|
+
value={model.maxModelSelected}
|
|
134
|
+
name="max-model"
|
|
135
|
+
onChange={this.changeMaxModel}
|
|
136
|
+
/>
|
|
137
|
+
</Group>
|
|
138
|
+
<Group>
|
|
139
|
+
<InputLabel>Parts per Model</InputLabel>
|
|
140
|
+
<MiniField
|
|
141
|
+
min={partsPerModel.min}
|
|
142
|
+
max={partsPerModel.max}
|
|
143
|
+
value={model.partsPerModel}
|
|
144
|
+
name="model-parts"
|
|
145
|
+
onChange={this.changePartModel}
|
|
146
|
+
/>
|
|
147
|
+
</Group>
|
|
148
|
+
</GroupInline>
|
|
149
|
+
<CheckboxContainer>
|
|
150
|
+
<Checkbox onChange={this.studentConfig} checked={model.allowedStudentConfig} label={''} />
|
|
151
|
+
<CheckboxLabel>Allow student to configure number of models and parts per model</CheckboxLabel>
|
|
152
|
+
</CheckboxContainer>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default ModelOptions;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/fraction-model/configure/src/number-text-field.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { NumberTextField as NTF } from '@pie-lib/config-ui';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
|
|
15
|
+
const StyledNTF: any = styled(NTF)(({ theme }) => ({
|
|
16
|
+
marginLeft: theme.spacing(1),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const MiniStyledNTF: any = styled(NTF)({
|
|
20
|
+
maxWidth: '120px',
|
|
21
|
+
width: '120px',
|
|
22
|
+
marginTop: '0',
|
|
23
|
+
'& [class^="MuiInputBase-root"]': {
|
|
24
|
+
height: 40,
|
|
25
|
+
fontSize: '14px',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export class NumberTextField extends React.Component {
|
|
30
|
+
static propTypes = {};
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
const props = { ...this.props };
|
|
34
|
+
return <StyledNTF {...props} variant="outlined" />;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const MiniField = React.forwardRef((props, ref) => (
|
|
39
|
+
<MiniStyledNTF {...props} ref={ref} variant="outlined" />
|
|
40
|
+
));
|
|
41
|
+
|
|
42
|
+
export default NumberTextField;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/fraction-model/controller/src/defaults.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Should be exactly the same as configure/defaults.js
|
|
12
|
+
export default {
|
|
13
|
+
model: {
|
|
14
|
+
correctResponse: [],
|
|
15
|
+
title: '',
|
|
16
|
+
prompt: '',
|
|
17
|
+
modelTypeSelected: 'bar',
|
|
18
|
+
maxModelSelected: 1,
|
|
19
|
+
partsPerModel: 5,
|
|
20
|
+
allowedStudentConfig: false,
|
|
21
|
+
showGraphLabels: false,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/fraction-model/controller/src/index.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { isEmpty } from 'lodash-es';
|
|
12
|
+
import defaults from './defaults.js';
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Function to check the correctness of the response
|
|
16
|
+
* @param {model} model contains the model object
|
|
17
|
+
* @param {answers} answers contains the answers object
|
|
18
|
+
* @param {env} env contains the environment object
|
|
19
|
+
* @returns {string} returns the correctness of the response
|
|
20
|
+
* */
|
|
21
|
+
export const getResponseCorrectness = (model, answers, env = {}) => {
|
|
22
|
+
let correct;
|
|
23
|
+
if (model.allowedStudentConfig) {
|
|
24
|
+
correct = !!(
|
|
25
|
+
answers.partsPerModel === model.partsPerModel &&
|
|
26
|
+
partialFillCheck(answers.response, model.partsPerModel) &&
|
|
27
|
+
numeratorCheck(model.correctResponse, answers.response)
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
correct = !!(
|
|
31
|
+
partialFillCheck(answers.response, model.partsPerModel) && numeratorCheck(model.correctResponse, answers.response)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return correct ? 'correct' : 'incorrect';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Function to get the correctness of the response
|
|
39
|
+
* @param {question} question contains the question object
|
|
40
|
+
* @param {env} env contains the environment object
|
|
41
|
+
* @param {answers} answers contains the answers object
|
|
42
|
+
* @returns {string} returns the correctness
|
|
43
|
+
* */
|
|
44
|
+
const getCorrectness = (question, env, answers = {}) => {
|
|
45
|
+
if (env.mode === 'evaluate') {
|
|
46
|
+
return getResponseCorrectness(question, answers, env);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Function to get the outcome score
|
|
52
|
+
* @param {question} question contains the question object
|
|
53
|
+
* @param {env} env contains the environment object
|
|
54
|
+
* @param {answers} answers contains the answers object
|
|
55
|
+
* @returns {number} returns the score
|
|
56
|
+
* */
|
|
57
|
+
const getOutComeScore = (question, env, answers = {}) => {
|
|
58
|
+
const correctness = getCorrectness(question, env, answers);
|
|
59
|
+
return correctness === 'correct' ? 1 : 0;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* Function to check outcome of the session
|
|
64
|
+
* @param {model} model contains the model object
|
|
65
|
+
* @param {session} session contains the session object
|
|
66
|
+
* @param {env} env contains the environment object
|
|
67
|
+
* @returns {Promise} returns the score
|
|
68
|
+
*/
|
|
69
|
+
export const outcome = (model, session, env) =>
|
|
70
|
+
new Promise((resolve) => {
|
|
71
|
+
if (!session || isEmpty(session)) {
|
|
72
|
+
resolve({ score: 0, empty: true });
|
|
73
|
+
} else {
|
|
74
|
+
if (env.mode !== 'evaluate') {
|
|
75
|
+
resolve({ score: undefined, completed: undefined });
|
|
76
|
+
} else {
|
|
77
|
+
resolve({ score: getOutComeScore(model, env, session.answers) });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Function to check if the numerator of the response matches the numerator of the correct response
|
|
84
|
+
* @param {correctResponse} correctResponse contains the correct response object
|
|
85
|
+
* @param {response} response contains the response object
|
|
86
|
+
* @returns {boolean} returns true if the numerators match
|
|
87
|
+
* */
|
|
88
|
+
const numeratorCheck = (correctResponse, response) => {
|
|
89
|
+
let correctNumerator = 0;
|
|
90
|
+
let responseNumerator = 0;
|
|
91
|
+
for (let i = 0; i < correctResponse.length; i++) {
|
|
92
|
+
correctNumerator += correctResponse[i].value;
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < response.length; i++) {
|
|
95
|
+
responseNumerator += response[i].value;
|
|
96
|
+
}
|
|
97
|
+
return correctNumerator === responseNumerator;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* Function to check if the response contains more than one partially-filled model
|
|
102
|
+
* @param {response} response contains the response object
|
|
103
|
+
* @param {partsPerModel} partsPerModel contains the number of parts per model
|
|
104
|
+
* */
|
|
105
|
+
const partialFillCheck = (response, partsPerModel) => {
|
|
106
|
+
if (response.length > 0) {
|
|
107
|
+
let partialModelCount = 0;
|
|
108
|
+
response.forEach((selection) => {
|
|
109
|
+
if (selection.value !== partsPerModel) {
|
|
110
|
+
partialModelCount++;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return partialModelCount <= 1;
|
|
114
|
+
} else {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* Function to create a default model
|
|
121
|
+
* @param {model} model contains the model object
|
|
122
|
+
* */
|
|
123
|
+
export const createDefaultModel = (model = {}) => ({
|
|
124
|
+
...defaults.model,
|
|
125
|
+
...model,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Return the model object
|
|
130
|
+
* */
|
|
131
|
+
export 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 || 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
|
+
export const createCorrectResponseSession = (model, env) => {
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
170
|
+
const { correctResponse, maxModelSelected, partsPerModel } = model;
|
|
171
|
+
resolve({
|
|
172
|
+
answers: {
|
|
173
|
+
response: correctResponse,
|
|
174
|
+
noOfModel: maxModelSelected,
|
|
175
|
+
partsPerModel,
|
|
176
|
+
},
|
|
177
|
+
id: '1',
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
resolve(null);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/*
|
|
186
|
+
* Function to validate the model
|
|
187
|
+
* @param {model} model contains the model object
|
|
188
|
+
* @param {config} config contains the config object
|
|
189
|
+
* */
|
|
190
|
+
export const validate = (model = {}, config = {}) => {
|
|
191
|
+
const errors = {};
|
|
192
|
+
if (model.correctResponse.length === 0) {
|
|
193
|
+
errors.correctResponse = 'To save the item, at least one section must be marked as correct.';
|
|
194
|
+
}
|
|
195
|
+
if (model.correctResponse.length > 0) {
|
|
196
|
+
let partialModelCount = 0;
|
|
197
|
+
model.correctResponse.forEach((selection) => {
|
|
198
|
+
if (selection.value !== model.partsPerModel) {
|
|
199
|
+
partialModelCount++;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (partialModelCount > 1) {
|
|
203
|
+
errors.correctResponse = 'The correct answer should include no more than one partially-filled model';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return errors;
|
|
207
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/fraction-model/src/answer-fraction.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { TextField } from '@mui/material';
|
|
15
|
+
|
|
16
|
+
const GroupInline: any = styled('div')({
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
gap: '20px',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const Group: any = styled('div')({
|
|
23
|
+
margin: '12px 0',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const InputLabel: any = styled('label')({
|
|
27
|
+
display: 'block',
|
|
28
|
+
marginBottom: '4px',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const StyledTextField: any = styled(TextField)({
|
|
32
|
+
width: '120px',
|
|
33
|
+
maxHeight: '40px',
|
|
34
|
+
'& [class^="MuiInputBase-root"]': {
|
|
35
|
+
height: 40,
|
|
36
|
+
fontSize: '14px',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export class AnswerFraction extends React.Component {
|
|
41
|
+
static propTypes = {
|
|
42
|
+
model: PropTypes.object.isRequired,
|
|
43
|
+
disabled: PropTypes.bool.isRequired,
|
|
44
|
+
showCorrect: PropTypes.bool.isRequired,
|
|
45
|
+
onAnswerChange: PropTypes.func.isRequired,
|
|
46
|
+
answers: PropTypes.object.isRequired,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Function to trigger when value change from number selection
|
|
51
|
+
* @param {string} key contains event change object
|
|
52
|
+
* @returns updated answer change object
|
|
53
|
+
*/
|
|
54
|
+
onValueChange = (key) => (event) => {
|
|
55
|
+
let value = parseInt(event?.target?.value);
|
|
56
|
+
const { model, onAnswerChange, answers } = this.props;
|
|
57
|
+
const newAnswers = { ...answers };
|
|
58
|
+
const min = 1;
|
|
59
|
+
const max = (key === 'noOfModel') ? model.maxModelSelected : 9;
|
|
60
|
+
if(value > max) {
|
|
61
|
+
value = max;
|
|
62
|
+
} else if(value < min) {
|
|
63
|
+
value = min;
|
|
64
|
+
}
|
|
65
|
+
newAnswers[key] = value;
|
|
66
|
+
onAnswerChange(newAnswers);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
const { model, showCorrect, answers, disabled } = this.props;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div>
|
|
74
|
+
{model.allowedStudentConfig && (
|
|
75
|
+
<GroupInline>
|
|
76
|
+
<Group>
|
|
77
|
+
<InputLabel htmlFor={'preview_number-of-models'}>
|
|
78
|
+
Number of Models
|
|
79
|
+
</InputLabel>
|
|
80
|
+
<StyledTextField
|
|
81
|
+
id="preview_number-of-models"
|
|
82
|
+
inputProps={{ min: 1, max: model.maxModelSelected }}
|
|
83
|
+
name="preview_number-of-models"
|
|
84
|
+
onChange={this.onValueChange('noOfModel')}
|
|
85
|
+
type="number"
|
|
86
|
+
variant="outlined"
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
value={showCorrect ? model.maxModelSelected : answers.noOfModel}
|
|
89
|
+
/>
|
|
90
|
+
</Group>
|
|
91
|
+
<Group>
|
|
92
|
+
<InputLabel htmlFor={'preview_parts-per-model'}>
|
|
93
|
+
Parts per Model
|
|
94
|
+
</InputLabel>
|
|
95
|
+
<StyledTextField
|
|
96
|
+
id="preview_parts-per-model"
|
|
97
|
+
inputProps={{ min: 1, max: 9 }}
|
|
98
|
+
name="preview_parts-per-model"
|
|
99
|
+
onChange={this.onValueChange('partsPerModel')}
|
|
100
|
+
type="number"
|
|
101
|
+
variant="outlined"
|
|
102
|
+
disabled={disabled}
|
|
103
|
+
value={showCorrect ? model.partsPerModel : answers.partsPerModel}
|
|
104
|
+
/>
|
|
105
|
+
</Group>
|
|
106
|
+
</GroupInline>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default AnswerFraction;
|