@pie-element/complex-rubric 3.8.1-next.10 → 3.8.1-next.9

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.
Files changed (66) hide show
  1. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
  2. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +2683 -0
  3. package/configure/node_modules/@pie-element/rubric/LICENSE.md +5 -0
  4. package/configure/node_modules/@pie-element/rubric/README.md +3 -0
  5. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
  6. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +2484 -0
  7. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js +68 -0
  8. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js.map +1 -0
  9. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +197 -0
  10. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
  11. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js +162 -0
  12. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js.map +1 -0
  13. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/authoring.js +573 -0
  14. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/authoring.js.map +1 -0
  15. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/index.js +24 -0
  16. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/index.js.map +1 -0
  17. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/point-menu.js +172 -0
  18. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/point-menu.js.map +1 -0
  19. package/configure/node_modules/@pie-element/rubric/configure/package.json +20 -0
  20. package/configure/node_modules/@pie-element/rubric/configure/src/__tests__/index.test.jsx +178 -0
  21. package/configure/node_modules/@pie-element/rubric/configure/src/defaults.js +42 -0
  22. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +129 -0
  23. package/configure/node_modules/@pie-element/rubric/configure/src/main.jsx +89 -0
  24. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/authoring.jsx +449 -0
  25. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/index.js +9 -0
  26. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/point-menu.jsx +94 -0
  27. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
  28. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +1510 -0
  29. package/configure/node_modules/@pie-element/rubric/controller/lib/defaults.js +16 -0
  30. package/configure/node_modules/@pie-element/rubric/controller/lib/defaults.js.map +1 -0
  31. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +59 -0
  32. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
  33. package/configure/node_modules/@pie-element/rubric/controller/package.json +12 -0
  34. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +33 -0
  35. package/configure/node_modules/@pie-element/rubric/controller/src/defaults.js +8 -0
  36. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +41 -0
  37. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +712 -0
  38. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +532 -0
  39. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
  40. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
  41. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +2 -0
  42. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +391 -0
  43. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +281 -0
  44. package/configure/node_modules/@pie-element/rubric/lib/index.js +94 -0
  45. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
  46. package/configure/node_modules/@pie-element/rubric/lib/main.js +270 -0
  47. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
  48. package/configure/node_modules/@pie-element/rubric/lib/print.js +114 -0
  49. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
  50. package/configure/node_modules/@pie-element/rubric/module/configure.js +1 -0
  51. package/configure/node_modules/@pie-element/rubric/module/controller.js +113 -0
  52. package/configure/node_modules/@pie-element/rubric/module/demo.js +33 -0
  53. package/configure/node_modules/@pie-element/rubric/module/element.js +1 -0
  54. package/configure/node_modules/@pie-element/rubric/module/index.html +21 -0
  55. package/configure/node_modules/@pie-element/rubric/module/manifest.json +10 -0
  56. package/configure/node_modules/@pie-element/rubric/module/print-demo.js +71 -0
  57. package/configure/node_modules/@pie-element/rubric/module/print.html +18 -0
  58. package/configure/node_modules/@pie-element/rubric/module/print.js +1 -0
  59. package/configure/node_modules/@pie-element/rubric/package.json +27 -0
  60. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +1815 -0
  61. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +49 -0
  62. package/configure/node_modules/@pie-element/rubric/src/index.js +37 -0
  63. package/configure/node_modules/@pie-element/rubric/src/main.jsx +219 -0
  64. package/configure/node_modules/@pie-element/rubric/src/print.js +63 -0
  65. package/configure/package.json +1 -1
  66. package/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pie-toolbox-rubric/index.js"],"names":["RUBRIC_TYPES","SIMPLE_RUBRIC","MULTI_TRAIT_RUBRIC","RUBRICLESS"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,aAAa,EAAE,cADI;AAEnBC,EAAAA,kBAAkB,EAAE,kBAFD;AAGnBC,EAAAA,UAAU,EAAE;AAHO,CAArB","sourcesContent":["import Authoring from './authoring';\n\nconst RUBRIC_TYPES = {\n SIMPLE_RUBRIC: 'simpleRubric',\n MULTI_TRAIT_RUBRIC: 'multiTraitRubric',\n RUBRICLESS: 'rubricless',\n};\n\nexport { Authoring, RUBRIC_TYPES };\n"],"file":"index.js"}
@@ -0,0 +1,172 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pie-toolbox-rubric/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":"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","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"}
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pie-element/rubric-configure",
3
+ "private": true,
4
+ "version": "4.8.0",
5
+ "description": "Rubric authoring view",
6
+ "main": "lib/index.js",
7
+ "author": "Pie Framework Authors",
8
+ "dependencies": {
9
+ "@material-ui/core": "^3.9.2",
10
+ "@pie-framework/pie-configure-events": "^1.3.0",
11
+ "@pie-lib/config-ui": "^11.25.0",
12
+ "@pie-lib/editable-html": "^11.17.0",
13
+ "@pie-lib/render-ui": "^4.31.0",
14
+ "debug": "^4.1.1",
15
+ "react": "^16.8.6",
16
+ "react-beautiful-dnd": "^11.0.2",
17
+ "react-dom": "^16.8.6"
18
+ },
19
+ "license": "ISC"
20
+ }
@@ -0,0 +1,178 @@
1
+ import RubricElement from '../index';
2
+ import defaults from '../defaults';
3
+ import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
4
+ import React from 'react';
5
+
6
+ jest.mock('react-dom', () => ({
7
+ render: jest.fn(),
8
+ }));
9
+
10
+ jest.mock('@pie-lib/config-ui', () => ({
11
+ layout: {
12
+ ConfigLayout: (props) => <div {...props} />,
13
+ },
14
+ settings: {
15
+ Panel: (props) => <div {...props} />,
16
+ toggle: jest.fn(),
17
+ radio: jest.fn(),
18
+ },
19
+ }));
20
+
21
+ const model = (extras) => ({
22
+ id: '1',
23
+ element: 'pie-rubric',
24
+ points: ['A', 'B', 'C', 'D'],
25
+ sampleAnswers: [true, true, false, false],
26
+ maxPoints: 3,
27
+ excludeZero: false,
28
+ excludeZeroEnabled: true,
29
+ maxPointsEnabled: true,
30
+ ...extras,
31
+ });
32
+
33
+ const invalidModel = (extras) => ({
34
+ id: '2',
35
+ element: 'pie-rubric',
36
+ points: ['A', 'B', 'C', 'D'],
37
+ sampleAnswers: [true, true, false, false],
38
+ maxPoints: 5,
39
+ excludeZero: false,
40
+ excludeZeroEnabled: true,
41
+ maxPointsEnabled: true,
42
+ ...extras,
43
+ });
44
+ const configuration = (c) => ({ ...defaults.configuration, ...c });
45
+
46
+ describe('RubricElement', () => {
47
+ let element;
48
+
49
+ beforeEach(() => {
50
+ element = new RubricElement();
51
+ });
52
+
53
+ afterEach(() => {
54
+ jest.clearAllMocks();
55
+ });
56
+
57
+ describe('set model', () => {
58
+ it('should set the model correctly', () => {
59
+ const newModel = model();
60
+ element.model = newModel;
61
+ expect(element._model).toEqual(newModel);
62
+ });
63
+ });
64
+
65
+ describe('onModelChanged', () => {
66
+ it('should dispatch ModelUpdatedEvent on model change', () => {
67
+ const newModel = model();
68
+ const dispatchEventSpy = jest.spyOn(element, 'dispatchEvent');
69
+ element.onModelChanged(newModel);
70
+ expect(element._model).toEqual(newModel);
71
+ expect(dispatchEventSpy).toHaveBeenCalledWith(new ModelUpdatedEvent(newModel, false));
72
+ });
73
+ });
74
+
75
+ describe('set configuration', () => {
76
+ it('should set the configuration correctly', () => {
77
+ const newConfiguration = configuration();
78
+ element.configuration = newConfiguration;
79
+ expect(element._configuration).toEqual(newConfiguration);
80
+ });
81
+ });
82
+
83
+ describe('onConfigurationChanged', () => {
84
+ it('should call _render method on configuration change and overwrite the defaults with the new values', () => {
85
+ const newConfiguration = configuration({ maxMaxPoints: 10 });
86
+ const renderSpy = jest.spyOn(element, '_render');
87
+ element.onConfigurationChanged(newConfiguration);
88
+ expect(element._configuration.maxMaxPoints).toEqual(10);
89
+ expect(renderSpy).toHaveBeenCalled();
90
+ });
91
+ });
92
+
93
+ describe('updateModelAccordingToReceivedProps', () => {
94
+ it('should return the same model if it is already valid', () => {
95
+ const validModel = model();
96
+ const validatedModel = element.updateModelAccordingToReceivedProps(validModel);
97
+ expect(validatedModel).toEqual(validModel);
98
+ });
99
+
100
+ it('should return an empty model if the input model is undefined', () => {
101
+ const validatedModel = element.updateModelAccordingToReceivedProps(undefined);
102
+ expect(validatedModel).toEqual(defaults.model);
103
+ });
104
+
105
+ it('should return an empty model if the input model is null', () => {
106
+ const validatedModel = element.updateModelAccordingToReceivedProps(null);
107
+ expect(validatedModel).toEqual(defaults.model);
108
+ });
109
+
110
+ it('should handle undefined properties in the input model', () => {
111
+ const validatedModel = element.updateModelAccordingToReceivedProps({});
112
+ expect(validatedModel).toEqual({ points: [], sampleAnswers: [] });
113
+ });
114
+
115
+ it('should handle null properties in the input model', () => {
116
+ const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: null, excludeZero: null });
117
+ expect(validatedModel).toEqual({
118
+ excludeZero: null,
119
+ maxPoints: null,
120
+ points: ['', ''],
121
+ sampleAnswers: [null, null],
122
+ });
123
+ });
124
+
125
+ it('should handle undefined points and sampleAnswers arrays', () => {
126
+ const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: 5, excludeZero: false });
127
+ expect(validatedModel.points).toEqual(['', '', '', '', '', '']);
128
+ expect(validatedModel.sampleAnswers).toEqual([null, null, null, null, null, null]);
129
+ });
130
+
131
+ it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave with maxPoints & excludeZero changed', () => {
132
+ const nextModel = model({
133
+ maxPoints: 7,
134
+ excludeZero: true,
135
+ });
136
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
137
+ expect(result.points).toEqual(['A', 'B', 'C', 'D', '', '', '']);
138
+ expect(result.sampleAnswers).toEqual([true, true, false, false, null, null, null]);
139
+ });
140
+
141
+ it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave and maxPointsChanged', () => {
142
+ const nextModel = model({
143
+ maxPoints: 4,
144
+ excludeZero: false,
145
+ });
146
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
147
+ expect(result.points).toEqual(['A', 'B', 'C', 'D', '']);
148
+ expect(result.sampleAnswers).toEqual([true, true, false, false, null]);
149
+ });
150
+
151
+ it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and excludeZeroChanged', () => {
152
+ const nextModel = model({
153
+ maxPoints: 3,
154
+ excludeZero: true,
155
+ });
156
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
157
+ expect(result.points).toEqual(['B', 'C', 'D']);
158
+ expect(result.sampleAnswers).toEqual([true, false, false]);
159
+ });
160
+
161
+ it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and maxPointsChanged', () => {
162
+ const nextModel = model({
163
+ maxPoints: 1,
164
+ excludeZero: false,
165
+ });
166
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
167
+ expect(result.points).toEqual(['A', 'B']);
168
+ expect(result.sampleAnswers).toEqual([true, true]);
169
+ });
170
+
171
+ it('should handle case if invalid model is set, after updateModelAccordingToReceivedProps the returned model is valid', () => {
172
+ const newModel = invalidModel();
173
+ element.onModelChanged(newModel);
174
+ expect(element._model.points).toEqual(['A', 'B', 'C', 'D', '', '']);
175
+ expect(element._model.sampleAnswers).toEqual([true, true, false, false, null, null]);
176
+ });
177
+ });
178
+ });
@@ -0,0 +1,42 @@
1
+ export default {
2
+ model: {
3
+ points: ['', '', '', ''],
4
+ sampleAnswers: [null, null, null, null],
5
+ maxPoints: 3,
6
+ excludeZero: false,
7
+ excludeZeroEnabled: true,
8
+ maxPointsEnabled: true,
9
+ },
10
+ configuration: {
11
+ baseInputConfiguration: {
12
+ audio: { disabled: false },
13
+ video: { disabled: false },
14
+ image: { disabled: false },
15
+ textAlign: { disabled: true },
16
+ showParagraphs: { disabled: false },
17
+ separateParagraphs: { disabled: true },
18
+ },
19
+ rubriclessInstruction: {
20
+ inputConfiguration: {
21
+ audio: { disabled: false },
22
+ video: { disabled: false },
23
+ image: { disabled: false },
24
+ },
25
+ },
26
+ showExcludeZero: {
27
+ settings: true,
28
+ label: 'Ability to exclude zero',
29
+ },
30
+ showMaxPoint: {
31
+ settings: true,
32
+ label: 'Show max points dropdown',
33
+ },
34
+ settingsPanelDisabled: false,
35
+ // width: '500px'
36
+ mathMlOptions: {
37
+ mmlOutput: false,
38
+ mmlEditing: false,
39
+ },
40
+ maxMaxPoints: 9,
41
+ },
42
+ };
@@ -0,0 +1,129 @@
1
+ import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom';
4
+ import debug from 'debug';
5
+
6
+ import Main from './main';
7
+ import defaults from './defaults';
8
+
9
+ const modelWithDefaults = (m) => ({ ...defaults.model, ...m });
10
+
11
+ const configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });
12
+
13
+ export default class RubricElement extends HTMLElement {
14
+ constructor() {
15
+ super();
16
+ debug.log('constructor called');
17
+ this._model = modelWithDefaults();
18
+ this._configuration = configurationWithDefaults();
19
+ this.onModelChanged = this.onModelChanged.bind(this);
20
+ this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
21
+ }
22
+
23
+ updateModelAccordingToReceivedProps = (nextModel) => {
24
+ const currentModel = { ...this._model };
25
+
26
+ if (!nextModel) {
27
+ return currentModel;
28
+ }
29
+
30
+ const validatedModel = { ...nextModel };
31
+
32
+ // excludeZero should be false and disabled when maxPoints is 1
33
+ if (validatedModel.maxPoints === 1) {
34
+ validatedModel.excludeZero = false;
35
+ }
36
+
37
+ const { maxPoints, excludeZero } = validatedModel || {};
38
+
39
+ validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];
40
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];
41
+
42
+ const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
43
+ const howManyPointsDoesItHave = validatedModel.points.length;
44
+
45
+ const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;
46
+ const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;
47
+
48
+ if (howManyPointsDoesItHave < howManyPointsShouldHave) {
49
+ if (excludeZeroChanged && !excludeZero) {
50
+ validatedModel.points = ['', ...validatedModel.points];
51
+ validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];
52
+ }
53
+
54
+ if (maxPointsChanged) {
55
+ for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {
56
+ validatedModel.points.push('');
57
+ validatedModel.sampleAnswers.push(null);
58
+ }
59
+ }
60
+ } else if (howManyPointsDoesItHave > howManyPointsShouldHave) {
61
+ if (excludeZeroChanged && excludeZero) {
62
+ validatedModel.points = validatedModel.points.slice(1);
63
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);
64
+ }
65
+
66
+ if (maxPointsChanged) {
67
+ validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);
68
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);
69
+ }
70
+ }
71
+
72
+ return validatedModel;
73
+ };
74
+
75
+ set model(m) {
76
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
77
+ this._render();
78
+ }
79
+
80
+ set configuration(c) {
81
+ this._configuration = configurationWithDefaults(c);
82
+ this._render();
83
+ }
84
+
85
+ onModelChanged(m) {
86
+ this._model = this.updateModelAccordingToReceivedProps(m);
87
+ this._render();
88
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
89
+ }
90
+
91
+ onConfigurationChanged = (c) => {
92
+ this._configuration = configurationWithDefaults(c);
93
+
94
+ if (this._model) {
95
+ this.onModelChanged(this._model);
96
+ }
97
+
98
+ this._render();
99
+ };
100
+
101
+ insertImage(handler) {
102
+ this.dispatchEvent(new InsertImageEvent(handler));
103
+ }
104
+
105
+ onDeleteImage(src, done) {
106
+ this.dispatchEvent(new DeleteImageEvent(src, done));
107
+ }
108
+
109
+ connectedCallback() {
110
+ this._render();
111
+ }
112
+
113
+ _render() {
114
+ if (this._model) {
115
+ let element = React.createElement(Main, {
116
+ model: this._model,
117
+ configuration: this._configuration,
118
+ onModelChanged: this.onModelChanged,
119
+ onConfigurationChanged: this.onConfigurationChanged,
120
+ imageSupport: {
121
+ add: this.insertImage.bind(this),
122
+ delete: this.onDeleteImage.bind(this),
123
+ },
124
+ });
125
+
126
+ ReactDOM.render(element, this);
127
+ }
128
+ }
129
+ }
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import { Authoring } from './pie-toolbox-rubric/index';
3
+ import { withStyles } from '@material-ui/core/styles';
4
+ import { layout, settings } from '@pie-lib/config-ui';
5
+
6
+ const { Panel, toggle } = settings;
7
+
8
+ const styles = (theme) => ({
9
+ design: {
10
+ fontFamily: 'Cerebri Sans',
11
+ fontSize: theme.typography.fontSize,
12
+ },
13
+ });
14
+
15
+ class Main extends React.Component {
16
+ verifyRubriclessModel = (m, config) => {
17
+ const { rubricless = false } = config || {};
18
+ return rubricless ? (({ points, sampleAnswers, ...rest }) => rest)(m) : m;
19
+ };
20
+
21
+ render() {
22
+ const { model, configuration, onConfigurationChanged, onModelChanged, imageSupport } = this.props || {};
23
+ const {
24
+ baseInputConfiguration = {},
25
+ contentDimensions = {},
26
+ settingsPanelDisabled,
27
+ showExcludeZero = {},
28
+ showMaxPoint = {},
29
+ mathMlOptions = {},
30
+ rubricless = false,
31
+ rubriclessInstruction,
32
+ width,
33
+ } = configuration || {};
34
+
35
+ // ensure to eliminate points and sampleAnswers in case of rubricless
36
+ const value = this.verifyRubriclessModel(model, configuration);
37
+ const { extraCSSRules } = model;
38
+
39
+ const panelProperties = {
40
+ excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),
41
+ maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
42
+ rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label),
43
+ };
44
+
45
+ const getPluginProps = (props) => {
46
+ return Object.assign(
47
+ {
48
+ ...baseInputConfiguration,
49
+ },
50
+ props || {},
51
+ );
52
+ };
53
+
54
+ return (
55
+ <layout.ConfigLayout
56
+ extraCSSRules={extraCSSRules}
57
+ dimensions={contentDimensions}
58
+ hideSettings={settingsPanelDisabled}
59
+ settings={
60
+ <Panel
61
+ model={model}
62
+ onChangeModel={onModelChanged}
63
+ configuration={configuration}
64
+ onChangeConfiguration={onConfigurationChanged}
65
+ pluginOpts={getPluginProps(rubriclessInstruction?.inputConfiguration)}
66
+ groups={{
67
+ Properties: panelProperties,
68
+ }}
69
+ imageSupport={imageSupport}
70
+ />
71
+ }
72
+ >
73
+ <div style={{ maxWidth: width }}>
74
+ <Authoring
75
+ value={value}
76
+ config={configuration}
77
+ onChange={onModelChanged}
78
+ mathMlOptions={mathMlOptions}
79
+ rubricless={rubricless}
80
+ pluginOpts={baseInputConfiguration}
81
+ imageSupport={imageSupport}
82
+ />
83
+ </div>
84
+ </layout.ConfigLayout>
85
+ );
86
+ }
87
+ }
88
+
89
+ export default withStyles(styles)(Main);