@pie-element/rubric 8.1.0-next.28 → 8.1.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/dist/author/defaults.d.ts +71 -0
- package/dist/author/defaults.js +53 -0
- package/dist/author/index.d.ts +21 -0
- package/dist/author/index.js +72 -0
- package/dist/author/main.d.ts +14 -0
- package/dist/author/main.js +51 -0
- package/dist/controller/defaults.d.ts +17 -0
- package/dist/controller/defaults.js +21 -0
- package/dist/controller/index.d.ts +10 -0
- package/dist/controller/index.js +23 -0
- package/dist/delivery/index.d.ts +16 -0
- package/dist/delivery/index.js +33 -0
- package/dist/delivery/main.d.ts +34 -0
- package/dist/delivery/main.js +156 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +145 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/print/index.d.ts +15 -0
- package/dist/print/index.js +34 -0
- package/package.json +57 -25
- package/CHANGELOG.json +0 -257
- package/CHANGELOG.md +0 -1707
- package/LICENSE.md +0 -5
- package/README.md +0 -3
- package/configure/CHANGELOG.json +0 -197
- package/configure/CHANGELOG.md +0 -1547
- package/configure/lib/defaults.js +0 -70
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -135
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -103
- package/configure/lib/main.js.map +0 -1
- package/configure/package.json +0 -23
- package/configure/src/__tests__/index.test.jsx +0 -192
- package/configure/src/defaults.js +0 -43
- package/configure/src/index.js +0 -139
- package/configure/src/main.jsx +0 -87
- package/controller/CHANGELOG.json +0 -17
- package/controller/CHANGELOG.md +0 -893
- package/controller/lib/defaults.js +0 -15
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -46
- package/controller/lib/index.js.map +0 -1
- package/controller/package.json +0 -12
- package/controller/src/__tests__/index.test.js +0 -33
- package/controller/src/defaults.js +0 -8
- package/controller/src/index.js +0 -41
- package/docs/config-schema.json +0 -712
- package/docs/config-schema.json.md +0 -532
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -8
- package/docs/demo/index.html +0 -2
- package/docs/pie-schema.json +0 -391
- package/docs/pie-schema.json.md +0 -281
- package/lib/index.js +0 -52
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -208
- package/lib/main.js.map +0 -1
- package/lib/print.js +0 -71
- package/lib/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -73
- package/module/demo.js +0 -33
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -71
- package/module/print.html +0 -18
- package/module/print.js +0 -1
- package/src/__tests__/rubric-view.test.jsx +0 -37
- package/src/index.js +0 -48
- package/src/main.jsx +0 -226
- package/src/print.js +0 -74
package/src/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import Rubric from './main';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { createRoot } from 'react-dom/client';
|
|
4
|
-
import debug from 'debug';
|
|
5
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
|
-
|
|
7
|
-
export default class RubricRender extends HTMLElement {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
debug.log('constructor called');
|
|
11
|
-
this.onModelChanged = this.onModelChanged.bind(this);
|
|
12
|
-
this._root = null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
set model(s) {
|
|
16
|
-
this._model = s;
|
|
17
|
-
this._render();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
onModelChanged(m) {
|
|
21
|
-
this._model = m;
|
|
22
|
-
this._render();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
connectedCallback() {
|
|
26
|
-
this._render();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
_render() {
|
|
30
|
-
if (this._model) {
|
|
31
|
-
const el = React.createElement(Rubric, { value: this._model });
|
|
32
|
-
|
|
33
|
-
if (!this._root) {
|
|
34
|
-
this._root = createRoot(this);
|
|
35
|
-
}
|
|
36
|
-
this._root.render(el);
|
|
37
|
-
queueMicrotask(() => {
|
|
38
|
-
renderMath(this);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
disconnectedCallback() {
|
|
44
|
-
if (this._root) {
|
|
45
|
-
this._root.unmount();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
package/src/main.jsx
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
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
|
-
import { color, UiLayout } from '@pie-lib/render-ui';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
9
|
-
const StyledUiLayout = styled(UiLayout)({
|
|
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
|
-
|
|
85
|
-
export const RubricType = PropTypes.shape({
|
|
86
|
-
excludeZero: PropTypes.bool,
|
|
87
|
-
points: PropTypes.arrayOf(PropTypes.string),
|
|
88
|
-
sampleAnswers: PropTypes.arrayOf(PropTypes.string),
|
|
89
|
-
animationsDisabled: PropTypes.bool,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
class Rubric extends React.Component {
|
|
93
|
-
dudUrl = 'javascript:;';
|
|
94
|
-
|
|
95
|
-
constructor(props) {
|
|
96
|
-
super(props);
|
|
97
|
-
this.state = {
|
|
98
|
-
rubricOpen: false,
|
|
99
|
-
linkPrefix: 'Show',
|
|
100
|
-
};
|
|
101
|
-
this.toggleRubric = this.toggleRubric.bind(this);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static propTypes = {
|
|
105
|
-
model: PropTypes.object.isRequired,
|
|
106
|
-
animationsDisabled: PropTypes.bool,
|
|
107
|
-
value: RubricType,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
toggleRubric() {
|
|
111
|
-
this.setState({ rubricOpen: !this.state.rubricOpen });
|
|
112
|
-
this.setState({ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide' });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
shouldRenderPoint = (index, value) => {
|
|
116
|
-
if (!value.excludeZero) {
|
|
117
|
-
return true;
|
|
118
|
-
} else {
|
|
119
|
-
return index !== 0;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
render() {
|
|
124
|
-
const { model, value } = this.props;
|
|
125
|
-
let { animationsDisabled } = this.props;
|
|
126
|
-
animationsDisabled = animationsDisabled || value.animationsDisabled;
|
|
127
|
-
|
|
128
|
-
if (value && value.points) {
|
|
129
|
-
const { extraCSSRules } = model || {};
|
|
130
|
-
const { points, sampleAnswers } = value;
|
|
131
|
-
|
|
132
|
-
const rubricList = (
|
|
133
|
-
<List component="nav">
|
|
134
|
-
{points
|
|
135
|
-
.slice(0)
|
|
136
|
-
.reverse()
|
|
137
|
-
.map((desc, index) => {
|
|
138
|
-
index = points.length - index - 1;
|
|
139
|
-
const pointsLabel = value.excludeZero ? index + 1 : index;
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<React.Fragment key={index}>
|
|
143
|
-
<StyledListItem key={`P${index}`}>
|
|
144
|
-
<TitleText>
|
|
145
|
-
{pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`}
|
|
146
|
-
</TitleText>
|
|
147
|
-
<Text dangerouslySetInnerHTML={{ __html: desc }} />
|
|
148
|
-
</StyledListItem>
|
|
149
|
-
|
|
150
|
-
{sampleAnswers && sampleAnswers[index] && (
|
|
151
|
-
<StyledListItem key={`S${index}`}>
|
|
152
|
-
<SampleTitleText>
|
|
153
|
-
Sample Answer
|
|
154
|
-
</SampleTitleText>
|
|
155
|
-
<Text dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
156
|
-
</StyledListItem>
|
|
157
|
-
)}
|
|
158
|
-
</React.Fragment>
|
|
159
|
-
);
|
|
160
|
-
})}
|
|
161
|
-
</List>
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<StyledUiLayout extraCSSRules={extraCSSRules}>
|
|
166
|
-
{/* screen reader only heading for navigation as per PD-5057 */}
|
|
167
|
-
<HiddenScreenReader>Rubric</HiddenScreenReader>
|
|
168
|
-
{!animationsDisabled ? (
|
|
169
|
-
<React.Fragment>
|
|
170
|
-
<RubricToggle
|
|
171
|
-
id={'rubric-toggle'}
|
|
172
|
-
tabIndex={0}
|
|
173
|
-
role="button"
|
|
174
|
-
aria-expanded={this.state.rubricOpen}
|
|
175
|
-
onClick={this.toggleRubric}
|
|
176
|
-
onKeyPress={(e) => {
|
|
177
|
-
if (e.key === 'Enter' || e.key === ' ') this.toggleRubric();
|
|
178
|
-
}}
|
|
179
|
-
>
|
|
180
|
-
{this.state.linkPrefix} Rubric
|
|
181
|
-
<ChevronStyle aria-hidden="true">
|
|
182
|
-
{this.state.rubricOpen ? (
|
|
183
|
-
<svg
|
|
184
|
-
width="20"
|
|
185
|
-
height="20"
|
|
186
|
-
viewBox="0 0 24 24"
|
|
187
|
-
fill="none"
|
|
188
|
-
stroke="currentColor"
|
|
189
|
-
strokeWidth="2"
|
|
190
|
-
strokeLinecap="round"
|
|
191
|
-
strokeLinejoin="round"
|
|
192
|
-
>
|
|
193
|
-
<polyline points="18 15 12 9 6 15"></polyline>
|
|
194
|
-
</svg>
|
|
195
|
-
) : (
|
|
196
|
-
<svg
|
|
197
|
-
width="20"
|
|
198
|
-
height="20"
|
|
199
|
-
viewBox="0 0 24 24"
|
|
200
|
-
fill="none"
|
|
201
|
-
stroke="currentColor"
|
|
202
|
-
strokeWidth="2"
|
|
203
|
-
strokeLinecap="round"
|
|
204
|
-
strokeLinejoin="round"
|
|
205
|
-
>
|
|
206
|
-
<polyline points="6 9 12 15 18 9"></polyline>
|
|
207
|
-
</svg>
|
|
208
|
-
)}
|
|
209
|
-
</ChevronStyle>
|
|
210
|
-
</RubricToggle>
|
|
211
|
-
<Collapse in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>
|
|
212
|
-
{rubricList}
|
|
213
|
-
</Collapse>
|
|
214
|
-
</React.Fragment>
|
|
215
|
-
) : (
|
|
216
|
-
rubricList
|
|
217
|
-
)}
|
|
218
|
-
</StyledUiLayout>
|
|
219
|
-
);
|
|
220
|
-
} else {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export default Rubric;
|
package/src/print.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { debounce } from 'lodash-es';
|
|
4
|
-
import Main from './main';
|
|
5
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
|
-
import debug from 'debug';
|
|
7
|
-
|
|
8
|
-
const log = debug('pie-element:rubric:print');
|
|
9
|
-
|
|
10
|
-
const preparePrintModel = (model, opts) => {
|
|
11
|
-
const instr = opts.role === 'instructor';
|
|
12
|
-
|
|
13
|
-
if (!instr) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
model.value = { ...model };
|
|
18
|
-
model.mode = 'evaluate';
|
|
19
|
-
model.animationsDisabled = true;
|
|
20
|
-
|
|
21
|
-
return model;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default class RubricPrint extends HTMLElement {
|
|
25
|
-
constructor() {
|
|
26
|
-
super();
|
|
27
|
-
this._options = null;
|
|
28
|
-
this._model = null;
|
|
29
|
-
this._session = [];
|
|
30
|
-
this._root = null;
|
|
31
|
-
this._rerender = debounce(
|
|
32
|
-
() => {
|
|
33
|
-
if (this._model && this._session) {
|
|
34
|
-
const printModel = preparePrintModel(this._model, this._options);
|
|
35
|
-
|
|
36
|
-
const element =
|
|
37
|
-
this._options &&
|
|
38
|
-
React.createElement(Main, {
|
|
39
|
-
...printModel,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (!this._root) {
|
|
43
|
-
this._root = createRoot(this);
|
|
44
|
-
}
|
|
45
|
-
this._root.render(element);
|
|
46
|
-
queueMicrotask(() => {
|
|
47
|
-
log('render complete - render math');
|
|
48
|
-
renderMath(this);
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
log('skip');
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
50,
|
|
55
|
-
{ leading: false, trailing: true },
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
set options(o) {
|
|
59
|
-
this._options = o;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
set model(s) {
|
|
63
|
-
this._model = s;
|
|
64
|
-
this._rerender();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
connectedCallback() {}
|
|
68
|
-
|
|
69
|
-
disconnectedCallback() {
|
|
70
|
-
if (this._root) {
|
|
71
|
-
this._root.unmount();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|