@pie-element/rubric 1.6.3-next.1217 → 1.6.3-next.1219
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/package.json +2 -2
- package/configure/node_modules/@pie-lib/rubric/CHANGELOG.json +0 -407
- package/configure/node_modules/@pie-lib/rubric/CHANGELOG.md +0 -924
- package/configure/node_modules/@pie-lib/rubric/LICENSE.md +0 -5
- package/configure/node_modules/@pie-lib/rubric/lib/authoring.js +0 -460
- package/configure/node_modules/@pie-lib/rubric/lib/authoring.js.map +0 -1
- package/configure/node_modules/@pie-lib/rubric/lib/index.js +0 -23
- package/configure/node_modules/@pie-lib/rubric/lib/index.js.map +0 -1
- package/configure/node_modules/@pie-lib/rubric/lib/point-menu.js +0 -172
- package/configure/node_modules/@pie-lib/rubric/lib/point-menu.js.map +0 -1
- package/configure/node_modules/@pie-lib/rubric/package.json +0 -22
- package/configure/node_modules/@pie-lib/rubric/src/authoring.jsx +0 -361
- package/configure/node_modules/@pie-lib/rubric/src/index.js +0 -8
- package/configure/node_modules/@pie-lib/rubric/src/point-menu.jsx +0 -94
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.IconMenu = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
|
|
25
|
-
|
|
26
|
-
var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
|
|
27
|
-
|
|
28
|
-
var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
|
|
29
|
-
|
|
30
|
-
var _MoreHoriz = _interopRequireDefault(require("@material-ui/icons/MoreHoriz"));
|
|
31
|
-
|
|
32
|
-
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
33
|
-
|
|
34
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
|
-
|
|
36
|
-
var _react = _interopRequireDefault(require("react"));
|
|
37
|
-
|
|
38
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
|
-
var IconMenu = /*#__PURE__*/function (_React$Component) {
|
|
43
|
-
(0, _inherits2["default"])(IconMenu, _React$Component);
|
|
44
|
-
|
|
45
|
-
var _super = _createSuper(IconMenu);
|
|
46
|
-
|
|
47
|
-
function IconMenu(props) {
|
|
48
|
-
var _this;
|
|
49
|
-
|
|
50
|
-
(0, _classCallCheck2["default"])(this, IconMenu);
|
|
51
|
-
_this = _super.call(this, props);
|
|
52
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (event) {
|
|
53
|
-
return _this.setState({
|
|
54
|
-
open: true,
|
|
55
|
-
anchorEl: event.currentTarget
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleRequestClose", function () {
|
|
59
|
-
return _this.setState({
|
|
60
|
-
open: false
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
_this.state = {
|
|
64
|
-
anchorEl: undefined,
|
|
65
|
-
open: false
|
|
66
|
-
};
|
|
67
|
-
return _this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
(0, _createClass2["default"])(IconMenu, [{
|
|
71
|
-
key: "render",
|
|
72
|
-
value: function render() {
|
|
73
|
-
var _this2 = this;
|
|
74
|
-
|
|
75
|
-
var _this$props = this.props,
|
|
76
|
-
opts = _this$props.opts,
|
|
77
|
-
onClick = _this$props.onClick,
|
|
78
|
-
classes = _this$props.classes;
|
|
79
|
-
var _this$state = this.state,
|
|
80
|
-
open = _this$state.open,
|
|
81
|
-
anchorEl = _this$state.anchorEl;
|
|
82
|
-
var keys = Object.keys(opts) || [];
|
|
83
|
-
|
|
84
|
-
var handleMenuClick = function handleMenuClick(key) {
|
|
85
|
-
return function () {
|
|
86
|
-
onClick(key);
|
|
87
|
-
|
|
88
|
-
_this2.handleRequestClose();
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
var iconColor = open ? 'inherit' : 'disabled';
|
|
93
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
94
|
-
onClick: this.handleClick
|
|
95
|
-
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
96
|
-
className: classes.icon
|
|
97
|
-
}, open ? /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
|
|
98
|
-
color: iconColor
|
|
99
|
-
}) : /*#__PURE__*/_react["default"].createElement(_MoreHoriz["default"], {
|
|
100
|
-
color: iconColor
|
|
101
|
-
}))), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
|
|
102
|
-
id: "point-menu",
|
|
103
|
-
anchorEl: anchorEl,
|
|
104
|
-
open: open,
|
|
105
|
-
onClose: this.handleRequestClose,
|
|
106
|
-
style: {
|
|
107
|
-
transform: 'translate(-15px, -15px)'
|
|
108
|
-
},
|
|
109
|
-
transformOrigin: {
|
|
110
|
-
vertical: 'center',
|
|
111
|
-
horizontal: 'right'
|
|
112
|
-
}
|
|
113
|
-
}, keys.map(function (k, index) {
|
|
114
|
-
return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
115
|
-
key: index,
|
|
116
|
-
onClick: handleMenuClick(k)
|
|
117
|
-
}, opts[k]);
|
|
118
|
-
})));
|
|
119
|
-
}
|
|
120
|
-
}]);
|
|
121
|
-
return IconMenu;
|
|
122
|
-
}(_react["default"].Component);
|
|
123
|
-
|
|
124
|
-
exports.IconMenu = IconMenu;
|
|
125
|
-
(0, _defineProperty2["default"])(IconMenu, "propTypes", {
|
|
126
|
-
opts: _propTypes["default"].object,
|
|
127
|
-
onClick: _propTypes["default"].func.isRequired,
|
|
128
|
-
classes: _propTypes["default"].object.isRequired
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
var PointMenu = /*#__PURE__*/function (_React$Component2) {
|
|
132
|
-
(0, _inherits2["default"])(PointMenu, _React$Component2);
|
|
133
|
-
|
|
134
|
-
var _super2 = _createSuper(PointMenu);
|
|
135
|
-
|
|
136
|
-
function PointMenu() {
|
|
137
|
-
(0, _classCallCheck2["default"])(this, PointMenu);
|
|
138
|
-
return _super2.apply(this, arguments);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
(0, _createClass2["default"])(PointMenu, [{
|
|
142
|
-
key: "render",
|
|
143
|
-
value: function render() {
|
|
144
|
-
var _this$props2 = this.props,
|
|
145
|
-
onChange = _this$props2.onChange,
|
|
146
|
-
classes = _this$props2.classes,
|
|
147
|
-
showSampleAnswer = _this$props2.showSampleAnswer;
|
|
148
|
-
var sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';
|
|
149
|
-
return /*#__PURE__*/_react["default"].createElement(IconMenu, {
|
|
150
|
-
onClick: function onClick(key) {
|
|
151
|
-
return onChange(key);
|
|
152
|
-
},
|
|
153
|
-
opts: {
|
|
154
|
-
sample: sampleText
|
|
155
|
-
},
|
|
156
|
-
classes: classes
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}]);
|
|
160
|
-
return PointMenu;
|
|
161
|
-
}(_react["default"].Component);
|
|
162
|
-
|
|
163
|
-
exports["default"] = PointMenu;
|
|
164
|
-
(0, _defineProperty2["default"])(PointMenu, "propTypes", {
|
|
165
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
166
|
-
classes: _propTypes["default"].object.isRequired,
|
|
167
|
-
showSampleAnswer: _propTypes["default"].bool.isRequired
|
|
168
|
-
});
|
|
169
|
-
(0, _defineProperty2["default"])(PointMenu, "defaultProps", {
|
|
170
|
-
classes: {}
|
|
171
|
-
});
|
|
172
|
-
//# sourceMappingURL=point-menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/point-menu.jsx"],"names":["IconMenu","props","event","setState","open","anchorEl","currentTarget","state","undefined","opts","onClick","classes","keys","Object","handleMenuClick","key","handleRequestClose","iconColor","handleClick","icon","transform","vertical","horizontal","map","k","index","React","Component","PropTypes","object","func","isRequired","PointMenu","onChange","showSampleAnswer","sampleText","sample","bool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA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E,QAAA,OAAO,EAAExB;AALX,QADF;AASD;;;EAxBoCe,kBAAMC,S;;;iCAAxBK,S,eACA;AACjBC,EAAAA,QAAQ,EAAEL,sBAAUE,IAAV,CAAeC,UADR;AAEjBpB,EAAAA,OAAO,EAAEiB,sBAAUC,MAAV,CAAiBE,UAFT;AAGjBG,EAAAA,gBAAgB,EAAEN,sBAAUS,IAAV,CAAeN;AAHhB,C;iCADAC,S,kBAOG;AACpBrB,EAAAA,OAAO,EAAE;AADW,C","sourcesContent":["import Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport MoreVertIcon from '@material-ui/icons/MoreVert';\nimport MoreHorizIcon from '@material-ui/icons/MoreHoriz';\nimport IconButton from '@material-ui/core/IconButton';\nimport PropTypes from 'prop-types';\nimport React from 'react';\n\nexport class IconMenu extends React.Component {\n static propTypes = {\n opts: PropTypes.object,\n onClick: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired\n };\n\n constructor(props) {\n super(props);\n this.state = {\n anchorEl: undefined,\n open: false\n };\n }\n\n handleClick = event => this.setState({ open: true, anchorEl: event.currentTarget });\n\n handleRequestClose = () => this.setState({ open: false });\n\n render() {\n const { opts, onClick, classes } = this.props;\n const { open, anchorEl } = this.state;\n const keys = Object.keys(opts) || [];\n\n const handleMenuClick = key => () => {\n onClick(key);\n this.handleRequestClose();\n };\n\n const iconColor = open ? 'inherit' : 'disabled';\n\n return (\n <div>\n <div onClick={this.handleClick}>\n <IconButton className={classes.icon}>\n {open ? <MoreVertIcon color={iconColor} /> : <MoreHorizIcon color={iconColor} />}\n </IconButton>\n </div>\n <Menu\n id=\"point-menu\"\n anchorEl={anchorEl}\n open={open}\n onClose={this.handleRequestClose}\n style={{ transform: 'translate(-15px, -15px)' }}\n transformOrigin={{\n vertical: 'center',\n horizontal: 'right'\n }}\n >\n {keys.map((k, index) => (\n <MenuItem key={index} onClick={handleMenuClick(k)}>\n {opts[k]}\n </MenuItem>\n ))}\n </Menu>\n </div>\n );\n }\n}\n\nexport default class PointMenu extends React.Component {\n static propTypes = {\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n showSampleAnswer: PropTypes.bool.isRequired\n };\n\n static defaultProps = {\n classes: {}\n };\n\n render() {\n const { onChange, classes, showSampleAnswer } = this.props;\n const sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';\n\n return (\n <IconMenu\n onClick={key => onChange(key)}\n opts={{\n sample: sampleText\n }}\n classes={classes}\n />\n );\n }\n}\n"],"file":"point-menu.js"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pie-lib/rubric",
|
|
3
|
-
"version": "0.5.1",
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
7
|
-
"main": "lib/index.js",
|
|
8
|
-
"module": "src/index.js",
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@material-ui/core": "^3.9.3",
|
|
11
|
-
"@material-ui/icons": "^3.0.2",
|
|
12
|
-
"@pie-lib/editable-html": "^9.1.6",
|
|
13
|
-
"debug": "^4.1.1",
|
|
14
|
-
"editable-html": "npm:@pie-lib/editable-html@^7.21.0",
|
|
15
|
-
"lodash": "^4.17.11",
|
|
16
|
-
"prop-types": "^15.7.2",
|
|
17
|
-
"react": "^16.8.1",
|
|
18
|
-
"react-beautiful-dnd": "^11.0.2",
|
|
19
|
-
"react-dom": "^16.9.0"
|
|
20
|
-
},
|
|
21
|
-
"gitHead": "945cf008fd2a4a0d136813a9034274288ae95510"
|
|
22
|
-
}
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import OutlinedInput from '@material-ui/core/OutlinedInput';
|
|
6
|
-
import InputLabel from '@material-ui/core/InputLabel';
|
|
7
|
-
import Select from '@material-ui/core/Select';
|
|
8
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
9
|
-
import MenuItem from '@material-ui/core/MenuItem';
|
|
10
|
-
import times from 'lodash/times';
|
|
11
|
-
import Checkbox from '@material-ui/core/Checkbox';
|
|
12
|
-
import FormGroup from '@material-ui/core/FormGroup';
|
|
13
|
-
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
14
|
-
import grey from '@material-ui/core/colors/grey';
|
|
15
|
-
import Typography from '@material-ui/core/Typography';
|
|
16
|
-
import DragIndicator from '@material-ui/icons/DragIndicator';
|
|
17
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
18
|
-
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
19
|
-
import debug from 'debug';
|
|
20
|
-
import takeRight from 'lodash/takeRight';
|
|
21
|
-
import PointMenu from './point-menu';
|
|
22
|
-
|
|
23
|
-
import range from 'lodash/range';
|
|
24
|
-
const log = debug('pie-lib:rubric:authoring');
|
|
25
|
-
|
|
26
|
-
const reorder = (list, startIndex, endIndex) => {
|
|
27
|
-
const result = Array.from(list);
|
|
28
|
-
const [removed] = result.splice(startIndex, 1);
|
|
29
|
-
|
|
30
|
-
result.splice(endIndex, 0, removed);
|
|
31
|
-
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const RubricType = PropTypes.shape({
|
|
36
|
-
excludeZero: PropTypes.bool,
|
|
37
|
-
points: PropTypes.arrayOf(PropTypes.string),
|
|
38
|
-
sampleAnswers: PropTypes.arrayOf(PropTypes.string)
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const MaxPoints = withStyles(theme => ({
|
|
42
|
-
formControl: {
|
|
43
|
-
minWidth: '120px',
|
|
44
|
-
margin: theme.spacing.unit
|
|
45
|
-
}
|
|
46
|
-
}))(props => {
|
|
47
|
-
const { value, onChange, max, classes } = props;
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<FormControl className={classes.formControl} variant="outlined">
|
|
51
|
-
<InputLabel width={100} htmlFor="...">
|
|
52
|
-
Max Points
|
|
53
|
-
</InputLabel>
|
|
54
|
-
<Select
|
|
55
|
-
value={value}
|
|
56
|
-
onChange={e => onChange(e.target.value)}
|
|
57
|
-
input={<OutlinedInput labelWidth={80} />}
|
|
58
|
-
>
|
|
59
|
-
{range(1, max).map(v => (
|
|
60
|
-
<MenuItem key={`${v}`} value={v}>
|
|
61
|
-
{v}
|
|
62
|
-
</MenuItem>
|
|
63
|
-
))}
|
|
64
|
-
</Select>
|
|
65
|
-
</FormControl>
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// if the value is null or 'null', the Sample Answer input field for that point will not be dispalyed
|
|
70
|
-
// if the value is '', the Sample Answer input field will be empty
|
|
71
|
-
const checkSampleAnswer = sampleAnswer => sampleAnswer === null || sampleAnswer === 'null';
|
|
72
|
-
|
|
73
|
-
export const PointConfig = withStyles(theme => ({
|
|
74
|
-
pointConfig: {},
|
|
75
|
-
row: {
|
|
76
|
-
display: 'flex',
|
|
77
|
-
width: '100%',
|
|
78
|
-
position: 'relative'
|
|
79
|
-
},
|
|
80
|
-
editor: {
|
|
81
|
-
width: '100%',
|
|
82
|
-
backgroundColor: 'white !important'
|
|
83
|
-
},
|
|
84
|
-
dragIndicator: {
|
|
85
|
-
paddingTop: theme.spacing.unit,
|
|
86
|
-
color: grey[500]
|
|
87
|
-
},
|
|
88
|
-
pointsLabel: {
|
|
89
|
-
color: grey[500],
|
|
90
|
-
paddingBottom: theme.spacing.unit,
|
|
91
|
-
textTransform: 'uppercase'
|
|
92
|
-
},
|
|
93
|
-
sampleAnswersEditor: {
|
|
94
|
-
paddingLeft: theme.spacing.unit * 3
|
|
95
|
-
},
|
|
96
|
-
pointMenu: {
|
|
97
|
-
position: 'absolute',
|
|
98
|
-
right: 0
|
|
99
|
-
}
|
|
100
|
-
}))(props => {
|
|
101
|
-
const { points, content, classes, sampleAnswer } = props;
|
|
102
|
-
const pointsLabel = `${points} ${points <= 1 ? 'pt' : 'pts'}`;
|
|
103
|
-
const showSampleAnswer = checkSampleAnswer(sampleAnswer);
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<div className={classes.pointConfig}>
|
|
107
|
-
<Typography variant="overline" className={classes.pointsLabel}>
|
|
108
|
-
{pointsLabel}
|
|
109
|
-
</Typography>
|
|
110
|
-
<div className={classes.row}>
|
|
111
|
-
<DragIndicator className={classes.dragIndicator} />
|
|
112
|
-
<EditableHtml className={classes.editor} markup={content} onChange={props.onChange} />
|
|
113
|
-
<PointMenu
|
|
114
|
-
classes={{
|
|
115
|
-
icon: classes.pointMenu
|
|
116
|
-
}}
|
|
117
|
-
showSampleAnswer={showSampleAnswer}
|
|
118
|
-
onChange={props.onMenuChange}
|
|
119
|
-
/>
|
|
120
|
-
</div>
|
|
121
|
-
{!showSampleAnswer && (
|
|
122
|
-
<div className={classes.sampleAnswersEditor}>
|
|
123
|
-
<Typography variant="overline" className={classes.dragIndicator}>
|
|
124
|
-
Sample Response
|
|
125
|
-
</Typography>
|
|
126
|
-
<EditableHtml
|
|
127
|
-
className={classes.editor}
|
|
128
|
-
markup={sampleAnswer}
|
|
129
|
-
onChange={props.onSampleChange}
|
|
130
|
-
/>
|
|
131
|
-
</div>
|
|
132
|
-
)}
|
|
133
|
-
</div>
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
export class RawAuthoring extends React.Component {
|
|
138
|
-
static propTypes = {
|
|
139
|
-
classes: PropTypes.object.isRequired,
|
|
140
|
-
className: PropTypes.string,
|
|
141
|
-
value: RubricType,
|
|
142
|
-
onChange: PropTypes.func
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
static defaultProps = {};
|
|
146
|
-
|
|
147
|
-
dragEnd = result => {
|
|
148
|
-
if (!result.destination) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const { value, onChange } = this.props;
|
|
153
|
-
|
|
154
|
-
const points = reorder(value.points, result.source.index, result.destination.index);
|
|
155
|
-
const sampleAnswers = reorder(
|
|
156
|
-
value.sampleAnswers,
|
|
157
|
-
result.source.index,
|
|
158
|
-
result.destination.index
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
onChange({ ...value, points, sampleAnswers });
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
changeMaxPoints = maxPoints => {
|
|
165
|
-
const { value, onChange } = this.props;
|
|
166
|
-
const currentMax = value.points.length - 1;
|
|
167
|
-
|
|
168
|
-
log('current', currentMax, 'new: ', maxPoints);
|
|
169
|
-
|
|
170
|
-
let points, sampleAnswers;
|
|
171
|
-
if (maxPoints > currentMax) {
|
|
172
|
-
points = times(maxPoints - currentMax)
|
|
173
|
-
.map(() => '')
|
|
174
|
-
.concat(value.points);
|
|
175
|
-
sampleAnswers = times(maxPoints - currentMax)
|
|
176
|
-
.map(() => null)
|
|
177
|
-
.concat(value.sampleAnswers);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (maxPoints < currentMax) {
|
|
181
|
-
log('less than');
|
|
182
|
-
points = takeRight(value.points, maxPoints + 1);
|
|
183
|
-
sampleAnswers = takeRight(value.sampleAnswers, maxPoints + 1);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (points) {
|
|
187
|
-
onChange({ ...value, points, sampleAnswers });
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
changeContent = (index, content, type) => {
|
|
192
|
-
// type could be 'points' or 'sampleAnswers'
|
|
193
|
-
log(`changeModel[${type}]:`, index, content);
|
|
194
|
-
|
|
195
|
-
if (type !== 'points' && type !== 'sampleAnswers') {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const { value, onChange } = this.props;
|
|
200
|
-
const items = value[type] && Array.from(value[type]);
|
|
201
|
-
|
|
202
|
-
items.splice(index, 1, content);
|
|
203
|
-
log(`changeModel[${type}]:`, items);
|
|
204
|
-
|
|
205
|
-
onChange({ ...value, [type]: items });
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
excludeZeros = () => {
|
|
209
|
-
const { value, onChange } = this.props;
|
|
210
|
-
|
|
211
|
-
onChange({ ...value, excludeZero: !value.excludeZero });
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
shouldRenderPoint = (index, value) => {
|
|
215
|
-
if (!value.excludeZero) {
|
|
216
|
-
return true;
|
|
217
|
-
} else {
|
|
218
|
-
if (index < value.points.length - 1) {
|
|
219
|
-
return true;
|
|
220
|
-
} else if (index === value.points.length - 1) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
onPointMenuChange = (index, clickedItem) => {
|
|
229
|
-
if (clickedItem === 'sample') {
|
|
230
|
-
const { value } = this.props;
|
|
231
|
-
const sampleAnswers = Array.from(value.sampleAnswers || []);
|
|
232
|
-
|
|
233
|
-
if (checkSampleAnswer(sampleAnswers[index])) {
|
|
234
|
-
// an empty string will display an empty Sample Answer input field
|
|
235
|
-
this.changeContent(index, '', 'sampleAnswers');
|
|
236
|
-
} else {
|
|
237
|
-
// when the content is null or 'null', the Sample Answer input field will not be displayed
|
|
238
|
-
this.changeContent(index, null, 'sampleAnswers');
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
render() {
|
|
244
|
-
const { classes, className, value } = this.props;
|
|
245
|
-
|
|
246
|
-
if (value && Number.isFinite(value.maxPoints)) {
|
|
247
|
-
// eslint-disable-next-line no-console
|
|
248
|
-
console.warn('maxPoints is deprecated - remove from model');
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<div className={classNames(classes.class, className)}>
|
|
253
|
-
<Typography variant="h5" className={classes.rubricTitle}>
|
|
254
|
-
Rubric
|
|
255
|
-
</Typography>
|
|
256
|
-
<FormGroup row>
|
|
257
|
-
<MaxPoints max={10} value={value.points.length - 1} onChange={this.changeMaxPoints} />
|
|
258
|
-
<FormControlLabel
|
|
259
|
-
label="Exclude zeros"
|
|
260
|
-
control={<Checkbox checked={value.excludeZero} onChange={this.excludeZeros} />}
|
|
261
|
-
/>
|
|
262
|
-
</FormGroup>
|
|
263
|
-
<div className={classes.container}>
|
|
264
|
-
<DragDropContext onDragEnd={this.dragEnd}>
|
|
265
|
-
<Droppable droppableId="droppable">
|
|
266
|
-
{provided => (
|
|
267
|
-
<div {...provided.droppableProps} ref={provided.innerRef}>
|
|
268
|
-
{value.points.map(
|
|
269
|
-
(p, index) =>
|
|
270
|
-
this.shouldRenderPoint(index, value) && (
|
|
271
|
-
<Draggable
|
|
272
|
-
key={`${p.points}-${index}`}
|
|
273
|
-
index={index}
|
|
274
|
-
draggableId={index.toString()}
|
|
275
|
-
>
|
|
276
|
-
{provided => (
|
|
277
|
-
<div
|
|
278
|
-
className={classes.configHolder}
|
|
279
|
-
ref={provided.innerRef}
|
|
280
|
-
{...provided.draggableProps}
|
|
281
|
-
{...provided.dragHandleProps}
|
|
282
|
-
>
|
|
283
|
-
<PointConfig
|
|
284
|
-
points={value.points.length - 1 - index}
|
|
285
|
-
content={p}
|
|
286
|
-
sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}
|
|
287
|
-
onChange={content => this.changeContent(index, content, 'points')}
|
|
288
|
-
onSampleChange={content =>
|
|
289
|
-
this.changeContent(index, content, 'sampleAnswers')
|
|
290
|
-
}
|
|
291
|
-
onMenuChange={clickedItem =>
|
|
292
|
-
this.onPointMenuChange(index, clickedItem)
|
|
293
|
-
}
|
|
294
|
-
/>
|
|
295
|
-
</div>
|
|
296
|
-
)}
|
|
297
|
-
</Draggable>
|
|
298
|
-
)
|
|
299
|
-
)}
|
|
300
|
-
{provided.placeholder}
|
|
301
|
-
</div>
|
|
302
|
-
)}
|
|
303
|
-
</Droppable>
|
|
304
|
-
</DragDropContext>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const styles = theme => ({
|
|
312
|
-
container: {
|
|
313
|
-
backgroundColor: grey[200],
|
|
314
|
-
borderWidth: 1,
|
|
315
|
-
borderStyle: 'solid',
|
|
316
|
-
borderColor: grey[300],
|
|
317
|
-
padding: theme.spacing.unit * 2,
|
|
318
|
-
margin: theme.spacing.unit
|
|
319
|
-
},
|
|
320
|
-
configHolder: {
|
|
321
|
-
paddingTop: theme.spacing.unit,
|
|
322
|
-
paddingBottom: theme.spacing.unit
|
|
323
|
-
},
|
|
324
|
-
rubricTitle: {
|
|
325
|
-
paddingLeft: theme.spacing.unit,
|
|
326
|
-
margin: theme.spacing.unit
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
const StyledRawAuthoring = withStyles(styles)(RawAuthoring);
|
|
331
|
-
|
|
332
|
-
const Reverse = props => {
|
|
333
|
-
const points = Array.from(props.value.points || []).reverse();
|
|
334
|
-
let sampleAnswers = Array.from(props.value.sampleAnswers || []).reverse();
|
|
335
|
-
|
|
336
|
-
if (points.length > sampleAnswers.length) {
|
|
337
|
-
sampleAnswers = times(points.length - sampleAnswers.length)
|
|
338
|
-
.map(() => null)
|
|
339
|
-
.concat(sampleAnswers);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const value = { ...props.value, points, sampleAnswers };
|
|
343
|
-
|
|
344
|
-
const onChange = value => {
|
|
345
|
-
props.onChange({
|
|
346
|
-
...value,
|
|
347
|
-
points: Array.from(value.points || []).reverse(),
|
|
348
|
-
sampleAnswers: Array.from(value.sampleAnswers || []).reverse()
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
return <StyledRawAuthoring value={value} onChange={onChange} />;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
Reverse.propTypes = {
|
|
356
|
-
value: RubricType,
|
|
357
|
-
getIndex: PropTypes.func,
|
|
358
|
-
onChange: PropTypes.func
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
export default Reverse;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import Menu from '@material-ui/core/Menu';
|
|
2
|
-
import MenuItem from '@material-ui/core/MenuItem';
|
|
3
|
-
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
4
|
-
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
|
|
5
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
export class IconMenu extends React.Component {
|
|
10
|
-
static propTypes = {
|
|
11
|
-
opts: PropTypes.object,
|
|
12
|
-
onClick: PropTypes.func.isRequired,
|
|
13
|
-
classes: PropTypes.object.isRequired
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
constructor(props) {
|
|
17
|
-
super(props);
|
|
18
|
-
this.state = {
|
|
19
|
-
anchorEl: undefined,
|
|
20
|
-
open: false
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
handleClick = event => this.setState({ open: true, anchorEl: event.currentTarget });
|
|
25
|
-
|
|
26
|
-
handleRequestClose = () => this.setState({ open: false });
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
const { opts, onClick, classes } = this.props;
|
|
30
|
-
const { open, anchorEl } = this.state;
|
|
31
|
-
const keys = Object.keys(opts) || [];
|
|
32
|
-
|
|
33
|
-
const handleMenuClick = key => () => {
|
|
34
|
-
onClick(key);
|
|
35
|
-
this.handleRequestClose();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const iconColor = open ? 'inherit' : 'disabled';
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<div onClick={this.handleClick}>
|
|
43
|
-
<IconButton className={classes.icon}>
|
|
44
|
-
{open ? <MoreVertIcon color={iconColor} /> : <MoreHorizIcon color={iconColor} />}
|
|
45
|
-
</IconButton>
|
|
46
|
-
</div>
|
|
47
|
-
<Menu
|
|
48
|
-
id="point-menu"
|
|
49
|
-
anchorEl={anchorEl}
|
|
50
|
-
open={open}
|
|
51
|
-
onClose={this.handleRequestClose}
|
|
52
|
-
style={{ transform: 'translate(-15px, -15px)' }}
|
|
53
|
-
transformOrigin={{
|
|
54
|
-
vertical: 'center',
|
|
55
|
-
horizontal: 'right'
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{keys.map((k, index) => (
|
|
59
|
-
<MenuItem key={index} onClick={handleMenuClick(k)}>
|
|
60
|
-
{opts[k]}
|
|
61
|
-
</MenuItem>
|
|
62
|
-
))}
|
|
63
|
-
</Menu>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default class PointMenu extends React.Component {
|
|
70
|
-
static propTypes = {
|
|
71
|
-
onChange: PropTypes.func.isRequired,
|
|
72
|
-
classes: PropTypes.object.isRequired,
|
|
73
|
-
showSampleAnswer: PropTypes.bool.isRequired
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
static defaultProps = {
|
|
77
|
-
classes: {}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
render() {
|
|
81
|
-
const { onChange, classes, showSampleAnswer } = this.props;
|
|
82
|
-
const sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<IconMenu
|
|
86
|
-
onClick={key => onChange(key)}
|
|
87
|
-
opts={{
|
|
88
|
-
sample: sampleText
|
|
89
|
-
}}
|
|
90
|
-
classes={classes}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|