@pie-element/complex-rubric 0.0.2-next.4424

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 (121) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +3 -0
  3. package/configure/lib/defaults.js +99 -0
  4. package/configure/lib/defaults.js.map +1 -0
  5. package/configure/lib/index.js +232 -0
  6. package/configure/lib/index.js.map +1 -0
  7. package/configure/lib/main.js +165 -0
  8. package/configure/lib/main.js.map +1 -0
  9. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +1 -0
  10. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +376 -0
  11. package/configure/node_modules/@pie-element/multi-trait-rubric/LICENSE.md +5 -0
  12. package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +55 -0
  13. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +1 -0
  14. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +344 -0
  15. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +455 -0
  16. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +82 -0
  18. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +112 -0
  20. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +438 -0
  22. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +1 -0
  23. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +324 -0
  24. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +1 -0
  25. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +490 -0
  26. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +1 -0
  27. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +334 -0
  28. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +1 -0
  29. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +254 -0
  30. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +1 -0
  31. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +29 -0
  32. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +1 -0
  33. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +22 -0
  34. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +1 -0
  35. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +66 -0
  36. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +9 -0
  37. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +1 -0
  38. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +122 -0
  39. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +1 -0
  40. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +15 -0
  41. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +226 -0
  42. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +169 -0
  43. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +8 -0
  44. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +108 -0
  45. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +1 -0
  46. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +6 -0
  47. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +282 -0
  48. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +189 -0
  49. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +85 -0
  50. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +99 -0
  52. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +209 -0
  54. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +103 -0
  56. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +1 -0
  57. package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +24 -0
  58. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
  59. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +731 -0
  60. package/configure/node_modules/@pie-element/rubric/LICENSE.md +5 -0
  61. package/configure/node_modules/@pie-element/rubric/README.md +3 -0
  62. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
  63. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +615 -0
  64. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +93 -0
  65. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
  66. package/configure/node_modules/@pie-element/rubric/configure/package.json +16 -0
  67. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +38 -0
  68. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
  69. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +105 -0
  70. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +14 -0
  71. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
  72. package/configure/node_modules/@pie-element/rubric/controller/package.json +9 -0
  73. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +35 -0
  74. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +6 -0
  75. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +24 -0
  76. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +19 -0
  77. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
  78. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
  79. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +3 -0
  80. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +62 -0
  81. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +35 -0
  82. package/configure/node_modules/@pie-element/rubric/lib/index.js +88 -0
  83. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
  84. package/configure/node_modules/@pie-element/rubric/lib/main.js +171 -0
  85. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
  86. package/configure/node_modules/@pie-element/rubric/lib/print.js +114 -0
  87. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
  88. package/configure/node_modules/@pie-element/rubric/package.json +25 -0
  89. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +22767 -0
  90. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +48 -0
  91. package/configure/node_modules/@pie-element/rubric/src/index.js +38 -0
  92. package/configure/node_modules/@pie-element/rubric/src/main.jsx +117 -0
  93. package/configure/node_modules/@pie-element/rubric/src/print.js +63 -0
  94. package/configure/package.json +22 -0
  95. package/configure/src/__tests__/__snapshots__/main.test.jsx.snap +106 -0
  96. package/configure/src/__tests__/index.test.js +41 -0
  97. package/configure/src/__tests__/main.test.jsx +104 -0
  98. package/configure/src/defaults.js +122 -0
  99. package/configure/src/index.js +138 -0
  100. package/configure/src/main.jsx +117 -0
  101. package/controller/lib/defaults.js +99 -0
  102. package/controller/lib/defaults.js.map +1 -0
  103. package/controller/lib/index.js +147 -0
  104. package/controller/lib/index.js.map +1 -0
  105. package/controller/package.json +12 -0
  106. package/controller/src/__tests__/index.test.js +58 -0
  107. package/controller/src/defaults.js +121 -0
  108. package/controller/src/index.js +81 -0
  109. package/docs/config-schema.json +427 -0
  110. package/docs/config-schema.json.md +315 -0
  111. package/docs/demo/config.js +8 -0
  112. package/docs/demo/generate.js +119 -0
  113. package/docs/demo/index.html +1 -0
  114. package/docs/demo/session.js +6 -0
  115. package/docs/pie-schema.json +994 -0
  116. package/docs/pie-schema.json.md +660 -0
  117. package/lib/index.js +176 -0
  118. package/lib/index.js.map +1 -0
  119. package/package.json +25 -0
  120. package/src/__tests__/index.test.js +166 -0
  121. package/src/index.js +106 -0
@@ -0,0 +1,48 @@
1
+ import { shallow, mount } from 'enzyme';
2
+ import React from 'react';
3
+ import Rubric from '../main';
4
+ import Link from '@material-ui/core/Link';
5
+
6
+
7
+ describe('rubric viewer', () => {
8
+
9
+
10
+ const wrapper = extras => {
11
+ const props = {value: {
12
+ points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
13
+ sampleAnswers: [null, 'just right', 'not left', null],
14
+ excludeZero: false,
15
+ ...extras
16
+ }};
17
+
18
+ return mount(<Rubric {...props} />);
19
+ };
20
+
21
+ describe('snapshot', () => {
22
+ it('renders', () => {
23
+ const w = wrapper();
24
+ expect(w).toMatchSnapshot();
25
+ });
26
+ });
27
+
28
+ describe('expanded snapshot', () => {
29
+ it('renders', () => {
30
+ const w = wrapper();
31
+ w.find(Link).simulate('click');
32
+ expect(w).toMatchSnapshot();
33
+ });
34
+ });
35
+
36
+ describe('exclude zeros', () => {
37
+ it('renders correctly with exluded zeroes', () => {
38
+ let w = wrapper({ excludeZero: true });
39
+ w.find(Link).simulate('click');
40
+ expect(w.find('li').length).toEqual(5);
41
+
42
+ w = wrapper({ excludeZero: false });
43
+ w.find(Link).simulate('click');
44
+ expect(w.find('li').length).toEqual(6);
45
+ });
46
+ });
47
+
48
+ });
@@ -0,0 +1,38 @@
1
+ import Rubric from './main';
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom';
4
+ import debug from 'debug';
5
+
6
+
7
+ export default class RubricRender extends HTMLElement {
8
+
9
+ constructor() {
10
+ super();
11
+ debug.log('constructor called');
12
+ this.onModelChanged = this.onModelChanged.bind(this);
13
+ }
14
+
15
+ set model(s) {
16
+ this._model = s;
17
+ this._render();
18
+ }
19
+
20
+ onModelChanged(m) {
21
+ this._model = m;
22
+ this._render();
23
+ }
24
+
25
+ connectedCallback() {
26
+ this._render();
27
+ }
28
+
29
+ _render() {
30
+ if (this._model) {
31
+ const el = (
32
+ <Rubric value={this._model} />
33
+ );
34
+
35
+ ReactDOM.render(el, this);
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@material-ui/core/styles';
3
+ import ListItem from '@material-ui/core/ListItem';
4
+ import List from '@material-ui/core/List';
5
+ import ListItemText from '@material-ui/core/ListItemText';
6
+ import Link from '@material-ui/core/Link';
7
+ import Collapse from '@material-ui/core/Collapse';
8
+ import PropTypes from 'prop-types';
9
+
10
+ export const RubricType = PropTypes.shape({
11
+ excludeZero: PropTypes.bool,
12
+ points: PropTypes.arrayOf(PropTypes.string),
13
+ sampleAnswers: PropTypes.arrayOf(PropTypes.string),
14
+ });
15
+
16
+ class Rubric extends React.Component {
17
+ dudUrl = 'javascript:;';
18
+
19
+ constructor(props) {
20
+ super(props);
21
+ this.state = {
22
+ rubricOpen: false,
23
+ linkPrefix: 'Show',
24
+ };
25
+ this.toggleRubric = this.toggleRubric.bind(this);
26
+ }
27
+
28
+ static propTypes = {
29
+ classes: PropTypes.object.isRequired,
30
+ animationsDisabled: PropTypes.bool,
31
+ value: RubricType,
32
+ };
33
+
34
+ toggleRubric() {
35
+ this.setState({ rubricOpen: !this.state.rubricOpen });
36
+ this.setState({ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide' });
37
+ }
38
+
39
+ shouldRenderPoint = (index, value) => {
40
+ if (!value.excludeZero) {
41
+ return true;
42
+ } else {
43
+ return index !== 0;
44
+ }
45
+ };
46
+
47
+ render() {
48
+ const { value, classes, animationsDisabled } = this.props;
49
+
50
+ if (value && value.points) {
51
+ const { points, sampleAnswers } = value;
52
+
53
+ const rubricList = <List component="nav">
54
+ {points.slice(0).reverse().map(
55
+ (desc, index) => {
56
+ index = points.length - index - 1;
57
+ return this.shouldRenderPoint(index, value) && (
58
+ <React.Fragment key={index}>
59
+ <ListItem key={`P${index}`}>
60
+ <ListItemText
61
+ className={classes.rubricCol}
62
+ primary={index === 1 ? `${index} PT` : `${index} PTS`}
63
+ />
64
+ <ListItemText
65
+ primary={
66
+ <div dangerouslySetInnerHTML={{ __html: desc }} />
67
+ }
68
+ />
69
+ </ListItem>
70
+ {sampleAnswers && sampleAnswers[index] && (
71
+ <ListItem key={`S${index}`}>
72
+ <ListItemText
73
+ className={classes.rubricCol}
74
+ style={{marginLeft: '20px'}}
75
+ primary={'Sample Answer'}
76
+ />
77
+ <ListItemText
78
+ primary={
79
+ <div dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
80
+ }
81
+ />
82
+ </ListItem>
83
+ )}
84
+ </React.Fragment>
85
+ )
86
+ })}
87
+ </List>;
88
+
89
+ return (
90
+ <div className={classes.root}>
91
+ {!animationsDisabled ?
92
+ <React.Fragment>
93
+ <Link href={this.dudUrl} onClick={this.toggleRubric}>
94
+ {this.state.linkPrefix} Rubric
95
+ </Link>
96
+ <Collapse in={this.state.rubricOpen} timeout="auto">
97
+ {rubricList}
98
+ </Collapse>
99
+ </React.Fragment>
100
+ : rubricList
101
+ }
102
+ </div>
103
+ );
104
+ } else {
105
+ return null;
106
+ }
107
+ }
108
+ }
109
+
110
+ const styles = () => ({
111
+ rubricCol: {
112
+ flex: '0 1 auto',
113
+ minWidth: 'fit-content'
114
+ },
115
+ });
116
+
117
+ export default withStyles(styles)(Rubric);
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import debounce from 'lodash/debounce';
4
+ import Main from './main';
5
+ import { renderMath } from '@pie-lib/math-rendering';
6
+ import debug from 'debug';
7
+
8
+ const log = debug('pie-element:rubric:print');
9
+
10
+ const preparePrintModel = (model, opts) => {
11
+ const instr = opts.role === 'instructor';
12
+
13
+ if (!instr) {
14
+ return {};
15
+ }
16
+
17
+ model.value = { ...model };
18
+ model.mode = 'evaluate';
19
+ model.animationsDisabled = true;
20
+
21
+ return model;
22
+ };
23
+
24
+ export default class RubricPrint extends HTMLElement {
25
+ constructor() {
26
+ super();
27
+ this._options = null;
28
+ this._model = null;
29
+ this._session = [];
30
+ this._rerender = debounce(
31
+ () => {
32
+ if (this._model && this._session) {
33
+ const printModel = preparePrintModel(this._model, this._options);
34
+
35
+ const element =
36
+ this._options &&
37
+ React.createElement(Main, {
38
+ ...printModel,
39
+ });
40
+
41
+ ReactDOM.render(element, this, () => {
42
+ log('render complete - render math');
43
+ renderMath(this);
44
+ });
45
+ } else {
46
+ log('skip');
47
+ }
48
+ },
49
+ 50,
50
+ { leading: false, trailing: true }
51
+ );
52
+ }
53
+ set options(o) {
54
+ this._options = o;
55
+ }
56
+
57
+ set model(s) {
58
+ this._model = s;
59
+ this._rerender();
60
+ }
61
+
62
+ connectedCallback() {}
63
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@pie-element/complex-rubric-configure",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "description": "Complex Rubric authoring view",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "author": "Pie Framework Authors",
9
+ "dependencies": {
10
+ "@pie-framework/pie-configure-events": "^1.2.0",
11
+ "@pie-element/multi-trait-rubric": "^2.0.7",
12
+ "@pie-element/rubric": "^2.0.7",
13
+ "@pie-lib/rubric": "^0.4.39",
14
+ "@material-ui/core": "^3.9.2",
15
+ "debug": "^4.1.1",
16
+ "react": "^16.8.6",
17
+ "react-dom": "^16.8.6",
18
+ "prop-types": "^15.6.2",
19
+ "lodash": "^4.17.15"
20
+ },
21
+ "license": "ISC"
22
+ }
@@ -0,0 +1,106 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Main snapshot renders 1`] = `
4
+ <div>
5
+ <div>
6
+ <div>
7
+ <RadioGroup
8
+ aria-label="rubric-type"
9
+ defaultValue="simpleRubric"
10
+ name="rubricType"
11
+ onChange={[Function]}
12
+ value="simpleRubric"
13
+ >
14
+ <WithStyles(WithFormControlContext(FormControlLabel))
15
+ checked={true}
16
+ control={<WithStyles(Radio) />}
17
+ label="Simple Rubric"
18
+ value="simpleRubric"
19
+ />
20
+ <WithStyles(WithFormControlContext(FormControlLabel))
21
+ checked={false}
22
+ control={<WithStyles(Radio) />}
23
+ label="Multi Trait Rubric"
24
+ value="multiTraitRubric"
25
+ />
26
+ </RadioGroup>
27
+ </div>
28
+ <div>
29
+ <rubric-configure
30
+ id="simpleRubric"
31
+ key="simple-rubric"
32
+ />
33
+ </div>
34
+ </div>
35
+ </div>
36
+ `;
37
+
38
+ exports[`Main snapshot renders multi trait rubric 1`] = `
39
+ <div>
40
+ <div>
41
+ <div>
42
+ <RadioGroup
43
+ aria-label="rubric-type"
44
+ defaultValue="simpleRubric"
45
+ name="rubricType"
46
+ onChange={[Function]}
47
+ value="multiTraitRubric"
48
+ >
49
+ <WithStyles(WithFormControlContext(FormControlLabel))
50
+ checked={false}
51
+ control={<WithStyles(Radio) />}
52
+ label="Simple Rubric"
53
+ value="simpleRubric"
54
+ />
55
+ <WithStyles(WithFormControlContext(FormControlLabel))
56
+ checked={true}
57
+ control={<WithStyles(Radio) />}
58
+ label="Multi Trait Rubric"
59
+ value="multiTraitRubric"
60
+ />
61
+ </RadioGroup>
62
+ </div>
63
+ <div>
64
+ <multi-trait-rubric-configure
65
+ id="multiTraitRubric"
66
+ key="multi-trait-rubric"
67
+ />
68
+ </div>
69
+ </div>
70
+ </div>
71
+ `;
72
+
73
+ exports[`Main snapshot renders simple rubric 1`] = `
74
+ <div>
75
+ <div>
76
+ <div>
77
+ <RadioGroup
78
+ aria-label="rubric-type"
79
+ defaultValue="simpleRubric"
80
+ name="rubricType"
81
+ onChange={[Function]}
82
+ value="simpleRubric"
83
+ >
84
+ <WithStyles(WithFormControlContext(FormControlLabel))
85
+ checked={true}
86
+ control={<WithStyles(Radio) />}
87
+ label="Simple Rubric"
88
+ value="simpleRubric"
89
+ />
90
+ <WithStyles(WithFormControlContext(FormControlLabel))
91
+ checked={false}
92
+ control={<WithStyles(Radio) />}
93
+ label="Multi Trait Rubric"
94
+ value="multiTraitRubric"
95
+ />
96
+ </RadioGroup>
97
+ </div>
98
+ <div>
99
+ <rubric-configure
100
+ id="simpleRubric"
101
+ key="simple-rubric"
102
+ />
103
+ </div>
104
+ </div>
105
+ </div>
106
+ `;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+
4
+ import defaults from '../defaults';
5
+
6
+ jest.mock('@pie-lib/config-ui', () => ({
7
+ settings: {
8
+ Panel: props => <div {...props} />,
9
+ toggle: jest.fn(),
10
+ radio: jest.fn()
11
+ }
12
+ }));
13
+
14
+ const model = () => ({ ...defaults.model });
15
+
16
+ jest.mock('react-dom', () => ({
17
+ render: jest.fn()
18
+ }));
19
+
20
+ describe('index', () => {
21
+ let Def;
22
+ let el;
23
+ let onModelChanged = jest.fn();
24
+ let initialModel = model();
25
+
26
+ beforeAll(() => {
27
+ Def = require('../index').default;
28
+ });
29
+
30
+ beforeEach(() => {
31
+ el = new Def();
32
+ el.model = initialModel;
33
+ el.onModelChanged = onModelChanged;
34
+ });
35
+
36
+ describe('set model', () => {
37
+ it('calls ReactDOM.render', () => {
38
+ expect(ReactDOM.render).toHaveBeenCalled();
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,104 @@
1
+ import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+ import { Main } from '@pie-element/complex-rubric-configure/src/main';
4
+
5
+ import defaults from '../defaults';
6
+
7
+ jest.mock('@pie-lib/rubric', () => ({
8
+ RUBRIC_TYPES: {
9
+ SIMPLE_RUBRIC: 'simpleRubric',
10
+ MULTI_TRAIT_RUBRIC: 'multiTraitRubric'
11
+ }
12
+ }));
13
+
14
+ const model = (extras) => ({
15
+ id: '1',
16
+ element: 'complex-rubric',
17
+ ...defaults.model,
18
+ ...extras
19
+ });
20
+
21
+ describe('Main', () => {
22
+ let initialModel = model();
23
+ let onModelChanged = jest.fn();
24
+ let onConfigurationChanged = jest.fn();
25
+
26
+ const wrapper = extras => {
27
+ const defaults = {
28
+ onModelChanged,
29
+ onConfigurationChanged,
30
+ classes: {},
31
+ model: model(extras),
32
+ configuration: {
33
+ multiTraitrubric: {
34
+ showStandards: {
35
+ settings: false,
36
+ label: 'Show Standards',
37
+ enabled: false
38
+ },
39
+ showExcludeZero: {
40
+ settings: true,
41
+ label: 'Exclude Zero',
42
+ enabled: false
43
+ },
44
+ showScorePointLabels: {
45
+ settings: true,
46
+ label: 'Show Score Point Labels',
47
+ enabled: false
48
+ },
49
+ showLevelTagInput: {
50
+ settings: true,
51
+ label: 'Show Level Tag Input',
52
+ enabled: false
53
+ },
54
+ showDescription: {
55
+ settings: true,
56
+ label: 'Show Description',
57
+ enabled: false
58
+ },
59
+ showVisibleToStudent: {
60
+ settings: true,
61
+ label: 'Visible to Student',
62
+ enabled: false
63
+ },
64
+ showHalfScoring: {
65
+ settings: true,
66
+ label: 'Half Scoring',
67
+ enabled: false
68
+ },
69
+ dragAndDrop: {
70
+ settings: false,
71
+ label: 'Enable Drag and Drop',
72
+ enabled: false,
73
+ }
74
+ }
75
+ },
76
+ };
77
+ const props = { ...defaults };
78
+
79
+ return shallow(<Main {...props} />);
80
+ };
81
+
82
+ describe('snapshot', () => {
83
+ it('renders', () => {
84
+ const w = wrapper();
85
+ expect(w).toMatchSnapshot();
86
+ });
87
+
88
+ it('renders simple rubric', () => {
89
+ const w = wrapper({ rubricType: 'simpleRubric' });
90
+ expect(w).toMatchSnapshot();
91
+ });
92
+
93
+ it('renders multi trait rubric', () => {
94
+ const w = wrapper({ rubricType: 'multiTraitRubric' });
95
+ expect(w).toMatchSnapshot();
96
+ });
97
+
98
+ it('calls onModelChange when changing rubric type', () => {
99
+ const w = wrapper();
100
+ w.instance().onChangeRubricType({ target: { value: 'multiTraitRubric' } });
101
+ expect(onModelChanged).toBeCalledWith({ ...initialModel, rubricType: 'multiTraitRubric' });
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,122 @@
1
+ const multiTraitDefaultModel = {
2
+ visibleToStudent: true,
3
+ halfScoring: false,
4
+ pointLabels: true,
5
+ description: false,
6
+ standards: false,
7
+ scales: [],
8
+ excludeZero: false,
9
+ };
10
+
11
+ const rubricDefaultModel = {
12
+ points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
13
+ sampleAnswers: [null, 'just right', 'not left', null],
14
+ maxPoints: 4,
15
+ excludeZero: false
16
+ };
17
+
18
+ const multiTraitDefaultConfiguration = {
19
+ settingsPanelDisabled: true,
20
+ excludeZeroDialogBoxContent: {
21
+ title: 'Exclude 0 (Zero) from Score Point Values.',
22
+ text: `<div>
23
+ You are about to exclude 0 from score point values.
24
+ <br/>
25
+ Some of the existing data has to be changed.
26
+ <br/>
27
+ Please choose if you want to:
28
+ <ul>
29
+ <li>
30
+ shift Labels and Descriptions to the left
31
+ </li>
32
+ <li>
33
+ remove 0 column with its Label and Description
34
+ </li>
35
+ </ul>
36
+ </div>`
37
+ },
38
+ includeZeroDialogBoxContent: {
39
+ title: 'Include 0 (Zero) in Score Point Values.',
40
+ text: `<div>
41
+ You are about to include 0 in score point values.
42
+ <br/>
43
+ Some of the existing data has to be changed.
44
+ <br/>
45
+ Please choose if you want to:
46
+ <ul>
47
+ <li>
48
+ shift Labels and Descriptions to the right
49
+ </li>
50
+ <li>
51
+ add 0 column with empty Label and Descriptions
52
+ </li>
53
+ </ul>
54
+ </div>`
55
+ },
56
+ deleteTraitDialogBoxContent: {
57
+ title: 'Delete Trait',
58
+ text: 'Are you sure you want to delete this trait?'
59
+ },
60
+ deleteScaleDialogBoxContent: {
61
+ title: 'Delete Scale',
62
+ text: 'Are you sure you want to delete this scale?'
63
+ },
64
+ maxPointsDialogBoxContent: {
65
+ title: 'Decreasing Max Points.',
66
+ text: ` You are about to decrease max score point value.
67
+ <br/>
68
+ All the Labels and Descriptions for scores above Max Point will be deleted.`
69
+ },
70
+ spellCheck: {
71
+ label: 'Spellcheck',
72
+ settings: false,
73
+ enabled: true
74
+ },
75
+ showExcludeZero: {
76
+ settings: true,
77
+ label: 'Exclude Zero',
78
+ },
79
+ showScorePointLabels: {
80
+ settings: true,
81
+ label: 'Show Score Point Labels',
82
+ },
83
+ showDescription: {
84
+ settings: true,
85
+ label: 'Show Description',
86
+ },
87
+ showVisibleToStudent: {
88
+ settings: true,
89
+ label: 'Visible to Student',
90
+ },
91
+ showHalfScoring: {
92
+ settings: true,
93
+ label: 'Half Scoring',
94
+ },
95
+ width: '900px',
96
+ // these should not be set to true (should not be used) for now
97
+ showStandards: {
98
+ settings: false,
99
+ label: 'Show Standards',
100
+ },
101
+ showLevelTagInput: {
102
+ settings: false,
103
+ label: 'Show Level Tag Input',
104
+ enabled: false
105
+ },
106
+ dragAndDrop: {
107
+ settings: true,
108
+ label: 'Enable Drag and Drop',
109
+ enabled: false,
110
+ }
111
+ };
112
+
113
+ export default {
114
+ model: {
115
+ rubricType: 'simpleRubric',
116
+ rubrics: { simpleRubric: rubricDefaultModel, multiTraitRubric: multiTraitDefaultModel }
117
+ },
118
+ configuration: {
119
+ multiTraitRubric: multiTraitDefaultConfiguration
120
+ }
121
+ };
122
+