@pie-element/rubric 4.7.3-next.9 → 4.8.1-next.0
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 +16 -0
- package/configure/CHANGELOG.md +11 -0
- package/configure/package.json +2 -2
- package/controller/CHANGELOG.md +11 -0
- package/controller/package.json +2 -2
- package/lib/main.js +103 -40
- package/lib/main.js.map +1 -1
- package/module/configure.js +1 -1
- package/module/element.js +690 -1084
- package/module/index.html +1 -1
- package/module/manifest.json +2 -2
- package/module/print.html +1 -1
- package/module/print.js +690 -1084
- package/package.json +3 -3
- package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +424 -21644
- package/src/__tests__/rubric-view.test.jsx +4 -5
- package/src/main.jsx +80 -36
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mount } from 'enzyme';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Rubric from '../main';
|
|
4
|
-
import Link from '@material-ui/core/Link';
|
|
5
4
|
|
|
6
5
|
describe('rubric viewer', () => {
|
|
7
6
|
const wrapper = (extras) => {
|
|
@@ -27,7 +26,7 @@ describe('rubric viewer', () => {
|
|
|
27
26
|
describe('expanded snapshot', () => {
|
|
28
27
|
it('renders', () => {
|
|
29
28
|
const w = wrapper();
|
|
30
|
-
w.find(
|
|
29
|
+
w.find('#rubric-toggle').simulate('click');
|
|
31
30
|
expect(w).toMatchSnapshot();
|
|
32
31
|
});
|
|
33
32
|
});
|
|
@@ -39,11 +38,11 @@ describe('rubric viewer', () => {
|
|
|
39
38
|
points: ['a teeny bit right', 'mostly right', 'bingo'],
|
|
40
39
|
sampleAnswers: ['just right', 'not left', null]
|
|
41
40
|
});
|
|
42
|
-
w.find(
|
|
41
|
+
w.find('#rubric-toggle').simulate('click');
|
|
43
42
|
expect(w.find('li').length).toEqual(5);
|
|
44
43
|
|
|
45
44
|
w = wrapper({excludeZero: false});
|
|
46
|
-
w.find(
|
|
45
|
+
w.find('#rubric-toggle').simulate('click');
|
|
47
46
|
expect(w.find('li').length).toEqual(6);
|
|
48
47
|
});
|
|
49
48
|
});
|
package/src/main.jsx
CHANGED
|
@@ -2,8 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { withStyles } from '@material-ui/core/styles';
|
|
3
3
|
import ListItem from '@material-ui/core/ListItem';
|
|
4
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
5
|
import Collapse from '@material-ui/core/Collapse';
|
|
8
6
|
import { color, UiLayout } from '@pie-lib/pie-toolbox/render-ui';
|
|
9
7
|
import PropTypes from 'prop-types';
|
|
@@ -63,37 +61,22 @@ class Rubric extends React.Component {
|
|
|
63
61
|
.reverse()
|
|
64
62
|
.map((desc, index) => {
|
|
65
63
|
index = points.length - index - 1;
|
|
66
|
-
const pointsLabel = value.excludeZero ? index + 1: index;
|
|
64
|
+
const pointsLabel = value.excludeZero ? index + 1 : index;
|
|
67
65
|
|
|
68
66
|
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/>
|
|
67
|
+
<React.Fragment key={index}>
|
|
68
|
+
<ListItem key={`P${index}`} className={classes.listColumn}>
|
|
69
|
+
<h3 className={classes.titleText}>{pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`}</h3>
|
|
70
|
+
<div className={classes.text} dangerouslySetInnerHTML={{ __html: desc }} />
|
|
71
|
+
</ListItem>
|
|
72
|
+
|
|
73
|
+
{sampleAnswers && sampleAnswers[index] && (
|
|
74
|
+
<ListItem key={`S${index}`} className={classes.listColumn}>
|
|
75
|
+
<h4 className={classes.titleText} style={{ fontWeight: 'normal' }}>Sample Answer</h4>
|
|
76
|
+
<div className={classes.text} dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
79
77
|
</ListItem>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<ListItem key={`S${index}`}>
|
|
83
|
-
<ListItemText
|
|
84
|
-
className={classes.rubricCol}
|
|
85
|
-
style={{ marginLeft: '20px' }}
|
|
86
|
-
primary={<div className={classes.text}>Sample Answer</div>}
|
|
87
|
-
/>
|
|
88
|
-
|
|
89
|
-
<ListItemText
|
|
90
|
-
primary={
|
|
91
|
-
<div className={classes.text} dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
92
|
-
}
|
|
93
|
-
/>
|
|
94
|
-
</ListItem>
|
|
95
|
-
)}
|
|
96
|
-
</React.Fragment>
|
|
78
|
+
)}
|
|
79
|
+
</React.Fragment>
|
|
97
80
|
);
|
|
98
81
|
})}
|
|
99
82
|
</List>
|
|
@@ -101,11 +84,33 @@ class Rubric extends React.Component {
|
|
|
101
84
|
|
|
102
85
|
return (
|
|
103
86
|
<UiLayout extraCSSRules={extraCSSRules} className={classes.root}>
|
|
87
|
+
{/* screen reader only heading for navigation as per PD-5057 */}
|
|
88
|
+
<h2 className={classes.hiddenScreenReader}>Rubric</h2>
|
|
104
89
|
{!animationsDisabled ? (
|
|
105
90
|
<React.Fragment>
|
|
106
|
-
<
|
|
91
|
+
<h2
|
|
92
|
+
id={'rubric-toggle'}
|
|
93
|
+
className={classes.rubricToggle}
|
|
94
|
+
tabIndex={0}
|
|
95
|
+
role="button"
|
|
96
|
+
aria-expanded={this.state.rubricOpen}
|
|
97
|
+
onClick={this.toggleRubric}
|
|
98
|
+
onKeyPress={e => {
|
|
99
|
+
if (e.key === 'Enter' || e.key === ' ') this.toggleRubric();
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
107
102
|
{this.state.linkPrefix} Rubric
|
|
108
|
-
|
|
103
|
+
<span
|
|
104
|
+
className={classes.chevronStyle}
|
|
105
|
+
aria-hidden="true"
|
|
106
|
+
>
|
|
107
|
+
{this.state.rubricOpen ? (
|
|
108
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>
|
|
109
|
+
) : (
|
|
110
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
111
|
+
)}
|
|
112
|
+
</span>
|
|
113
|
+
</h2>
|
|
109
114
|
<Collapse in={this.state.rubricOpen} timeout="auto">
|
|
110
115
|
{rubricList}
|
|
111
116
|
</Collapse>
|
|
@@ -121,18 +126,57 @@ class Rubric extends React.Component {
|
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
const styles = () => ({
|
|
129
|
+
const styles = (theme) => ({
|
|
125
130
|
root: {
|
|
126
131
|
color: color.text(),
|
|
127
132
|
backgroundColor: color.background(),
|
|
128
133
|
},
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
listColumn: {
|
|
135
|
+
display: 'flex',
|
|
136
|
+
flexDirection: 'column',
|
|
137
|
+
alignItems: 'flex-start',
|
|
138
|
+
padding: '12px 0px',
|
|
139
|
+
},
|
|
140
|
+
listColumnItem: {
|
|
141
|
+
padding: 0,
|
|
132
142
|
},
|
|
133
143
|
text: {
|
|
134
144
|
color: color.text(),
|
|
135
145
|
},
|
|
146
|
+
titleText: {
|
|
147
|
+
color: color.text(),
|
|
148
|
+
fontSize: '16px',
|
|
149
|
+
fontWeight: '700',
|
|
150
|
+
margin: 0,
|
|
151
|
+
paddingBottom: '6px',
|
|
152
|
+
},
|
|
153
|
+
rubricToggle: {
|
|
154
|
+
display: 'flex',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
cursor: 'pointer',
|
|
157
|
+
userSelect: 'none',
|
|
158
|
+
fontSize: theme.typography.fontSize,
|
|
159
|
+
fontWeight: '500',
|
|
160
|
+
color: color.tertiary(),
|
|
161
|
+
margin: 0
|
|
162
|
+
},
|
|
163
|
+
chevronStyle: {
|
|
164
|
+
display: 'inline-flex',
|
|
165
|
+
transition: 'transform 0.2s',
|
|
166
|
+
marginLeft: 2,
|
|
167
|
+
alignSelf: 'center',
|
|
168
|
+
},
|
|
169
|
+
hiddenScreenReader: {
|
|
170
|
+
position: 'absolute',
|
|
171
|
+
width: '1px',
|
|
172
|
+
height: '1px',
|
|
173
|
+
padding: 0,
|
|
174
|
+
margin: '-1px',
|
|
175
|
+
overflow: 'hidden',
|
|
176
|
+
clip: 'rect(0,0,0,0)',
|
|
177
|
+
border: 0,
|
|
178
|
+
whiteSpace: 'nowrap',
|
|
179
|
+
},
|
|
136
180
|
});
|
|
137
181
|
|
|
138
182
|
export default withStyles(styles)(Rubric);
|