@pie-element/rubric 6.1.0 → 6.2.0-mui-update.1
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 +11 -0
- package/configure/CHANGELOG.md +11 -0
- package/configure/lib/__tests__/index.test.js +174 -0
- package/configure/lib/defaults.js +3 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +91 -153
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +91 -150
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +10 -7
- package/configure/src/index.js +12 -2
- package/configure/src/main.jsx +11 -13
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/__tests__/index.test.js +39 -0
- package/controller/lib/defaults.js +3 -4
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +16 -29
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/demo/pie.manifest.json +11 -0
- package/lib/__tests__/rubric-view.test.js +49 -0
- package/lib/index.js +39 -81
- package/lib/index.js.map +1 -1
- package/lib/main.js +185 -245
- package/lib/main.js.map +1 -1
- package/lib/print.js +42 -85
- package/lib/print.js.map +1 -1
- package/package.json +8 -5
- package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +2350 -1524
- package/src/index.js +14 -3
- package/src/main.jsx +100 -93
- package/src/print.js +13 -2
- package/LICENSE.md +0 -5
- package/configure/lib/pie-toolbox-rubric/authoring.js +0 -573
- package/configure/lib/pie-toolbox-rubric/authoring.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/index.js +0 -24
- package/configure/lib/pie-toolbox-rubric/index.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/point-menu.js +0 -172
- package/configure/lib/pie-toolbox-rubric/point-menu.js.map +0 -1
- package/configure/src/pie-toolbox-rubric/authoring.jsx +0 -449
- package/configure/src/pie-toolbox-rubric/index.js +0 -9
- package/configure/src/pie-toolbox-rubric/point-menu.jsx +0 -94
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Rubric from './main';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import debug from 'debug';
|
|
5
5
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ export default class RubricRender extends HTMLElement {
|
|
|
9
9
|
super();
|
|
10
10
|
debug.log('constructor called');
|
|
11
11
|
this.onModelChanged = this.onModelChanged.bind(this);
|
|
12
|
+
this._root = null;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
set model(s) {
|
|
@@ -27,11 +28,21 @@ export default class RubricRender extends HTMLElement {
|
|
|
27
28
|
|
|
28
29
|
_render() {
|
|
29
30
|
if (this._model) {
|
|
30
|
-
const el =
|
|
31
|
+
const el = React.createElement(Rubric, { value: this._model });
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
if (!this._root) {
|
|
34
|
+
this._root = createRoot(this);
|
|
35
|
+
}
|
|
36
|
+
this._root.render(el);
|
|
37
|
+
queueMicrotask(() => {
|
|
33
38
|
renderMath(this);
|
|
34
39
|
});
|
|
35
40
|
}
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
if (this._root) {
|
|
45
|
+
this._root.unmount();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
}
|
package/src/main.jsx
CHANGED
|
@@ -1,11 +1,87 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import ListItem from '@material
|
|
4
|
-
import List from '@material
|
|
5
|
-
import Collapse from '@material
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import ListItem from '@mui/material/ListItem';
|
|
4
|
+
import List from '@mui/material/List';
|
|
5
|
+
import Collapse from '@mui/material/Collapse';
|
|
6
6
|
import { color, UiLayout } from '@pie-lib/render-ui';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
|
+
const StyledUiLayout = styled(UiLayout)(({ theme }) => ({
|
|
10
|
+
color: color.text(),
|
|
11
|
+
backgroundColor: color.background(),
|
|
12
|
+
// apply styles to tables to match the rest of the UI
|
|
13
|
+
'&:not(.MathJax) table': {
|
|
14
|
+
borderCollapse: 'collapse',
|
|
15
|
+
},
|
|
16
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
17
|
+
padding: '8px 12px',
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
},
|
|
20
|
+
// reset paragraph margins and line-height inside lists to override client styles
|
|
21
|
+
'& ul p, & ol p': {
|
|
22
|
+
marginBottom: 0,
|
|
23
|
+
marginTop: 0,
|
|
24
|
+
lineHeight: 'normal',
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const StyledListItem = styled(ListItem)({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
alignItems: 'flex-start',
|
|
32
|
+
padding: '12px 0px',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const Text = styled('div')({
|
|
36
|
+
color: color.text(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const TitleText = styled('h3')({
|
|
40
|
+
color: color.text(),
|
|
41
|
+
fontSize: '16px',
|
|
42
|
+
fontWeight: '700',
|
|
43
|
+
margin: 0,
|
|
44
|
+
paddingBottom: '6px',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const SampleTitleText = styled('h4')({
|
|
48
|
+
color: color.text(),
|
|
49
|
+
fontSize: '16px',
|
|
50
|
+
fontWeight: 'normal',
|
|
51
|
+
margin: 0,
|
|
52
|
+
paddingBottom: '6px',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const RubricToggle = styled('h2')(({ theme }) => ({
|
|
56
|
+
display: 'flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
userSelect: 'none',
|
|
60
|
+
fontSize: theme.typography.fontSize,
|
|
61
|
+
fontWeight: '500',
|
|
62
|
+
color: color.tertiary(),
|
|
63
|
+
margin: 0,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const ChevronStyle = styled('span')({
|
|
67
|
+
display: 'inline-flex',
|
|
68
|
+
transition: 'transform 0.2s',
|
|
69
|
+
marginLeft: 2,
|
|
70
|
+
alignSelf: 'center',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const HiddenScreenReader = styled('h2')({
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
width: '1px',
|
|
76
|
+
height: '1px',
|
|
77
|
+
padding: 0,
|
|
78
|
+
margin: '-1px',
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
clip: 'rect(0,0,0,0)',
|
|
81
|
+
border: 0,
|
|
82
|
+
whiteSpace: 'nowrap',
|
|
83
|
+
});
|
|
84
|
+
|
|
9
85
|
export const RubricType = PropTypes.shape({
|
|
10
86
|
excludeZero: PropTypes.bool,
|
|
11
87
|
points: PropTypes.arrayOf(PropTypes.string),
|
|
@@ -26,7 +102,6 @@ class Rubric extends React.Component {
|
|
|
26
102
|
}
|
|
27
103
|
|
|
28
104
|
static propTypes = {
|
|
29
|
-
classes: PropTypes.object.isRequired,
|
|
30
105
|
model: PropTypes.object.isRequired,
|
|
31
106
|
animationsDisabled: PropTypes.bool,
|
|
32
107
|
value: RubricType,
|
|
@@ -46,7 +121,7 @@ class Rubric extends React.Component {
|
|
|
46
121
|
};
|
|
47
122
|
|
|
48
123
|
render() {
|
|
49
|
-
const { model, value
|
|
124
|
+
const { model, value } = this.props;
|
|
50
125
|
let { animationsDisabled } = this.props;
|
|
51
126
|
animationsDisabled = animationsDisabled || value.animationsDisabled;
|
|
52
127
|
|
|
@@ -65,20 +140,20 @@ class Rubric extends React.Component {
|
|
|
65
140
|
|
|
66
141
|
return (
|
|
67
142
|
<React.Fragment key={index}>
|
|
68
|
-
<
|
|
69
|
-
<
|
|
143
|
+
<StyledListItem key={`P${index}`}>
|
|
144
|
+
<TitleText>
|
|
70
145
|
{pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`}
|
|
71
|
-
</
|
|
72
|
-
<
|
|
73
|
-
</
|
|
146
|
+
</TitleText>
|
|
147
|
+
<Text dangerouslySetInnerHTML={{ __html: desc }} />
|
|
148
|
+
</StyledListItem>
|
|
74
149
|
|
|
75
150
|
{sampleAnswers && sampleAnswers[index] && (
|
|
76
|
-
<
|
|
77
|
-
<
|
|
151
|
+
<StyledListItem key={`S${index}`}>
|
|
152
|
+
<SampleTitleText>
|
|
78
153
|
Sample Answer
|
|
79
|
-
</
|
|
80
|
-
<
|
|
81
|
-
</
|
|
154
|
+
</SampleTitleText>
|
|
155
|
+
<Text dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
156
|
+
</StyledListItem>
|
|
82
157
|
)}
|
|
83
158
|
</React.Fragment>
|
|
84
159
|
);
|
|
@@ -87,14 +162,13 @@ class Rubric extends React.Component {
|
|
|
87
162
|
);
|
|
88
163
|
|
|
89
164
|
return (
|
|
90
|
-
<
|
|
165
|
+
<StyledUiLayout extraCSSRules={extraCSSRules}>
|
|
91
166
|
{/* screen reader only heading for navigation as per PD-5057 */}
|
|
92
|
-
<
|
|
167
|
+
<HiddenScreenReader>Rubric</HiddenScreenReader>
|
|
93
168
|
{!animationsDisabled ? (
|
|
94
169
|
<React.Fragment>
|
|
95
|
-
<
|
|
170
|
+
<RubricToggle
|
|
96
171
|
id={'rubric-toggle'}
|
|
97
|
-
className={classes.rubricToggle}
|
|
98
172
|
tabIndex={0}
|
|
99
173
|
role="button"
|
|
100
174
|
aria-expanded={this.state.rubricOpen}
|
|
@@ -104,7 +178,7 @@ class Rubric extends React.Component {
|
|
|
104
178
|
}}
|
|
105
179
|
>
|
|
106
180
|
{this.state.linkPrefix} Rubric
|
|
107
|
-
<
|
|
181
|
+
<ChevronStyle aria-hidden="true">
|
|
108
182
|
{this.state.rubricOpen ? (
|
|
109
183
|
<svg
|
|
110
184
|
width="20"
|
|
@@ -132,16 +206,16 @@ class Rubric extends React.Component {
|
|
|
132
206
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
133
207
|
</svg>
|
|
134
208
|
)}
|
|
135
|
-
</
|
|
136
|
-
</
|
|
137
|
-
<Collapse in={this.state.rubricOpen} timeout=
|
|
209
|
+
</ChevronStyle>
|
|
210
|
+
</RubricToggle>
|
|
211
|
+
<Collapse in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>
|
|
138
212
|
{rubricList}
|
|
139
213
|
</Collapse>
|
|
140
214
|
</React.Fragment>
|
|
141
215
|
) : (
|
|
142
216
|
rubricList
|
|
143
217
|
)}
|
|
144
|
-
</
|
|
218
|
+
</StyledUiLayout>
|
|
145
219
|
);
|
|
146
220
|
} else {
|
|
147
221
|
return null;
|
|
@@ -149,71 +223,4 @@ class Rubric extends React.Component {
|
|
|
149
223
|
}
|
|
150
224
|
}
|
|
151
225
|
|
|
152
|
-
|
|
153
|
-
root: {
|
|
154
|
-
color: color.text(),
|
|
155
|
-
backgroundColor: color.background(),
|
|
156
|
-
// apply styles to tables to match the rest of the UI
|
|
157
|
-
'&:not(.MathJax) table': {
|
|
158
|
-
borderCollapse: 'collapse',
|
|
159
|
-
},
|
|
160
|
-
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
161
|
-
padding: '8px 12px',
|
|
162
|
-
textAlign: 'left',
|
|
163
|
-
},
|
|
164
|
-
// reset paragraph margins and line-height inside lists to override client styles
|
|
165
|
-
'& ul p, & ol p': {
|
|
166
|
-
marginBottom: 0,
|
|
167
|
-
marginTop: 0,
|
|
168
|
-
lineHeight: 'normal',
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
listColumn: {
|
|
172
|
-
display: 'flex',
|
|
173
|
-
flexDirection: 'column',
|
|
174
|
-
alignItems: 'flex-start',
|
|
175
|
-
padding: '12px 0px',
|
|
176
|
-
},
|
|
177
|
-
listColumnItem: {
|
|
178
|
-
padding: 0,
|
|
179
|
-
},
|
|
180
|
-
text: {
|
|
181
|
-
color: color.text(),
|
|
182
|
-
},
|
|
183
|
-
titleText: {
|
|
184
|
-
color: color.text(),
|
|
185
|
-
fontSize: '16px',
|
|
186
|
-
fontWeight: '700',
|
|
187
|
-
margin: 0,
|
|
188
|
-
paddingBottom: '6px',
|
|
189
|
-
},
|
|
190
|
-
rubricToggle: {
|
|
191
|
-
display: 'flex',
|
|
192
|
-
alignItems: 'center',
|
|
193
|
-
cursor: 'pointer',
|
|
194
|
-
userSelect: 'none',
|
|
195
|
-
fontSize: theme.typography.fontSize,
|
|
196
|
-
fontWeight: '500',
|
|
197
|
-
color: color.tertiary(),
|
|
198
|
-
margin: 0,
|
|
199
|
-
},
|
|
200
|
-
chevronStyle: {
|
|
201
|
-
display: 'inline-flex',
|
|
202
|
-
transition: 'transform 0.2s',
|
|
203
|
-
marginLeft: 2,
|
|
204
|
-
alignSelf: 'center',
|
|
205
|
-
},
|
|
206
|
-
hiddenScreenReader: {
|
|
207
|
-
position: 'absolute',
|
|
208
|
-
width: '1px',
|
|
209
|
-
height: '1px',
|
|
210
|
-
padding: 0,
|
|
211
|
-
margin: '-1px',
|
|
212
|
-
overflow: 'hidden',
|
|
213
|
-
clip: 'rect(0,0,0,0)',
|
|
214
|
-
border: 0,
|
|
215
|
-
whiteSpace: 'nowrap',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
export default withStyles(styles)(Rubric);
|
|
226
|
+
export default Rubric;
|
package/src/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import Main from './main';
|
|
5
5
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
@@ -27,6 +27,7 @@ export default class RubricPrint extends HTMLElement {
|
|
|
27
27
|
this._options = null;
|
|
28
28
|
this._model = null;
|
|
29
29
|
this._session = [];
|
|
30
|
+
this._root = null;
|
|
30
31
|
this._rerender = debounce(
|
|
31
32
|
() => {
|
|
32
33
|
if (this._model && this._session) {
|
|
@@ -38,7 +39,11 @@ export default class RubricPrint extends HTMLElement {
|
|
|
38
39
|
...printModel,
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
if (!this._root) {
|
|
43
|
+
this._root = createRoot(this);
|
|
44
|
+
}
|
|
45
|
+
this._root.render(element);
|
|
46
|
+
queueMicrotask(() => {
|
|
42
47
|
log('render complete - render math');
|
|
43
48
|
renderMath(this);
|
|
44
49
|
});
|
|
@@ -60,4 +65,10 @@ export default class RubricPrint extends HTMLElement {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
connectedCallback() {}
|
|
68
|
+
|
|
69
|
+
disconnectedCallback() {
|
|
70
|
+
if (this._root) {
|
|
71
|
+
this._root.unmount();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
63
74
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
Copyright 2019 CoreSpring Inc
|
|
2
|
-
|
|
3
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
4
|
-
|
|
5
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|