@pie-element/complex-rubric 2.10.1-next.1 → 2.10.1-next.11

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 (121) hide show
  1. package/configure/lib/defaults.js +216 -0
  2. package/configure/lib/defaults.js.map +1 -0
  3. package/configure/lib/index.js +241 -0
  4. package/configure/lib/index.js.map +1 -0
  5. package/configure/lib/main.js +221 -0
  6. package/configure/lib/main.js.map +1 -0
  7. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +1 -0
  8. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +1383 -0
  9. package/configure/node_modules/@pie-element/multi-trait-rubric/LICENSE.md +5 -0
  10. package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +55 -0
  11. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +1 -0
  12. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +1270 -0
  13. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +584 -0
  14. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +1 -0
  15. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +143 -0
  16. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +204 -0
  18. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +602 -0
  20. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +361 -0
  22. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +1 -0
  23. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +556 -0
  24. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +1 -0
  25. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +380 -0
  26. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +1 -0
  27. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +296 -0
  28. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +1 -0
  29. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +14 -0
  30. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +1 -0
  31. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +18 -0
  32. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +1 -0
  33. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +544 -0
  34. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +94 -0
  35. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +1 -0
  36. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +215 -0
  37. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +1 -0
  38. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js +13 -0
  39. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js.map +1 -0
  40. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +15 -0
  41. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +803 -0
  42. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +602 -0
  43. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +8 -0
  44. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +180 -0
  45. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +1 -0
  46. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +6 -0
  47. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +531 -0
  48. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +374 -0
  49. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +85 -0
  50. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +161 -0
  52. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +330 -0
  54. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +103 -0
  56. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +1 -0
  57. package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +24 -0
  58. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
  59. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +1640 -0
  60. package/configure/node_modules/@pie-element/rubric/LICENSE.md +5 -0
  61. package/configure/node_modules/@pie-element/rubric/README.md +3 -0
  62. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
  63. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +1471 -0
  64. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js +59 -0
  65. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js.map +1 -0
  66. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +194 -0
  67. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
  68. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js +160 -0
  69. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js.map +1 -0
  70. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/authoring.js +555 -0
  71. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/authoring.js.map +1 -0
  72. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/index.js +24 -0
  73. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/index.js.map +1 -0
  74. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/point-menu.js +172 -0
  75. package/configure/node_modules/@pie-element/rubric/configure/lib/pie-toolbox-rubric/point-menu.js.map +1 -0
  76. package/configure/node_modules/@pie-element/rubric/configure/package.json +17 -0
  77. package/configure/node_modules/@pie-element/rubric/configure/src/__tests__/index.test.jsx +173 -0
  78. package/configure/node_modules/@pie-element/rubric/configure/src/defaults.js +39 -0
  79. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +127 -0
  80. package/configure/node_modules/@pie-element/rubric/configure/src/main.jsx +87 -0
  81. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/authoring.jsx +427 -0
  82. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/index.js +9 -0
  83. package/configure/node_modules/@pie-element/rubric/configure/src/pie-toolbox-rubric/point-menu.jsx +94 -0
  84. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
  85. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +536 -0
  86. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +51 -0
  87. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
  88. package/configure/node_modules/@pie-element/rubric/controller/package.json +13 -0
  89. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +31 -0
  90. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +42 -0
  91. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +382 -0
  92. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +292 -0
  93. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
  94. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
  95. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +2 -0
  96. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +226 -0
  97. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +161 -0
  98. package/configure/node_modules/@pie-element/rubric/lib/index.js +88 -0
  99. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
  100. package/configure/node_modules/@pie-element/rubric/lib/main.js +187 -0
  101. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
  102. package/configure/node_modules/@pie-element/rubric/lib/print.js +114 -0
  103. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
  104. package/configure/node_modules/@pie-element/rubric/package.json +26 -0
  105. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +23003 -0
  106. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +50 -0
  107. package/configure/node_modules/@pie-element/rubric/src/index.js +34 -0
  108. package/configure/node_modules/@pie-element/rubric/src/main.jsx +136 -0
  109. package/configure/node_modules/@pie-element/rubric/src/print.js +63 -0
  110. package/configure/package.json +2 -2
  111. package/controller/lib/defaults.js +134 -0
  112. package/controller/lib/defaults.js.map +1 -0
  113. package/controller/lib/index.js +307 -0
  114. package/controller/lib/index.js.map +1 -0
  115. package/controller/lib/utils.js +13 -0
  116. package/controller/lib/utils.js.map +1 -0
  117. package/lib/index.js +232 -0
  118. package/lib/index.js.map +1 -0
  119. package/lib/print.js +201 -0
  120. package/lib/print.js.map +1 -0
  121. package/package.json +4 -4
@@ -0,0 +1,427 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { withStyles } from '@material-ui/core/styles';
4
+ import classNames from 'classnames';
5
+ import OutlinedInput from '@material-ui/core/OutlinedInput';
6
+ import InputLabel from '@material-ui/core/InputLabel';
7
+ import Select from '@material-ui/core/Select';
8
+ import FormControl from '@material-ui/core/FormControl';
9
+ import MenuItem from '@material-ui/core/MenuItem';
10
+ import times from 'lodash/times';
11
+ import Checkbox from '@material-ui/core/Checkbox';
12
+ import FormGroup from '@material-ui/core/FormGroup';
13
+ import FormControlLabel from '@material-ui/core/FormControlLabel';
14
+ import grey from '@material-ui/core/colors/grey';
15
+ import Typography from '@material-ui/core/Typography';
16
+ import DragIndicator from '@material-ui/icons/DragIndicator';
17
+ import EditableHtml from '@pie-lib/pie-toolbox/editable-html';
18
+ import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
19
+ import debug from 'debug';
20
+ import takeRight from 'lodash/takeRight';
21
+ import PointMenu from './point-menu';
22
+
23
+ import range from 'lodash/range';
24
+ import { InputContainer } from '@pie-lib/pie-toolbox/config-ui';
25
+
26
+ const log = debug('pie-lib:rubric:authoring');
27
+
28
+ const reorder = (list, startIndex, endIndex) => {
29
+ const result = Array.from(list);
30
+ const [removed] = result.splice(startIndex, 1);
31
+
32
+ result.splice(endIndex, 0, removed);
33
+
34
+ return result;
35
+ };
36
+
37
+ export const RubricType = PropTypes.shape({
38
+ excludeZero: PropTypes.bool,
39
+ points: PropTypes.arrayOf(PropTypes.string),
40
+ sampleAnswers: PropTypes.arrayOf(PropTypes.string),
41
+ maxPoints: PropTypes.number,
42
+ rubriclessInstruction: PropTypes.string,
43
+ });
44
+
45
+ const MaxPoints = withStyles((theme) => ({
46
+ formControl: {
47
+ minWidth: '120px',
48
+ margin: theme.spacing.unit,
49
+ },
50
+ }))((props) => {
51
+ const { value, onChange, max, classes } = props;
52
+
53
+ return (
54
+ <FormControl className={classes.formControl} variant="outlined">
55
+ <InputLabel width={100} htmlFor="...">
56
+ Max Points
57
+ </InputLabel>
58
+ <Select value={value} onChange={(e) => onChange(e.target.value)} input={<OutlinedInput labelWidth={80} />}>
59
+ {range(1, max + 1).map((v) => (
60
+ <MenuItem key={`${v}`} value={v}>
61
+ {v}
62
+ </MenuItem>
63
+ ))}
64
+ </Select>
65
+ </FormControl>
66
+ );
67
+ });
68
+
69
+ // if the value is null or 'null', the Sample Answer input field for that point will not be dispalyed
70
+ // if the value is '', the Sample Answer input field will be empty
71
+ const checkSampleAnswer = (sampleAnswer) => sampleAnswer === null || sampleAnswer === 'null';
72
+
73
+ export const PointConfig = withStyles((theme) => ({
74
+ pointConfig: {},
75
+ row: {
76
+ display: 'flex',
77
+ width: '100%',
78
+ position: 'relative',
79
+ },
80
+ editor: {
81
+ width: '100%',
82
+ backgroundColor: `${theme.palette.common.white} !important`,
83
+ },
84
+ dragIndicator: {
85
+ paddingTop: theme.spacing.unit,
86
+ color: grey[500],
87
+ },
88
+ pointsLabel: {
89
+ color: grey[500],
90
+ paddingBottom: theme.spacing.unit,
91
+ textTransform: 'uppercase',
92
+ },
93
+ sampleAnswersEditor: {
94
+ paddingLeft: theme.spacing.unit * 3,
95
+ },
96
+ pointMenu: {
97
+ position: 'absolute',
98
+ right: 0,
99
+ },
100
+ errorText: {
101
+ fontSize: theme.typography.fontSize - 2,
102
+ color: theme.palette.error.main,
103
+ paddingLeft: theme.spacing.unit * 3,
104
+ paddingTop: theme.spacing.unit,
105
+ },
106
+ }))((props) => {
107
+ const { points, content, classes, sampleAnswer, mathMlOptions = {}, error, pluginOpts = {}, excludeZero, imageSupport = {}, } = props;
108
+ const pointsCount = excludeZero ? points + 1 : points;
109
+ const pointsLabel = `${pointsCount} ${pointsCount <= 1 ? 'pt' : 'pts'}`;
110
+ const showSampleAnswer = checkSampleAnswer(sampleAnswer);
111
+
112
+ return (
113
+ <div className={classes.pointConfig}>
114
+ <Typography variant="overline" className={classes.pointsLabel}>
115
+ {pointsLabel}
116
+ </Typography>
117
+
118
+ <div className={classes.row}>
119
+ <DragIndicator className={classes.dragIndicator} />
120
+ <EditableHtml
121
+ className={classes.editor}
122
+ error={error}
123
+ pluginProps={pluginOpts}
124
+ markup={content}
125
+ onChange={props.onChange}
126
+ mathMlOptions={mathMlOptions}
127
+ imageSupport={imageSupport}
128
+ />
129
+ <PointMenu
130
+ classes={{
131
+ icon: classes.pointMenu,
132
+ }}
133
+ showSampleAnswer={showSampleAnswer}
134
+ onChange={props.onMenuChange}
135
+ />
136
+ </div>
137
+ {error && <div className={classes.errorText}>{error}</div>}
138
+ {!showSampleAnswer && (
139
+ <div className={classes.sampleAnswersEditor}>
140
+ <Typography variant="overline" className={classes.dragIndicator}>
141
+ Sample Response
142
+ </Typography>
143
+ <EditableHtml
144
+ className={classes.editor}
145
+ markup={sampleAnswer}
146
+ pluginProps={pluginOpts}
147
+ onChange={props.onSampleChange}
148
+ mathMlOptions={mathMlOptions}
149
+ imageSupport={imageSupport}
150
+ />
151
+ </div>
152
+ )}
153
+ </div>
154
+ );
155
+ });
156
+
157
+ export class RawAuthoring extends React.Component {
158
+ static propTypes = {
159
+ classes: PropTypes.object.isRequired,
160
+ className: PropTypes.string,
161
+ value: RubricType,
162
+ config: PropTypes.object,
163
+ pluginOpts: PropTypes.object,
164
+ rubricless: PropTypes.bool,
165
+ onChange: PropTypes.func,
166
+ imageSupport: PropTypes.shape({
167
+ add: PropTypes.func.isRequired,
168
+ delete: PropTypes.func.isRequired,
169
+ }),
170
+ };
171
+
172
+ static defaultProps = {};
173
+
174
+ dragEnd = (result) => {
175
+ if (!result.destination) {
176
+ return;
177
+ }
178
+
179
+ const { value, onChange } = this.props;
180
+
181
+ const points = reorder(value.points, result.source.index, result.destination.index);
182
+ const sampleAnswers = reorder(value.sampleAnswers, result.source.index, result.destination.index);
183
+
184
+ onChange({ ...value, points, sampleAnswers });
185
+ };
186
+
187
+ changeRubriclessInstruction = (input) => {
188
+ const { value, onChange } = this.props;
189
+ onChange({ ...value, rubriclessInstruction: input });
190
+ };
191
+
192
+ changeMaxPoints = (maxPoints) => {
193
+ const { value, onChange } = this.props;
194
+
195
+ onChange({ ...value, maxPoints });
196
+ };
197
+
198
+ changeContent = (index, content, type) => {
199
+ // type could be 'points' or 'sampleAnswers'
200
+ log(`changeModel[${type}]:`, index, content);
201
+
202
+ if (type !== 'points' && type !== 'sampleAnswers') {
203
+ return;
204
+ }
205
+
206
+ const { value, onChange } = this.props;
207
+ const items = value[type] && Array.from(value[type]);
208
+
209
+ items.splice(index, 1, content);
210
+ log(`changeModel[${type}]:`, items);
211
+
212
+ onChange({ ...value, [type]: items });
213
+ };
214
+
215
+ excludeZeros = () => {
216
+ const { value, onChange } = this.props;
217
+
218
+ onChange({ ...value, excludeZero: !value.excludeZero });
219
+ };
220
+
221
+ onPointMenuChange = (index, clickedItem) => {
222
+ if (clickedItem === 'sample') {
223
+ const { value } = this.props;
224
+ const sampleAnswers = Array.from(value.sampleAnswers || []);
225
+
226
+ if (checkSampleAnswer(sampleAnswers[index])) {
227
+ // an empty string will display an empty Sample Answer input field
228
+ this.changeContent(index, '', 'sampleAnswers');
229
+ } else {
230
+ // when the content is null or 'null', the Sample Answer input field will not be displayed
231
+ this.changeContent(index, null, 'sampleAnswers');
232
+ }
233
+ }
234
+ };
235
+
236
+ render() {
237
+ const {
238
+ classes,
239
+ className,
240
+ value,
241
+ mathMlOptions = {},
242
+ config = {},
243
+ rubricless = false,
244
+ pluginOpts = {},
245
+ imageSupport = {},
246
+ } = this.props;
247
+ let {
248
+ excludeZeroEnabled = true,
249
+ maxPointsEnabled = true,
250
+ errors = {},
251
+ rubriclessInstructionEnabled = false,
252
+ maxPoints = 10,
253
+ } = value || {};
254
+ // rubric will contain a max value for maxPoints
255
+ const { rubriclessInstruction = {}, maxMaxPoints = 10 } = config || {};
256
+ const { pointsDescriptorsErrors } = errors || {};
257
+ if (value && Number.isFinite(value.maxPoints)) {
258
+ // eslint-disable-next-line no-console
259
+ console.warn('maxPoints is deprecated - remove from model');
260
+ }
261
+
262
+ // for rubric value is computed based on points
263
+ const maxPointsValue = maxPoints;
264
+
265
+ return (
266
+ <div className={classNames(classes.class, className)}>
267
+ <Typography variant="h5" className={classes.rubricTitle}>
268
+ Rubric
269
+ </Typography>
270
+ <FormGroup row>
271
+ {maxPointsEnabled && (
272
+ <MaxPoints
273
+ max={maxMaxPoints < 100 ? maxMaxPoints : 100}
274
+ value={maxPointsValue}
275
+ onChange={this.changeMaxPoints}
276
+ pluginOpts={pluginOpts}
277
+ imageSupport={imageSupport}
278
+ />
279
+ )}
280
+ {excludeZeroEnabled && (
281
+ <FormControlLabel
282
+ label="Exclude zeros"
283
+ control={<Checkbox checked={value.excludeZero} onChange={this.excludeZeros} />}
284
+ />
285
+ )}
286
+ </FormGroup>
287
+
288
+ {rubriclessInstructionEnabled && rubricless && (
289
+ <InputContainer label={rubriclessInstruction.label} className={classes.inputContainer}>
290
+ <EditableHtml
291
+ className={classes.input}
292
+ markup={value.rubriclessInstruction || ''}
293
+ onChange={this.changeRubriclessInstruction}
294
+ pluginProps={pluginOpts}
295
+ nonEmpty={false}
296
+ disableUnderline
297
+ languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
298
+ mathMlOptions={mathMlOptions}
299
+ imageSupport={imageSupport}
300
+ />
301
+ </InputContainer>
302
+ )}
303
+
304
+ <div className={rubricless ? classes.rubricless : classes.container}>
305
+ <DragDropContext onDragEnd={this.dragEnd}>
306
+ <Droppable droppableId="droppable">
307
+ {(provided) => (
308
+ <div {...provided.droppableProps} ref={provided.innerRef}>
309
+ {value.points.map(
310
+ (p, index) => {
311
+ return (
312
+ <Draggable key={`${p.points}-${index}`} index={index} draggableId={index.toString()}>
313
+ {(provided) => (
314
+ <div
315
+ className={classes.configHolder}
316
+ ref={provided.innerRef}
317
+ {...provided.draggableProps}
318
+ {...provided.dragHandleProps}
319
+ >
320
+ <PointConfig
321
+ points={value.points.length - 1 - index}
322
+ content={p}
323
+ error={
324
+ pointsDescriptorsErrors && pointsDescriptorsErrors[value.points.length - 1 - index]
325
+ }
326
+ sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}
327
+ onChange={(content) => this.changeContent(index, content, 'points')}
328
+ onSampleChange={(content) => this.changeContent(index, content, 'sampleAnswers')}
329
+ onMenuChange={(clickedItem) => this.onPointMenuChange(index, clickedItem)}
330
+ mathMlOptions={mathMlOptions}
331
+ pluginOpts={pluginOpts}
332
+ imageSupport={imageSupport}
333
+ excludeZero={value.excludeZero}
334
+ />
335
+ </div>
336
+ )}
337
+ </Draggable>
338
+ );
339
+ },
340
+ )}
341
+ {provided.placeholder}
342
+ </div>
343
+ )}
344
+ </Droppable>
345
+ </DragDropContext>
346
+ </div>
347
+ </div>
348
+ );
349
+ }
350
+ }
351
+
352
+ const styles = (theme) => ({
353
+ container: {
354
+ backgroundColor: grey[200],
355
+ borderWidth: 1,
356
+ borderStyle: 'solid',
357
+ borderColor: grey[300],
358
+ padding: theme.spacing.unit * 2,
359
+ margin: theme.spacing.unit,
360
+ },
361
+ inputContainer: {
362
+ width: '100%',
363
+ paddingTop: theme.spacing.unit * 2,
364
+ marginBottom: theme.spacing.unit * 2,
365
+ },
366
+ rubricless: {
367
+ display: 'none',
368
+ },
369
+ configHolder: {
370
+ paddingTop: theme.spacing.unit,
371
+ paddingBottom: theme.spacing.unit,
372
+ },
373
+ rubricTitle: {
374
+ paddingLeft: theme.spacing.unit,
375
+ margin: theme.spacing.unit,
376
+ },
377
+ });
378
+
379
+ const StyledRawAuthoring = withStyles(styles)(RawAuthoring);
380
+
381
+ const Reverse = (props) => {
382
+ const { rubricless = false, config = {}, pluginOpts = {}, imageSupport = {} } = props || {};
383
+ const points = Array.from(props.value.points || []).reverse();
384
+ let sampleAnswers = Array.from(props.value.sampleAnswers || []).reverse();
385
+
386
+ if (points.length > sampleAnswers.length) {
387
+ sampleAnswers = times(points.length - sampleAnswers.length)
388
+ .map(() => null)
389
+ .concat(sampleAnswers);
390
+ }
391
+
392
+ const value = { ...props.value, points, sampleAnswers };
393
+
394
+ const onChange = (value) => {
395
+ props.onChange({
396
+ ...value,
397
+ points: Array.from(value.points || []).reverse(),
398
+ sampleAnswers: Array.from(value.sampleAnswers || []).reverse(),
399
+ });
400
+ };
401
+
402
+ return (
403
+ <StyledRawAuthoring
404
+ value={value}
405
+ config={config}
406
+ onChange={onChange}
407
+ rubricless={rubricless}
408
+ pluginOpts={pluginOpts}
409
+ imageSupport={imageSupport}
410
+ />
411
+ );
412
+ };
413
+
414
+ Reverse.propTypes = {
415
+ value: RubricType,
416
+ config: PropTypes.object,
417
+ pluginOpts: PropTypes.object,
418
+ rubricless: PropTypes.bool,
419
+ getIndex: PropTypes.func,
420
+ onChange: PropTypes.func,
421
+ imageSupport: PropTypes.shape({
422
+ add: PropTypes.func.isRequired,
423
+ delete: PropTypes.func.isRequired,
424
+ }),
425
+ };
426
+
427
+ export default Reverse;
@@ -0,0 +1,9 @@
1
+ import Authoring from './authoring';
2
+
3
+ const RUBRIC_TYPES = {
4
+ SIMPLE_RUBRIC: 'simpleRubric',
5
+ MULTI_TRAIT_RUBRIC: 'multiTraitRubric',
6
+ RUBRICLESS: 'rubricless',
7
+ };
8
+
9
+ export { Authoring, RUBRIC_TYPES };
@@ -0,0 +1,94 @@
1
+ import Menu from '@material-ui/core/Menu';
2
+ import MenuItem from '@material-ui/core/MenuItem';
3
+ import MoreVertIcon from '@material-ui/icons/MoreVert';
4
+ import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
5
+ import IconButton from '@material-ui/core/IconButton';
6
+ import PropTypes from 'prop-types';
7
+ import React from 'react';
8
+
9
+ export class IconMenu extends React.Component {
10
+ static propTypes = {
11
+ opts: PropTypes.object,
12
+ onClick: PropTypes.func.isRequired,
13
+ classes: PropTypes.object.isRequired,
14
+ };
15
+
16
+ constructor(props) {
17
+ super(props);
18
+ this.state = {
19
+ anchorEl: undefined,
20
+ open: false,
21
+ };
22
+ }
23
+
24
+ handleClick = (event) => this.setState({ open: true, anchorEl: event.currentTarget });
25
+
26
+ handleRequestClose = () => this.setState({ open: false });
27
+
28
+ render() {
29
+ const { opts, onClick, classes } = this.props;
30
+ const { open, anchorEl } = this.state;
31
+ const keys = Object.keys(opts) || [];
32
+
33
+ const handleMenuClick = (key) => () => {
34
+ onClick(key);
35
+ this.handleRequestClose();
36
+ };
37
+
38
+ const iconColor = open ? 'inherit' : 'disabled';
39
+
40
+ return (
41
+ <div>
42
+ <div onClick={this.handleClick}>
43
+ <IconButton className={classes.icon}>
44
+ {open ? <MoreVertIcon color={iconColor} /> : <MoreHorizIcon color={iconColor} />}
45
+ </IconButton>
46
+ </div>
47
+ <Menu
48
+ id="point-menu"
49
+ anchorEl={anchorEl}
50
+ open={open}
51
+ onClose={this.handleRequestClose}
52
+ style={{ transform: 'translate(-15px, -15px)' }}
53
+ transformOrigin={{
54
+ vertical: 'center',
55
+ horizontal: 'right',
56
+ }}
57
+ >
58
+ {keys.map((k, index) => (
59
+ <MenuItem key={index} onClick={handleMenuClick(k)}>
60
+ {opts[k]}
61
+ </MenuItem>
62
+ ))}
63
+ </Menu>
64
+ </div>
65
+ );
66
+ }
67
+ }
68
+
69
+ export default class PointMenu extends React.Component {
70
+ static propTypes = {
71
+ onChange: PropTypes.func.isRequired,
72
+ classes: PropTypes.object.isRequired,
73
+ showSampleAnswer: PropTypes.bool.isRequired,
74
+ };
75
+
76
+ static defaultProps = {
77
+ classes: {},
78
+ };
79
+
80
+ render() {
81
+ const { onChange, classes, showSampleAnswer } = this.props;
82
+ const sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';
83
+
84
+ return (
85
+ <IconMenu
86
+ onClick={(key) => onChange(key)}
87
+ opts={{
88
+ sample: sampleText,
89
+ }}
90
+ classes={classes}
91
+ />
92
+ );
93
+ }
94
+ }
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "type": "fix",
4
+ "scope": null,
5
+ "subject": "bump all packages to avoid tag conflict",
6
+ "merge": null,
7
+ "header": "fix: bump all packages to avoid tag conflict",
8
+ "body": null,
9
+ "footer": null,
10
+ "notes": [],
11
+ "hash": "d9ec9a8689f0a391594b5e2f4ea958c6dc9f6d7b",
12
+ "gitTags": " (develop)",
13
+ "committerDate": "2020-04-10 20:01:37 +0100",
14
+ "isTagged": true,
15
+ "tag": "@pie-element/rubric-controller@1.1.1"
16
+ }
17
+ ]