@pie-element/complex-rubric 3.3.6-next.0 → 3.3.6-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 (51) hide show
  1. package/configure/package.json +0 -5
  2. package/controller/package.json +1 -1
  3. package/module/configure.js +66915 -1476
  4. package/module/element.js +67652 -2213
  5. package/module/manifest.json +2 -2
  6. package/module/print.js +67652 -2213
  7. package/package.json +4 -4
  8. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +0 -937
  9. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +0 -848
  10. package/configure/node_modules/@pie-lib/render-ui/LICENSE.md +0 -5
  11. package/configure/node_modules/@pie-lib/render-ui/README.md +0 -33
  12. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +0 -134
  13. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +0 -1
  14. package/configure/node_modules/@pie-lib/render-ui/lib/color.js +0 -157
  15. package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +0 -1
  16. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +0 -151
  17. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +0 -1
  18. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +0 -24
  19. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +0 -1
  20. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +0 -90
  21. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +0 -1
  22. package/configure/node_modules/@pie-lib/render-ui/lib/index.js +0 -104
  23. package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +0 -1
  24. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +0 -60
  25. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +0 -1
  26. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +0 -133
  27. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +0 -1
  28. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +0 -206
  29. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +0 -1
  30. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +0 -28
  31. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +0 -1
  32. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +0 -28
  33. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +0 -1
  34. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +0 -151
  35. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +0 -1
  36. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +0 -181
  37. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +0 -1
  38. package/configure/node_modules/@pie-lib/render-ui/package.json +0 -30
  39. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +0 -63
  40. package/configure/node_modules/@pie-lib/render-ui/src/color.js +0 -55
  41. package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +0 -100
  42. package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +0 -14
  43. package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +0 -34
  44. package/configure/node_modules/@pie-lib/render-ui/src/index.js +0 -27
  45. package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +0 -41
  46. package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +0 -84
  47. package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +0 -130
  48. package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +0 -17
  49. package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +0 -19
  50. package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +0 -89
  51. package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +0 -116
@@ -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: 0,
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,84 +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
- ariaLabel: PropTypes.string,
8
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
9
- classes: PropTypes.object,
10
- role: PropTypes.string,
11
- };
12
-
13
- render() {
14
- const { children, classes, ariaLabel, role } = this.props;
15
- const accessibility = ariaLabel ? { 'aria-label': ariaLabel, role } : {};
16
-
17
- return (
18
- <div className={classes.container} {...accessibility}>
19
- {children}
20
- </div>
21
- );
22
- }
23
- }
24
-
25
- const styles = () => ({
26
- container: {
27
- display: 'flex',
28
- flexDirection: 'column',
29
- position: 'relative',
30
- },
31
- });
32
-
33
- const theme = createMuiTheme({
34
- typography: {
35
- useNextVariants: true,
36
- },
37
- palette: {
38
- action: {
39
- disabled: 'rgba(0, 0, 0, 0.54);',
40
- },
41
- },
42
- overrides: {
43
- MuiRadio: {
44
- root: {
45
- '&$checked': {
46
- color: '#3f51b5 !important',
47
- },
48
- },
49
- },
50
- MuiCheckbox: {
51
- root: {
52
- '&$checked': {
53
- color: '#3f51b5 !important',
54
- },
55
- },
56
- },
57
- MuiTabs: {
58
- root: {
59
- borderBottom: '1px solid #eee',
60
- },
61
- },
62
- MuiSwitch: {
63
- root: {
64
- '&$checked': {
65
- color: '#3f51b5 !important',
66
- '& + $bar': {
67
- backgroundColor: '#3f51b5 !important',
68
- opacity: 0.5,
69
- },
70
- },
71
- },
72
- },
73
- },
74
- });
75
-
76
- const Styled = withStyles(styles)(PreviewLayout);
77
-
78
- const RootElem = (props) => (
79
- <MuiThemeProvider theme={theme}>
80
- <Styled {...props} />
81
- </MuiThemeProvider>
82
- );
83
-
84
- export default RootElem;
@@ -1,130 +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
- // check if alignment property was set
51
- if (image.attributes && image.attributes.alignment && image.attributes.alignment.value) {
52
- const parentNode = image.parentElement;
53
-
54
- // check if div is not already added to dom and replace current image with wrapped image
55
- if (
56
- !(parentNode.tagName === 'DIV' && parentNode.style.display === 'flex' && parentNode.style.width === '100%')
57
- ) {
58
- const div = document.createElement('div');
59
- div.style.display = 'flex';
60
- div.style.width = '100%';
61
-
62
- const copyImage = image.cloneNode(true);
63
- div.appendChild(copyImage);
64
- parentNode.replaceChild(div, image);
65
- }
66
- }
67
- }
68
- }
69
- }
70
-
71
- render() {
72
- const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;
73
- const CustomTag = tagName || 'div';
74
- // legend tag was added once with accessibility tasks, wee need extra style to make it work with images alignment
75
- const legendClass = tagName === 'legend' ? 'legend' : '';
76
- const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName || ''} ${classes[
77
- legendClass
78
- ] || ''}`;
79
-
80
- return (
81
- <CustomTag
82
- id={'preview-prompt'}
83
- onClick={onClick}
84
- className={customClasses}
85
- dangerouslySetInnerHTML={{
86
- __html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX),
87
- }}
88
- />
89
- );
90
- }
91
- }
92
-
93
- const styles = (theme) => ({
94
- prompt: {
95
- verticalAlign: 'middle',
96
- color: color.text(),
97
- },
98
- legend: {
99
- width: '100%',
100
- fontSize: 'inherit !important',
101
- },
102
- rationale: {
103
- paddingLeft: theme.spacing.unit * 4,
104
- paddingBottom: theme.spacing.unit,
105
- },
106
- label: {
107
- color: `${color.text()} !important`, //'var(--choice-input-color, black)',
108
- display: 'inline-block',
109
- verticalAlign: 'middle',
110
- cursor: 'pointer',
111
- '& > p': {
112
- margin: '0 0 0 0 !important',
113
- },
114
- },
115
- promptTable: {
116
- '&:not(.MathJax) > table': {
117
- borderCollapse: 'collapse',
118
- },
119
- '&:not(.MathJax) > table tr': {
120
- '&:nth-child(2n)': {
121
- backgroundColor: '#f6f8fa',
122
- },
123
- },
124
- '&:not(.MathJax) > table td, &:not(.MathJax) > table th': {
125
- padding: '.6em 1em',
126
- textAlign: 'center',
127
- },
128
- },
129
- });
130
- export default withStyles(styles)(PreviewPrompt);
@@ -1,17 +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) => React.cloneElement(child, { 'data-pie-purpose': props.purpose }))}
8
- </>
9
- );
10
- };
11
-
12
- Purpose.propTypes = {
13
- children: PropTypes.node,
14
- purpose: PropTypes.string,
15
- };
16
-
17
- 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,116 +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 ? newChanges[newChanges.length - 1] : state.sessionInitialValues,
70
- };
71
- },
72
- () => this.props.onSessionChange(this.state.session),
73
- );
74
- };
75
-
76
- onReset = () => {
77
- this.setState(
78
- (state) => ({ session: state.sessionInitialValues, changes: [] }),
79
- () => this.props.onSessionChange(this.state.sessionInitialValues),
80
- );
81
- };
82
-
83
- render() {
84
- const { classes, ...rest } = this.props;
85
- const { changes, session } = this.state;
86
-
87
- return (
88
- <div className={classes.wrapper}>
89
- <div className={classes.resetUndoContainer}>
90
- <Button
91
- className={classes.buttonContainer}
92
- color="primary"
93
- disabled={changes.length === 0}
94
- onClick={this.onUndo}
95
- >
96
- <Undo className={classes.icon} /> Undo
97
- </Button>
98
- <Button
99
- className={classes.buttonContainer}
100
- color="primary"
101
- disabled={changes.length === 0}
102
- onClick={this.onReset}
103
- >
104
- <Restore className={classes.icon} /> Start Over
105
- </Button>
106
- </div>
107
- <WrappedComponent {...rest} session={session} onSessionChange={this.onSessionChange} />
108
- </div>
109
- );
110
- }
111
- }
112
-
113
- return withStyles(styles)(WithUndoReset);
114
- };
115
-
116
- export default withUndoReset;