@pie-element/complex-rubric 1.0.3-next.4507 → 1.0.3

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 (135) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/configure/CHANGELOG.md +8 -0
  3. package/configure/package.json +6 -6
  4. package/controller/CHANGELOG.md +8 -0
  5. package/controller/package.json +2 -2
  6. package/package.json +4 -4
  7. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +0 -1
  8. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +0 -376
  9. package/configure/node_modules/@pie-element/multi-trait-rubric/LICENSE.md +0 -5
  10. package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +0 -55
  11. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +0 -1
  12. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +0 -344
  13. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +0 -455
  14. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +0 -1
  15. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +0 -82
  16. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +0 -1
  17. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +0 -112
  18. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +0 -1
  19. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +0 -438
  20. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +0 -1
  21. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +0 -324
  22. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +0 -1
  23. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +0 -490
  24. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +0 -1
  25. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +0 -334
  26. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +0 -1
  27. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +0 -254
  28. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +0 -1
  29. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +0 -29
  30. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +0 -1
  31. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +0 -22
  32. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +0 -1
  33. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +0 -66
  34. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +0 -9
  35. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +0 -1
  36. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +0 -122
  37. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +0 -1
  38. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +0 -15
  39. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +0 -226
  40. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +0 -169
  41. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +0 -8
  42. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +0 -108
  43. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +0 -1
  44. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +0 -6
  45. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +0 -282
  46. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +0 -189
  47. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +0 -85
  48. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +0 -1
  49. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +0 -99
  50. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +0 -1
  51. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +0 -209
  52. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +0 -1
  53. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +0 -103
  54. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +0 -1
  55. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/CHANGELOG.json +0 -937
  56. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/CHANGELOG.md +0 -686
  57. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/LICENSE.md +0 -5
  58. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/README.md +0 -33
  59. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +0 -134
  60. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +0 -1
  61. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/color.js +0 -134
  62. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/color.js.map +0 -1
  63. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/feedback.js +0 -151
  64. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/feedback.js.map +0 -1
  65. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/has-text.js +0 -24
  66. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/has-text.js.map +0 -1
  67. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/html-and-math.js +0 -90
  68. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +0 -1
  69. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/index.js +0 -104
  70. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/index.js.map +0 -1
  71. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/input-container.js +0 -60
  72. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/input-container.js.map +0 -1
  73. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/preview-layout.js +0 -123
  74. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +0 -1
  75. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +0 -165
  76. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +0 -1
  77. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/purpose.js +0 -28
  78. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/purpose.js.map +0 -1
  79. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/readable.js +0 -28
  80. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/readable.js.map +0 -1
  81. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/response-indicators.js +0 -151
  82. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +0 -1
  83. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +0 -181
  84. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +0 -1
  85. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/package.json +0 -30
  86. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +0 -68
  87. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/color.js +0 -48
  88. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/feedback.jsx +0 -100
  89. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/has-text.js +0 -14
  90. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/html-and-math.js +0 -40
  91. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/index.js +0 -27
  92. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/input-container.jsx +0 -41
  93. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +0 -77
  94. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +0 -103
  95. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/purpose.jsx +0 -19
  96. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/readable.jsx +0 -19
  97. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +0 -89
  98. package/configure/node_modules/@pie-element/multi-trait-rubric/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +0 -118
  99. package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +0 -24
  100. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +0 -257
  101. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +0 -731
  102. package/configure/node_modules/@pie-element/rubric/LICENSE.md +0 -5
  103. package/configure/node_modules/@pie-element/rubric/README.md +0 -3
  104. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +0 -197
  105. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +0 -615
  106. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +0 -93
  107. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +0 -1
  108. package/configure/node_modules/@pie-element/rubric/configure/package.json +0 -16
  109. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +0 -38
  110. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +0 -17
  111. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +0 -105
  112. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +0 -14
  113. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +0 -1
  114. package/configure/node_modules/@pie-element/rubric/controller/package.json +0 -9
  115. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +0 -35
  116. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +0 -6
  117. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +0 -24
  118. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +0 -19
  119. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +0 -8
  120. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +0 -8
  121. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +0 -3
  122. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +0 -62
  123. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +0 -35
  124. package/configure/node_modules/@pie-element/rubric/lib/index.js +0 -88
  125. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +0 -1
  126. package/configure/node_modules/@pie-element/rubric/lib/main.js +0 -171
  127. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +0 -1
  128. package/configure/node_modules/@pie-element/rubric/lib/print.js +0 -114
  129. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +0 -1
  130. package/configure/node_modules/@pie-element/rubric/package.json +0 -25
  131. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +0 -22767
  132. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +0 -48
  133. package/configure/node_modules/@pie-element/rubric/src/index.js +0 -38
  134. package/configure/node_modules/@pie-element/rubric/src/main.jsx +0 -117
  135. package/configure/node_modules/@pie-element/rubric/src/print.js +0 -63
@@ -1,27 +0,0 @@
1
- import * as indicators from './response-indicators';
2
- import Feedback from './feedback';
3
- import Collapsible from './collapsible';
4
- import withUndoReset from './withUndoReset';
5
- import PreviewLayout from './preview-layout';
6
- import HtmlAndMath from './html-and-math';
7
- import InputContainer from './input-container';
8
- import PreviewPrompt from './preview-prompt';
9
- import Readable from './readable';
10
- import Purpose from './purpose';
11
- import * as color from './color';
12
- import { hasText } from './has-text';
13
-
14
- export {
15
- HtmlAndMath,
16
- indicators,
17
- withUndoReset,
18
- Feedback,
19
- PreviewLayout,
20
- Collapsible,
21
- InputContainer,
22
- PreviewPrompt,
23
- color,
24
- Readable,
25
- Purpose,
26
- hasText
27
- };
@@ -1,41 +0,0 @@
1
- import InputLabel from '@material-ui/core/InputLabel';
2
- import PropTypes from 'prop-types';
3
- import React from 'react';
4
- import classNames from 'classnames';
5
- import { withStyles } from '@material-ui/core/styles';
6
- import FormControl from '@material-ui/core/FormControl';
7
-
8
- const RawInputContainer = props => {
9
- const { label, className, children, classes } = props;
10
- const names = classNames(classes.formControl, className);
11
-
12
- return (
13
- <FormControl className={names}>
14
- <InputLabel className={classes.label} shrink={true}>
15
- {label}
16
- </InputLabel>
17
- {children}
18
- </FormControl>
19
- );
20
- };
21
-
22
- RawInputContainer.propTypes = {
23
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
24
- className: PropTypes.string,
25
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
26
- classes: PropTypes.object.isRequired
27
- };
28
-
29
- export default withStyles(theme => ({
30
- formControl: {
31
- marginLeft: 0,
32
- marginRight: theme.spacing.unit,
33
- paddingBottom: theme.spacing.unit,
34
- flex: '1 0 auto',
35
- minWidth: theme.spacing.unit * 4
36
- },
37
- label: {
38
- fontSize: 'inherit',
39
- whiteSpace: 'nowrap'
40
- }
41
- }))(RawInputContainer);
@@ -1,77 +0,0 @@
1
- import React from 'react';
2
- import { withStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
3
- import PropTypes from 'prop-types';
4
-
5
- class PreviewLayout extends React.Component {
6
- static propTypes = {
7
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
8
- classes: PropTypes.object
9
- };
10
-
11
- render() {
12
- const { children, classes } = this.props;
13
-
14
- return <div className={classes.container}>{children}</div>;
15
- }
16
- }
17
-
18
- const styles = () => ({
19
- container: {
20
- display: 'flex',
21
- flexDirection: 'column',
22
- position: 'relative'
23
- }
24
- });
25
-
26
- const theme = createMuiTheme({
27
- typography: {
28
- useNextVariants: true
29
- },
30
- palette: {
31
- action: {
32
- disabled: 'rgba(0, 0, 0, 0.54);'
33
- }
34
- },
35
- overrides: {
36
- MuiRadio: {
37
- root: {
38
- '&$checked': {
39
- color: '#3f51b5 !important'
40
- }
41
- }
42
- },
43
- MuiCheckbox: {
44
- root: {
45
- '&$checked': {
46
- color: '#3f51b5 !important'
47
- }
48
- }
49
- },
50
- MuiTabs: {
51
- root: {
52
- borderBottom: '1px solid #eee'
53
- }
54
- },
55
- MuiSwitch: {
56
- root: {
57
- '&$checked': {
58
- color: '#3f51b5 !important',
59
- '& + $bar': {
60
- backgroundColor: '#3f51b5 !important',
61
- opacity: 0.5
62
- }
63
- }
64
- }
65
- }
66
- }
67
- });
68
-
69
- const Styled = withStyles(styles)(PreviewLayout);
70
-
71
- const RootElem = props => (
72
- <MuiThemeProvider theme={theme}>
73
- <Styled {...props} />
74
- </MuiThemeProvider>
75
- );
76
-
77
- export default RootElem;
@@ -1,103 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { withStyles } from '@material-ui/core/styles';
3
- import PropTypes from 'prop-types';
4
- import * as color from './color';
5
-
6
- //Used these below to replace \\embed{newLine} with \\newline from prompt which will get parsed in MathJax
7
- const NEWLINE_BLOCK_REGEX = /\\embed\{newLine\}\[\]/g;
8
- const NEWLINE_LATEX = '\\newline ';
9
-
10
- export class PreviewPrompt extends Component {
11
- static propTypes = {
12
- classes: PropTypes.object,
13
- prompt: PropTypes.string,
14
- tagName: PropTypes.string,
15
- className: PropTypes.string,
16
- onClick: PropTypes.func,
17
- defaultClassName: PropTypes.string
18
- };
19
-
20
- static defaultProps = {
21
- onClick: () => {}
22
- };
23
-
24
- parsedText = text => {
25
- // fix imported audio content for Safari PD-1419
26
- const div = document.createElement('div');
27
- div.innerHTML = text;
28
-
29
- const audio = div.querySelector('audio');
30
- if (audio) {
31
- const source = document.createElement('source');
32
-
33
- source.setAttribute('type', 'audio/mp3');
34
- source.setAttribute('src', audio.getAttribute('src'));
35
-
36
- audio.removeAttribute('src');
37
- audio.appendChild(source);
38
- }
39
-
40
- return div.innerHTML;
41
- };
42
-
43
- // componentDidUpdate() {
44
- // // set image parent style so it can be horizontally aligned
45
- // const previewPrompt = document.querySelector('#preview-prompt');
46
- // const images = previewPrompt && previewPrompt.getElementsByTagName('img');
47
- //
48
- // if (images && images.length) {
49
- // for (let image of images) {
50
- // image.parentElement.style.display = 'flex';
51
- // }
52
- // }
53
- // }
54
-
55
- render() {
56
- const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;
57
- const CustomTag = tagName || 'div';
58
- const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName ||
59
- ''}`;
60
-
61
- return (
62
- <CustomTag
63
- id={'preview-prompt'}
64
- onClick={onClick}
65
- className={customClasses}
66
- dangerouslySetInnerHTML={{
67
- __html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
68
- }}
69
- />
70
- );
71
- }
72
- }
73
-
74
- const styles = theme => ({
75
- prompt: {
76
- verticalAlign: 'middle',
77
- color: color.text()
78
- },
79
- rationale: {
80
- paddingLeft: theme.spacing.unit * 16
81
- },
82
- label: {
83
- color: `${color.text()} !important`, //'var(--choice-input-color, black)',
84
- display: 'inline-block',
85
- verticalAlign: 'middle',
86
- cursor: 'pointer'
87
- },
88
- promptTable: {
89
- '&:not(.MathJax) > table': {
90
- borderCollapse: 'collapse'
91
- },
92
- '&:not(.MathJax) > table tr': {
93
- '&:nth-child(2n)': {
94
- backgroundColor: '#f6f8fa'
95
- }
96
- },
97
- '&:not(.MathJax) > table td, &:not(.MathJax) > table th': {
98
- padding: '.6em 1em',
99
- textAlign: 'center'
100
- }
101
- }
102
- });
103
- export default withStyles(styles)(PreviewPrompt);
@@ -1,19 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
-
4
- const Purpose = props => {
5
- return (
6
- <>
7
- {React.Children.map(props.children, child =>
8
- React.cloneElement(child, { 'data-pie-purpose': props.purpose })
9
- )}
10
- </>
11
- );
12
- };
13
-
14
- Purpose.propTypes = {
15
- children: PropTypes.node,
16
- purpose: PropTypes.string
17
- };
18
-
19
- export default Purpose;
@@ -1,19 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
-
4
- const Readable = props => {
5
- return (
6
- <>
7
- {React.Children.map(props.children, child =>
8
- React.cloneElement(child, { 'data-pie-readable': props.false === undefined })
9
- )}
10
- </>
11
- );
12
- };
13
-
14
- Readable.propTypes = {
15
- children: PropTypes.node,
16
- false: PropTypes.bool
17
- };
18
-
19
- export default Readable;
@@ -1,89 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import * as icons from '@pie-lib/icons';
4
- import Popover from '@material-ui/core/Popover';
5
- import { withStyles } from '@material-ui/core/styles';
6
- import Feedback from './feedback';
7
- import debug from 'debug';
8
-
9
- const log = debug('pie-libs:render-ui:response-indicators');
10
-
11
- const styles = () => ({
12
- responseIndicator: {
13
- cursor: 'pointer'
14
- },
15
- paper: {
16
- padding: '0',
17
- borderRadius: '4px'
18
- },
19
- popover: {
20
- cursor: 'pointer'
21
- },
22
- popperClose: {
23
- cursor: 'pointer'
24
- }
25
- });
26
-
27
- const BuildIndicator = (Icon, correctness) => {
28
- class RawIndicator extends React.Component {
29
- constructor(props) {
30
- super(props);
31
- this.state = {};
32
- }
33
-
34
- handlePopoverOpen = event => {
35
- log('[handlePopoverOpen]', event.target);
36
- this.setState({ anchorEl: event.target });
37
- };
38
-
39
- handlePopoverClose = () => {
40
- this.setState({ anchorEl: null });
41
- };
42
-
43
- render() {
44
- const { feedback, classes } = this.props;
45
- const { anchorEl } = this.state;
46
- return (
47
- <div className={feedback && classes.responseIndicator}>
48
- <span ref={r => (this.icon = r)} onClick={this.handlePopoverOpen}>
49
- <Icon />
50
- </span>
51
-
52
- {feedback && (
53
- <Popover
54
- className={classes.popover}
55
- classes={{
56
- paper: classes.paper
57
- }}
58
- open={!!anchorEl}
59
- anchorEl={anchorEl}
60
- anchorOrigin={{
61
- vertical: 'bottom',
62
- horizontal: 'left'
63
- }}
64
- transformOrigin={{
65
- vertical: 'top',
66
- horizontal: 'left'
67
- }}
68
- onClose={this.handlePopoverClose}
69
- >
70
- <Feedback feedback={feedback} correctness={correctness} />
71
- </Popover>
72
- )}
73
- </div>
74
- );
75
- }
76
- }
77
-
78
- RawIndicator.propTypes = {
79
- feedback: PropTypes.string,
80
- classes: PropTypes.object.isRequired
81
- };
82
-
83
- return withStyles(styles)(RawIndicator);
84
- };
85
-
86
- export const Correct = BuildIndicator(icons.Correct, 'correct');
87
- export const Incorrect = BuildIndicator(icons.Incorrect, 'incorrect');
88
- export const PartiallyCorrect = BuildIndicator(icons.PartiallyCorrect, 'partially-correct');
89
- export const NothingSubmitted = BuildIndicator(icons.NothingSubmitted, 'nothing-submitted');
@@ -1,118 +0,0 @@
1
- import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
- import Button from '@material-ui/core/Button';
4
- import { withStyles } from '@material-ui/core/styles';
5
- import Restore from '@material-ui/icons/Restore';
6
- import Undo from '@material-ui/icons/Undo';
7
-
8
- const styles = theme => ({
9
- wrapper: {
10
- display: 'flex',
11
- flexDirection: 'column'
12
- },
13
- resetUndoContainer: {
14
- display: 'flex',
15
- alignItems: 'center',
16
- justifyContent: 'center'
17
- },
18
- icon: {
19
- width: '24px',
20
- height: '24px',
21
- color: 'gray',
22
- marginRight: theme.spacing.unit
23
- },
24
- buttonContainer: {
25
- display: 'flex',
26
- alignItems: 'center',
27
- marginLeft: theme.spacing.unit * 3,
28
- marginRight: theme.spacing.unit * 3
29
- }
30
- });
31
-
32
- /**
33
- * HOC that adds undo and reset functionality for session values
34
- */
35
- const withUndoReset = WrappedComponent => {
36
- class WithUndoReset extends React.Component {
37
- static propTypes = {
38
- classes: PropTypes.object,
39
- session: PropTypes.object,
40
- onSessionChange: PropTypes.func
41
- };
42
-
43
- constructor(props) {
44
- super(props);
45
-
46
- this.state = {
47
- sessionInitialValues: JSON.parse(JSON.stringify(props.session)),
48
- session: props.session,
49
- changes: []
50
- };
51
- }
52
-
53
- onSessionChange = session => {
54
- this.setState(
55
- state => ({ session, changes: [...state.changes, session] }),
56
- () => this.props.onSessionChange(session)
57
- );
58
- };
59
-
60
- onUndo = () => {
61
- this.setState(
62
- state => {
63
- const newChanges = [...state.changes];
64
-
65
- newChanges.pop();
66
-
67
- return {
68
- changes: newChanges,
69
- session: newChanges.length
70
- ? newChanges[newChanges.length - 1]
71
- : state.sessionInitialValues
72
- };
73
- },
74
- () => this.props.onSessionChange(this.state.session)
75
- );
76
- };
77
-
78
- onReset = () => {
79
- this.setState(
80
- state => ({ session: state.sessionInitialValues, changes: [] }),
81
- () => this.props.onSessionChange(this.state.sessionInitialValues)
82
- );
83
- };
84
-
85
- render() {
86
- const { classes, ...rest } = this.props;
87
- const { changes, session } = this.state;
88
-
89
- return (
90
- <div className={classes.wrapper}>
91
- <div className={classes.resetUndoContainer}>
92
- <Button
93
- className={classes.buttonContainer}
94
- color="primary"
95
- disabled={changes.length === 0}
96
- onClick={this.onUndo}
97
- >
98
- <Undo className={classes.icon} /> Undo
99
- </Button>
100
- <Button
101
- className={classes.buttonContainer}
102
- color="primary"
103
- disabled={changes.length === 0}
104
- onClick={this.onReset}
105
- >
106
- <Restore className={classes.icon} /> Start Over
107
- </Button>
108
- </div>
109
- <WrappedComponent {...rest} session={session} onSessionChange={this.onSessionChange} />
110
- </div>
111
- );
112
- }
113
- }
114
-
115
- return withStyles(styles)(WithUndoReset);
116
- };
117
-
118
- export default withUndoReset;
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@pie-element/multi-trait-rubric",
3
- "repository": "pie-framework/pie-elements",
4
- "version": "2.0.10",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "dependencies": {
9
- "@material-ui/core": "^3.9.2",
10
- "@pie-framework/pie-player-events": "^0.1.0",
11
- "@pie-lib/render-ui": "^4.13.5",
12
- "clsx": "^1.1.1",
13
- "enzyme-to-json": "^3.3.5",
14
- "prop-types": "^15.6.1",
15
- "react": "^16.8.1",
16
- "react-dom": "^16.8.1"
17
- },
18
- "gitHead": "dec027da9b944f8ee4286ab27e27fb888f657155",
19
- "scripts": {
20
- "postpublish": "../../scripts/postpublish"
21
- },
22
- "main": "lib/index.js",
23
- "module": "src/index.js"
24
- }