@pie-element/ebsr 7.0.22 → 7.0.24-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -16
- package/configure/CHANGELOG.md +0 -16
- package/configure/lib/main.js +6 -4
- package/configure/lib/main.js.map +1 -1
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +1793 -0
- package/{LICENSE.md → configure/node_modules/@pie-element/multiple-choice/LICENSE.md} +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +1334 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +104 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +198 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +599 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +768 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +305 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +36 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +353 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +277 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +52 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +338 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +274 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +298 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +157 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +151 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +97 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +254 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +843 -0
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/controller.js +17304 -17374
- package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +77 -0
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/element.js +42 -171
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/index.html +1 -1
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/manifest.json +4 -4
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print-demo.js +46 -46
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.html +1 -1
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.js +70 -259
- package/configure/node_modules/@pie-element/multiple-choice/package.json +34 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +672 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +427 -0
- package/configure/node_modules/@pie-lib/math-rendering/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +30 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +316 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +123 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +103 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +275 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/package.json +19 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/demo.html +872 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/demo.js +108 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/main.html +156 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/main.js +16 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/webpack.config.js +29 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/index.js +4 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +215 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +234 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +937 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +602 -0
- package/configure/node_modules/@pie-lib/render-ui/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/render-ui/README.md +33 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +146 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js +134 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +160 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +24 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +102 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js +104 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +133 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +162 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +160 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +206 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/package.json +30 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +68 -0
- package/configure/node_modules/@pie-lib/render-ui/src/color.js +48 -0
- package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +100 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +14 -0
- package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +40 -0
- package/configure/node_modules/@pie-lib/render-ui/src/index.js +27 -0
- package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +77 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +90 -0
- package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
- package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +118 -0
- package/configure/package.json +3 -3
- package/configure/src/__tests__/index.test.js +4 -2
- package/configure/src/main.jsx +8 -3
- package/controller/lib/index.js +79 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/src/index.js +55 -0
- package/package.json +3 -3
- package/module/configure.js +0 -472
- package/module/demo.js +0 -77
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { renderMath } from '@pie-lib/math-rendering';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
export default class HtmlAndMath extends React.Component {
|
|
6
|
+
static propTypes = {
|
|
7
|
+
tag: PropTypes.string,
|
|
8
|
+
className: PropTypes.string,
|
|
9
|
+
html: PropTypes.string
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static defaultProps = {
|
|
13
|
+
tag: 'div',
|
|
14
|
+
html: ''
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
if (this.node) {
|
|
19
|
+
renderMath(this.node);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
componentDidUpdate() {
|
|
24
|
+
if (this.node) {
|
|
25
|
+
renderMath(this.node);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
const { tag, className, html } = this.props;
|
|
31
|
+
const Tag = tag || 'div';
|
|
32
|
+
return (
|
|
33
|
+
<Tag
|
|
34
|
+
ref={r => (this.node = r)}
|
|
35
|
+
className={className}
|
|
36
|
+
dangerouslySetInnerHTML={{ __html: html }}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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);
|
|
@@ -0,0 +1,77 @@
|
|
|
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;
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
render() {
|
|
44
|
+
const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;
|
|
45
|
+
const CustomTag = tagName || 'div';
|
|
46
|
+
const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName ||
|
|
47
|
+
''}`;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<CustomTag
|
|
51
|
+
onClick={onClick}
|
|
52
|
+
className={customClasses}
|
|
53
|
+
dangerouslySetInnerHTML={{
|
|
54
|
+
__html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const styles = theme => ({
|
|
62
|
+
prompt: {
|
|
63
|
+
verticalAlign: 'middle',
|
|
64
|
+
color: color.text()
|
|
65
|
+
},
|
|
66
|
+
rationale: {
|
|
67
|
+
paddingLeft: theme.spacing.unit * 16
|
|
68
|
+
},
|
|
69
|
+
label: {
|
|
70
|
+
color: `${color.text()} !important`, //'var(--choice-input-color, black)',
|
|
71
|
+
display: 'inline-block',
|
|
72
|
+
verticalAlign: 'middle',
|
|
73
|
+
cursor: 'pointer'
|
|
74
|
+
},
|
|
75
|
+
promptTable: {
|
|
76
|
+
'&:not(.MathJax) > table': {
|
|
77
|
+
borderCollapse: 'collapse'
|
|
78
|
+
},
|
|
79
|
+
'&:not(.MathJax) > table tr': {
|
|
80
|
+
'&:nth-child(2n)': {
|
|
81
|
+
backgroundColor: '#f6f8fa'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'&:not(.MathJax) > table td, &:not(.MathJax) > table th': {
|
|
85
|
+
padding: '.6em 1em',
|
|
86
|
+
textAlign: 'center'
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
export default withStyles(styles)(PreviewPrompt);
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,89 @@
|
|
|
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');
|
|
@@ -0,0 +1,118 @@
|
|
|
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;
|
package/configure/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.20",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
|
-
"@pie-element/multiple-choice": "^6.3.
|
|
11
|
+
"@pie-element/multiple-choice": "^6.3.2",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
13
|
-
"@pie-lib/config-ui": "^10.
|
|
13
|
+
"@pie-lib/config-ui": "^10.13.2",
|
|
14
14
|
"lodash": "^4.17.15",
|
|
15
15
|
"prop-types": "^15.6.2",
|
|
16
16
|
"react": "^16.8.1",
|
|
@@ -79,7 +79,8 @@ const model = createDefaultModel(defaults.model, {
|
|
|
79
79
|
}
|
|
80
80
|
],
|
|
81
81
|
choicePrefix: 'numbers',
|
|
82
|
-
prompt: `prompt ${PART_A}
|
|
82
|
+
prompt: `prompt ${PART_A}`,
|
|
83
|
+
errors: {}
|
|
83
84
|
},
|
|
84
85
|
partB: {
|
|
85
86
|
choiceMode: 'radio',
|
|
@@ -102,7 +103,8 @@ const model = createDefaultModel(defaults.model, {
|
|
|
102
103
|
}
|
|
103
104
|
],
|
|
104
105
|
choicePrefix: 'numbers',
|
|
105
|
-
prompt: `prompt ${PART_B}
|
|
106
|
+
prompt: `prompt ${PART_B}`,
|
|
107
|
+
errors: {}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
108
110
|
|
package/configure/src/main.jsx
CHANGED
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { settings, layout } from '@pie-lib/config-ui';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
6
5
|
|
|
7
6
|
const { Panel, toggle, radio, dropdown } = settings;
|
|
8
7
|
|
|
@@ -208,7 +207,10 @@ export class Main extends React.Component {
|
|
|
208
207
|
if (ref) {
|
|
209
208
|
// do not use destructuring to get model from props
|
|
210
209
|
this.partA = ref;
|
|
211
|
-
this.partA._model =
|
|
210
|
+
this.partA._model = {
|
|
211
|
+
...this.props.model.partA,
|
|
212
|
+
errors: this.props.model.errors && this.props.model.errors.partA || {}
|
|
213
|
+
};
|
|
212
214
|
this.partA.configuration = {
|
|
213
215
|
...partA,
|
|
214
216
|
...generalConfiguration
|
|
@@ -227,7 +229,10 @@ export class Main extends React.Component {
|
|
|
227
229
|
if (ref) {
|
|
228
230
|
// do not use destructuring to get model from props
|
|
229
231
|
this.partB = ref;
|
|
230
|
-
this.partB._model =
|
|
232
|
+
this.partB._model ={
|
|
233
|
+
...this.props.model.partB,
|
|
234
|
+
errors: this.props.model.errors && this.props.model.errors.partB || {}
|
|
235
|
+
};
|
|
231
236
|
this.partB.configuration = {
|
|
232
237
|
...partB,
|
|
233
238
|
...generalConfiguration
|