@pie-element/complex-rubric 0.0.2-next.4424
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/LICENSE.md +5 -0
- package/README.md +3 -0
- package/configure/lib/defaults.js +99 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +232 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +165 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +376 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/LICENSE.md +5 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +55 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +344 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +455 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +82 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +112 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +438 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +324 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +490 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +334 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +254 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +29 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +22 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +66 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +9 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +122 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +226 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +169 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +108 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +6 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +282 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +189 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +85 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +99 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +209 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +103 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +1 -0
- package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +24 -0
- package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
- package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +731 -0
- package/configure/node_modules/@pie-element/rubric/LICENSE.md +5 -0
- package/configure/node_modules/@pie-element/rubric/README.md +3 -0
- package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
- package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +615 -0
- package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +93 -0
- package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/rubric/configure/package.json +16 -0
- package/configure/node_modules/@pie-element/rubric/configure/src/index.js +38 -0
- package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
- package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +105 -0
- package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +14 -0
- package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/rubric/controller/package.json +9 -0
- package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +35 -0
- package/configure/node_modules/@pie-element/rubric/controller/src/index.js +6 -0
- package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +24 -0
- package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +19 -0
- package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
- package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +3 -0
- package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +62 -0
- package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +35 -0
- package/configure/node_modules/@pie-element/rubric/lib/index.js +88 -0
- package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/rubric/lib/main.js +171 -0
- package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/rubric/lib/print.js +114 -0
- package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/rubric/package.json +25 -0
- package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +22767 -0
- package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +48 -0
- package/configure/node_modules/@pie-element/rubric/src/index.js +38 -0
- package/configure/node_modules/@pie-element/rubric/src/main.jsx +117 -0
- package/configure/node_modules/@pie-element/rubric/src/print.js +63 -0
- package/configure/package.json +22 -0
- package/configure/src/__tests__/__snapshots__/main.test.jsx.snap +106 -0
- package/configure/src/__tests__/index.test.js +41 -0
- package/configure/src/__tests__/main.test.jsx +104 -0
- package/configure/src/defaults.js +122 -0
- package/configure/src/index.js +138 -0
- package/configure/src/main.jsx +117 -0
- package/controller/lib/defaults.js +99 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +147 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +12 -0
- package/controller/src/__tests__/index.test.js +58 -0
- package/controller/src/defaults.js +121 -0
- package/controller/src/index.js +81 -0
- package/docs/config-schema.json +427 -0
- package/docs/config-schema.json.md +315 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +119 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +994 -0
- package/docs/pie-schema.json.md +660 -0
- package/lib/index.js +176 -0
- package/lib/index.js.map +1 -0
- package/package.json +25 -0
- package/src/__tests__/index.test.js +166 -0
- package/src/index.js +106 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { ModelUpdatedEvent } from '@pie-framework/pie-configure-events';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import RubricConfigure from '@pie-element/rubric/configure/lib';
|
|
5
|
+
import MultiTraitRubricConfigure from '@pie-element/multi-trait-rubric/configure/lib';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
import defaults from 'lodash/defaults';
|
|
8
|
+
import Main from '@pie-element/complex-rubric-configure/src/main';
|
|
9
|
+
|
|
10
|
+
import sensibleDefaults from './defaults';
|
|
11
|
+
|
|
12
|
+
const MODEL_UPDATED = ModelUpdatedEvent.TYPE;
|
|
13
|
+
const RUBRIC_TAG_NAME = 'rubric-configure';
|
|
14
|
+
const MULTI_TRAIT_RUBRIC_TAG_NAME = 'multi-trait-rubric-configure';
|
|
15
|
+
|
|
16
|
+
class ComplexSimpleRubricConfigure extends RubricConfigure {}
|
|
17
|
+
class ComplexMTRConfigure extends MultiTraitRubricConfigure {}
|
|
18
|
+
|
|
19
|
+
const defineComplexRubric = () => {
|
|
20
|
+
if (!customElements.get(RUBRIC_TAG_NAME)) {
|
|
21
|
+
customElements.define(RUBRIC_TAG_NAME, ComplexSimpleRubricConfigure);
|
|
22
|
+
}
|
|
23
|
+
if (!customElements.get(MULTI_TRAIT_RUBRIC_TAG_NAME)) {
|
|
24
|
+
customElements.define(MULTI_TRAIT_RUBRIC_TAG_NAME, ComplexMTRConfigure);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
defineComplexRubric();
|
|
29
|
+
|
|
30
|
+
const prepareCustomizationObject = (config, model) => {
|
|
31
|
+
const configuration = defaults(config, sensibleDefaults.configuration);
|
|
32
|
+
configuration.settingsPanelDisabled = true;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
configuration,
|
|
36
|
+
model
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default class ComplexRubricConfigureElement extends HTMLElement {
|
|
41
|
+
static createDefaultModel = ({ rubrics: { simpleRubric = {}, multiTraitRubric = {} } = { simpleRubric: {}, multiTraitRubric: {}}, ...model } = {}, defaults = {}) => ({
|
|
42
|
+
...defaults,
|
|
43
|
+
...model,
|
|
44
|
+
rubrics: {
|
|
45
|
+
simpleRubric: {
|
|
46
|
+
...(defaults.rubrics || {}).simpleRubric,
|
|
47
|
+
...simpleRubric
|
|
48
|
+
},
|
|
49
|
+
multiTraitRubric: {
|
|
50
|
+
...(defaults.rubrics || {}).multiTraitRubric,
|
|
51
|
+
...multiTraitRubric
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
debug.log('constructor called');
|
|
59
|
+
this._model = ComplexRubricConfigureElement.createDefaultModel();
|
|
60
|
+
|
|
61
|
+
this._configuration = sensibleDefaults.configuration;
|
|
62
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set model(m) {
|
|
66
|
+
this._model = ComplexRubricConfigureElement.createDefaultModel(m, this._model);
|
|
67
|
+
|
|
68
|
+
this._render();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
dispatchModelUpdated(reset) {
|
|
72
|
+
const resetValue = !!reset;
|
|
73
|
+
|
|
74
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onModelChanged = (m, reset) => {
|
|
78
|
+
this._model = ComplexRubricConfigureElement.createDefaultModel(m, this._model);
|
|
79
|
+
|
|
80
|
+
this.dispatchModelUpdated(reset);
|
|
81
|
+
this._render();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
set configuration(c) {
|
|
85
|
+
const info = prepareCustomizationObject(c, this._model);
|
|
86
|
+
this._configuration = info.configuration;
|
|
87
|
+
|
|
88
|
+
this._render();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onConfigurationChanged(c) {
|
|
92
|
+
this._configuration = prepareCustomizationObject(c, this._model).configuration;
|
|
93
|
+
|
|
94
|
+
if (this._model) {
|
|
95
|
+
this.onModelChanged(this._model);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this._render();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onModelUpdated = e => {
|
|
102
|
+
if (e.target === this) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopImmediatePropagation();
|
|
108
|
+
|
|
109
|
+
const id = e.target && e.target.getAttribute('id');
|
|
110
|
+
|
|
111
|
+
if (id) {
|
|
112
|
+
if (e.update) {
|
|
113
|
+
this._model.rubrics[id] = e.update;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
connectedCallback() {
|
|
121
|
+
this.addEventListener(MODEL_UPDATED, this.onModelUpdated);
|
|
122
|
+
this._render();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
disconnectedCallback() {
|
|
126
|
+
this.removeEventListener(MODEL_UPDATED, this.onModelUpdated);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_render() {
|
|
130
|
+
let element = React.createElement(Main, {
|
|
131
|
+
model: this._model,
|
|
132
|
+
configuration: this._configuration,
|
|
133
|
+
onModelChanged: this.onModelChanged,
|
|
134
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
135
|
+
});
|
|
136
|
+
ReactDOM.render(element, this);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Radio from '@material-ui/core/Radio';
|
|
4
|
+
import RadioGroup from '@material-ui/core/RadioGroup';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
6
|
+
import { FormControlLabel } from '@material-ui/core';
|
|
7
|
+
import { RUBRIC_TYPES } from '@pie-lib/rubric';
|
|
8
|
+
|
|
9
|
+
const styles = {
|
|
10
|
+
rubric: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column',
|
|
13
|
+
padding: '16px 0 32px'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class Main extends React.Component {
|
|
18
|
+
static propTypes = {
|
|
19
|
+
classes: PropTypes.object,
|
|
20
|
+
configuration: PropTypes.object,
|
|
21
|
+
model: PropTypes.object,
|
|
22
|
+
onModelChanged: PropTypes.func,
|
|
23
|
+
onConfigurationChanged: PropTypes.func
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
onModelChanged = (model) => {
|
|
27
|
+
const { onModelChanged } = this.props;
|
|
28
|
+
|
|
29
|
+
return onModelChanged(model);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onChangeRubricType = (e) => {
|
|
33
|
+
const { model } = this.props;
|
|
34
|
+
|
|
35
|
+
const rubricType = e.target.value;
|
|
36
|
+
this.onModelChanged({
|
|
37
|
+
...model,
|
|
38
|
+
rubricType,
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
render() {
|
|
43
|
+
const {
|
|
44
|
+
classes,
|
|
45
|
+
model,
|
|
46
|
+
configuration
|
|
47
|
+
} = this.props;
|
|
48
|
+
const { rubricType, rubrics = {} } = model;
|
|
49
|
+
const { multiTraitRubric } = configuration;
|
|
50
|
+
let rubricTag = '';
|
|
51
|
+
|
|
52
|
+
switch (rubricType) {
|
|
53
|
+
case RUBRIC_TYPES.SIMPLE_RUBRIC:
|
|
54
|
+
default:
|
|
55
|
+
rubricTag = <rubric-configure
|
|
56
|
+
id="simpleRubric"
|
|
57
|
+
key="simple-rubric"
|
|
58
|
+
ref={ref => {
|
|
59
|
+
if (ref) {
|
|
60
|
+
this.simpleRubric = ref;
|
|
61
|
+
this.simpleRubric.model = rubrics.simpleRubric;
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
/>;
|
|
65
|
+
break;
|
|
66
|
+
case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:
|
|
67
|
+
rubricTag = <multi-trait-rubric-configure
|
|
68
|
+
id="multiTraitRubric"
|
|
69
|
+
key="multi-trait-rubric"
|
|
70
|
+
ref={ref => {
|
|
71
|
+
if (ref) {
|
|
72
|
+
this.multiTraitRubric = ref;
|
|
73
|
+
this.multiTraitRubric.model = {
|
|
74
|
+
...rubrics.multiTraitRubric
|
|
75
|
+
};
|
|
76
|
+
this.multiTraitRubric.configuration = multiTraitRubric;
|
|
77
|
+
}
|
|
78
|
+
}}
|
|
79
|
+
/>;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className={classes.design}>
|
|
85
|
+
<div>
|
|
86
|
+
<div>
|
|
87
|
+
<RadioGroup
|
|
88
|
+
aria-label='rubric-type'
|
|
89
|
+
name='rubricType'
|
|
90
|
+
value={rubricType}
|
|
91
|
+
defaultValue={RUBRIC_TYPES.SIMPLE_RUBRIC}
|
|
92
|
+
onChange={this.onChangeRubricType}
|
|
93
|
+
>
|
|
94
|
+
<FormControlLabel
|
|
95
|
+
value={RUBRIC_TYPES.SIMPLE_RUBRIC}
|
|
96
|
+
control={<Radio/>}
|
|
97
|
+
checked={rubricType === RUBRIC_TYPES.SIMPLE_RUBRIC}
|
|
98
|
+
label='Simple Rubric'
|
|
99
|
+
/>
|
|
100
|
+
<FormControlLabel
|
|
101
|
+
value={RUBRIC_TYPES.MULTI_TRAIT_RUBRIC}
|
|
102
|
+
control={<Radio/>}
|
|
103
|
+
checked={rubricType === RUBRIC_TYPES.MULTI_TRAIT_RUBRIC}
|
|
104
|
+
label='Multi Trait Rubric'
|
|
105
|
+
/>
|
|
106
|
+
</RadioGroup>
|
|
107
|
+
</div>
|
|
108
|
+
<div>
|
|
109
|
+
{rubricTag}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default withStyles(styles)(Main);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var multiTraitDefaultModel = {
|
|
8
|
+
visibleToStudent: true,
|
|
9
|
+
halfScoring: false,
|
|
10
|
+
pointLabels: true,
|
|
11
|
+
description: false,
|
|
12
|
+
standards: false,
|
|
13
|
+
scales: [],
|
|
14
|
+
excludeZero: false
|
|
15
|
+
};
|
|
16
|
+
var rubricDefaultModel = {
|
|
17
|
+
points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
|
|
18
|
+
sampleAnswers: [null, 'just right', 'not left', null],
|
|
19
|
+
maxPoints: 4,
|
|
20
|
+
excludeZero: false
|
|
21
|
+
};
|
|
22
|
+
var multiTraitDefaultConfiguration = {
|
|
23
|
+
settingsPanelDisabled: true,
|
|
24
|
+
excludeZeroDialogBoxContent: {
|
|
25
|
+
title: 'Exclude 0 (Zero) from Score Point Values.',
|
|
26
|
+
text: "<div>\n You are about to exclude 0 from score point values.\n <br/>\n Some of the existing data has to be changed.\n <br/>\n Please choose if you want to:\n <ul>\n <li>\n shift Labels and Descriptions to the left\n </li>\n <li>\n remove 0 column with its Label and Description\n </li>\n </ul>\n </div>"
|
|
27
|
+
},
|
|
28
|
+
includeZeroDialogBoxContent: {
|
|
29
|
+
title: 'Include 0 (Zero) in Score Point Values.',
|
|
30
|
+
text: "<div>\n You are about to include 0 in score point values.\n <br/>\n Some of the existing data has to be changed.\n <br/>\n Please choose if you want to:\n <ul>\n <li>\n shift Labels and Descriptions to the right\n </li>\n <li>\n add 0 column with empty Label and Descriptions\n </li>\n </ul>\n </div>"
|
|
31
|
+
},
|
|
32
|
+
deleteTraitDialogBoxContent: {
|
|
33
|
+
title: 'Delete Trait',
|
|
34
|
+
text: 'Are you sure you want to delete this trait?'
|
|
35
|
+
},
|
|
36
|
+
deleteScaleDialogBoxContent: {
|
|
37
|
+
title: 'Delete Scale',
|
|
38
|
+
text: 'Are you sure you want to delete this scale?'
|
|
39
|
+
},
|
|
40
|
+
maxPointsDialogBoxContent: {
|
|
41
|
+
title: 'Decreasing Max Points.',
|
|
42
|
+
text: " You are about to decrease max score point value.\n <br/>\n All the Labels and Descriptions for scores above Max Point will be deleted."
|
|
43
|
+
},
|
|
44
|
+
spellCheck: {
|
|
45
|
+
label: 'Spellcheck',
|
|
46
|
+
settings: false,
|
|
47
|
+
enabled: true
|
|
48
|
+
},
|
|
49
|
+
showExcludeZero: {
|
|
50
|
+
settings: true,
|
|
51
|
+
label: 'Exclude Zero'
|
|
52
|
+
},
|
|
53
|
+
showScorePointLabels: {
|
|
54
|
+
settings: true,
|
|
55
|
+
label: 'Show Score Point Labels'
|
|
56
|
+
},
|
|
57
|
+
showDescription: {
|
|
58
|
+
settings: true,
|
|
59
|
+
label: 'Show Description'
|
|
60
|
+
},
|
|
61
|
+
showVisibleToStudent: {
|
|
62
|
+
settings: true,
|
|
63
|
+
label: 'Visible to Student'
|
|
64
|
+
},
|
|
65
|
+
showHalfScoring: {
|
|
66
|
+
settings: true,
|
|
67
|
+
label: 'Half Scoring'
|
|
68
|
+
},
|
|
69
|
+
width: '900px',
|
|
70
|
+
// these should not be set to true (should not be used) for now
|
|
71
|
+
showStandards: {
|
|
72
|
+
settings: false,
|
|
73
|
+
label: 'Show Standards'
|
|
74
|
+
},
|
|
75
|
+
showLevelTagInput: {
|
|
76
|
+
settings: false,
|
|
77
|
+
label: 'Show Level Tag Input',
|
|
78
|
+
enabled: false
|
|
79
|
+
},
|
|
80
|
+
dragAndDrop: {
|
|
81
|
+
settings: true,
|
|
82
|
+
label: 'Enable Drag and Drop',
|
|
83
|
+
enabled: false
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var _default = {
|
|
87
|
+
model: {
|
|
88
|
+
rubricType: 'simpleRubric',
|
|
89
|
+
rubrics: {
|
|
90
|
+
simpleRubric: rubricDefaultModel,
|
|
91
|
+
multiTraitRubric: multiTraitDefaultModel
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
configuration: {
|
|
95
|
+
multiTraitRubric: multiTraitDefaultConfiguration
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports["default"] = _default;
|
|
99
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["multiTraitDefaultModel","visibleToStudent","halfScoring","pointLabels","description","standards","scales","excludeZero","rubricDefaultModel","points","sampleAnswers","maxPoints","multiTraitDefaultConfiguration","settingsPanelDisabled","excludeZeroDialogBoxContent","title","text","includeZeroDialogBoxContent","deleteTraitDialogBoxContent","deleteScaleDialogBoxContent","maxPointsDialogBoxContent","spellCheck","label","settings","enabled","showExcludeZero","showScorePointLabels","showDescription","showVisibleToStudent","showHalfScoring","width","showStandards","showLevelTagInput","dragAndDrop","model","rubricType","rubrics","simpleRubric","multiTraitRubric","configuration"],"mappings":";;;;;;AAAA,IAAMA,sBAAsB,GAAG;AAC7BC,EAAAA,gBAAgB,EAAE,IADW;AAE7BC,EAAAA,WAAW,EAAE,KAFgB;AAG7BC,EAAAA,WAAW,EAAE,IAHgB;AAI7BC,EAAAA,WAAW,EAAE,KAJgB;AAK7BC,EAAAA,SAAS,EAAE,KALkB;AAM7BC,EAAAA,MAAM,EAAE,EANqB;AAO7BC,EAAAA,WAAW,EAAE;AAPgB,CAA/B;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,IAAAA,QAAQ,EAAE,IADK;AAEfD,IAAAA,KAAK,EAAE;AAFQ,GAjEoB;AAqErCM,EAAAA,oBAAoB,EAAE;AACpBL,IAAAA,QAAQ,EAAE,IADU;AAEpBD,IAAAA,KAAK,EAAE;AAFa,GArEe;AAyErCO,EAAAA,eAAe,EAAE;AACfN,IAAAA,QAAQ,EAAE,IADK;AAEfD,IAAAA,KAAK,EAAE;AAFQ,GAzEoB;AA6ErCQ,EAAAA,KAAK,EAAE,OA7E8B;AA8ErC;AACAC,EAAAA,aAAa,EAAE;AACbR,IAAAA,QAAQ,EAAE,KADG;AAEbD,IAAAA,KAAK,EAAE;AAFM,GA/EsB;AAmFrCU,EAAAA,iBAAiB,EAAE;AACjBT,IAAAA,QAAQ,EAAE,KADO;AAEjBD,IAAAA,KAAK,EAAE,sBAFU;AAGjBE,IAAAA,OAAO,EAAE;AAHQ,GAnFkB;AAwFrCS,EAAAA,WAAW,EAAE;AACXV,IAAAA,QAAQ,EAAE,IADC;AAEXD,IAAAA,KAAK,EAAE,sBAFI;AAGXE,IAAAA,OAAO,EAAE;AAHE;AAxFwB,CAAvC;eA+Fe;AACbU,EAAAA,KAAK,EAAE;AACLC,IAAAA,UAAU,EAAE,cADP;AAELC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,YAAY,EAAE7B,kBAAhB;AAAoC8B,MAAAA,gBAAgB,EAAEtC;AAAtD;AAFJ,GADM;AAKbuC,EAAAA,aAAa,EAAE;AACbD,IAAAA,gBAAgB,EAAE1B;AADL;AALF,C","sourcesContent":["const multiTraitDefaultModel = {\n visibleToStudent: true,\n halfScoring: false,\n pointLabels: true,\n description: false,\n standards: false,\n scales: [],\n excludeZero: false,\n};\n\nconst rubricDefaultModel = {\n points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],\n sampleAnswers: [null, 'just right', 'not left', null],\n maxPoints: 4,\n excludeZero: false\n};\n\nconst multiTraitDefaultConfiguration = {\n settingsPanelDisabled: true,\n excludeZeroDialogBoxContent: {\n title: 'Exclude 0 (Zero) from Score Point Values.',\n text: `<div>\n You are about to exclude 0 from score point values.\n <br/>\n Some of the existing data has to be changed.\n <br/>\n Please choose if you want to:\n <ul>\n <li>\n shift Labels and Descriptions to the left\n </li>\n <li>\n remove 0 column with its Label and Description\n </li>\n </ul>\n </div>`\n },\n includeZeroDialogBoxContent: {\n title: 'Include 0 (Zero) in Score Point Values.',\n text: `<div>\n You are about to include 0 in score point values.\n <br/>\n Some of the existing data has to be changed.\n <br/>\n Please choose if you want to:\n <ul>\n <li>\n shift Labels and Descriptions to the right\n </li>\n <li>\n add 0 column with empty Label and Descriptions\n </li>\n </ul>\n </div>`\n },\n deleteTraitDialogBoxContent: {\n title: 'Delete Trait',\n text: 'Are you sure you want to delete this trait?'\n },\n deleteScaleDialogBoxContent: {\n title: 'Delete Scale',\n text: 'Are you sure you want to delete this scale?'\n },\n maxPointsDialogBoxContent: {\n title: 'Decreasing Max Points.',\n text: ` You are about to decrease max score point value.\n <br/>\n All the Labels and Descriptions for scores above Max Point will be deleted.`\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true\n },\n showExcludeZero: {\n settings: true,\n label: 'Exclude Zero',\n },\n showScorePointLabels: {\n settings: true,\n label: 'Show Score Point Labels',\n },\n showDescription: {\n settings: true,\n label: 'Show Description',\n },\n showVisibleToStudent: {\n settings: true,\n label: 'Visible to Student',\n },\n showHalfScoring: {\n settings: true,\n label: 'Half Scoring',\n },\n width: '900px',\n // these should not be set to true (should not be used) for now\n showStandards: {\n settings: false,\n label: 'Show Standards',\n },\n showLevelTagInput: {\n settings: false,\n label: 'Show Level Tag Input',\n enabled: false\n },\n dragAndDrop: {\n settings: true,\n label: 'Enable Drag and Drop',\n enabled: false,\n }\n};\n\nexport default {\n model: {\n rubricType: 'simpleRubric',\n rubrics: { simpleRubric: rubricDefaultModel, multiTraitRubric: multiTraitDefaultModel }\n },\n configuration: {\n multiTraitRubric: multiTraitDefaultConfiguration\n }\n};\n"],"file":"defaults.js"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createCorrectResponseSession = void 0;
|
|
9
|
+
exports.createDefaultModel = createDefaultModel;
|
|
10
|
+
exports.getScore = void 0;
|
|
11
|
+
exports.model = model;
|
|
12
|
+
exports.normalize = void 0;
|
|
13
|
+
exports.outcome = outcome;
|
|
14
|
+
|
|
15
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
|
+
|
|
17
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
+
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
|
+
|
|
21
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
22
|
+
|
|
23
|
+
var _rubric = require("@pie-lib/rubric");
|
|
24
|
+
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
|
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
28
|
+
|
|
29
|
+
function createDefaultModel() {
|
|
30
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
|
+
return new Promise(function (resolve) {
|
|
32
|
+
return resolve(_objectSpread(_objectSpread({}, _defaults["default"].model), model));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var normalize = function normalize(question) {
|
|
37
|
+
return _objectSpread(_objectSpread({}, _defaults["default"].model), question);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {*} question
|
|
42
|
+
* @param {*} session
|
|
43
|
+
* @param {*} env
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
exports.normalize = normalize;
|
|
48
|
+
|
|
49
|
+
function model(_x, _x2, _x3) {
|
|
50
|
+
return _model.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _model() {
|
|
54
|
+
_model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env) {
|
|
55
|
+
var normalizedQuestion, _ref, scales, excludeZero, parsedScales;
|
|
56
|
+
|
|
57
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
58
|
+
while (1) {
|
|
59
|
+
switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
normalizedQuestion = normalize(question);
|
|
62
|
+
|
|
63
|
+
if (!(normalizedQuestion.rubricType === _rubric.RUBRIC_TYPES.SIMPLE_RUBRIC)) {
|
|
64
|
+
_context.next = 5;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return _context.abrupt("return", new Promise(function (resolve) {
|
|
69
|
+
resolve(env && env.role && env.role === 'instructor' ? _objectSpread(_objectSpread({}, normalizedQuestion), {}, {
|
|
70
|
+
rubrics: _objectSpread(_objectSpread({}, normalizedQuestion.rubrics), {}, {
|
|
71
|
+
multiTraitRubric: _objectSpread(_objectSpread({}, normalizedQuestion.rubrics.multiTraitRubric), {}, {
|
|
72
|
+
visible: false
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}) : {});
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
case 5:
|
|
79
|
+
if (!env.role || env.role === 'student' && normalizedQuestion.rubrics && normalizedQuestion.rubrics.multiTraitRubric) {
|
|
80
|
+
normalizedQuestion.rubrics.multiTraitRubric.visible = normalizedQuestion.visibleToStudent;
|
|
81
|
+
} else {
|
|
82
|
+
normalizedQuestion.rubrics.multiTraitRubric.visible = true;
|
|
83
|
+
} // todo update pie-ui instead of parsing this here:
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
_ref = normalizedQuestion.rubrics.multiTraitRubric || {}, scales = _ref.scales, excludeZero = _ref.excludeZero;
|
|
87
|
+
parsedScales = (scales || []).map(function (scale) {
|
|
88
|
+
return _objectSpread(_objectSpread({}, scale), {}, {
|
|
89
|
+
excludeZero: excludeZero
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, normalizedQuestion), {}, {
|
|
93
|
+
rubrics: _objectSpread(_objectSpread({}, normalizedQuestion.rubrics), {}, {
|
|
94
|
+
simpleRubric: _objectSpread(_objectSpread({}, normalizedQuestion.rubrics.simpleRubric), {}, {
|
|
95
|
+
visible: false
|
|
96
|
+
}),
|
|
97
|
+
multiTraitRubric: _objectSpread(_objectSpread({}, normalizedQuestion.rubrics.multiTraitRubric), {}, {
|
|
98
|
+
scales: parsedScales
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
case 9:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context.stop();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
}));
|
|
110
|
+
return _model.apply(this, arguments);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var getScore = function getScore() {
|
|
114
|
+
return 0;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* @param {Object} model - the main model
|
|
118
|
+
* @param {*} session
|
|
119
|
+
* @param {Object} env
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
exports.getScore = getScore;
|
|
124
|
+
|
|
125
|
+
function outcome(model, session, env) {
|
|
126
|
+
return new Promise(function (resolve) {
|
|
127
|
+
return resolve({
|
|
128
|
+
score: 0,
|
|
129
|
+
empty: true
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
|
|
135
|
+
return new Promise(function (resolve) {
|
|
136
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
137
|
+
resolve({
|
|
138
|
+
id: '1'
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
resolve(null);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
147
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["createDefaultModel","model","Promise","resolve","defaults","normalize","question","session","env","normalizedQuestion","rubricType","RUBRIC_TYPES","SIMPLE_RUBRIC","role","rubrics","multiTraitRubric","visible","visibleToStudent","scales","excludeZero","parsedScales","map","scale","simpleRubric","getScore","outcome","score","empty","createCorrectResponseSession","mode","id"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,SAASA,kBAAT,GAAwC;AAAA,MAAZC,KAAY,uEAAJ,EAAI;AAC7C,SAAO,IAAIC,OAAJ,CAAY,UAAAC,OAAO;AAAA,WAAIA,OAAO,iCAAMC,qBAASH,KAAf,GAAyBA,KAAzB,EAAX;AAAA,GAAnB,CAAP;AACD;;AAEM,IAAMI,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AAAA,yCAAUF,qBA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["import defaults from './defaults';\nimport { RUBRIC_TYPES } from '@pie-lib/rubric';\n\nexport function createDefaultModel(model = {}) {\n return new Promise(resolve => resolve({ ...defaults.model, ...model }));\n}\n\nexport const normalize = question => ({ ...defaults.model, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n\n if (normalizedQuestion.rubricType === RUBRIC_TYPES.SIMPLE_RUBRIC) {\n return new Promise(resolve => {\n resolve((env && env.role && env.role === 'instructor') ?\n {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n visible: false\n }\n }\n }\n : {});\n });\n } else {\n if (!env.role || env.role === 'student' && normalizedQuestion.rubrics && normalizedQuestion.rubrics.multiTraitRubric) {\n normalizedQuestion.rubrics.multiTraitRubric.visible = normalizedQuestion.visibleToStudent;\n } else {\n normalizedQuestion.rubrics.multiTraitRubric.visible = true;\n }\n\n // todo update pie-ui instead of parsing this here:\n const { scales, excludeZero } = normalizedQuestion.rubrics.multiTraitRubric || {};\n const parsedScales = (scales || []).map(scale => ({ ...scale, excludeZero }));\n\n return {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n simpleRubric: {\n ...normalizedQuestion.rubrics.simpleRubric,\n visible: false\n },\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n scales: parsedScales\n }\n }\n };\n }\n}\n\nexport const getScore = () => 0;\n\n/**\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise(resolve => resolve({ score: 0, empty: true }));\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({ id: '1' });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { model } from '../index';
|
|
2
|
+
import defaultModel from '../defaults';
|
|
3
|
+
|
|
4
|
+
jest.mock('@pie-lib/rubric', () => ({
|
|
5
|
+
RUBRIC_TYPES: {
|
|
6
|
+
SIMPLE_RUBRIC: 'simpleRubric',
|
|
7
|
+
MULTI_TRAIT_RUBRIC: 'multiTraitRubric'
|
|
8
|
+
}
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
describe('complex rubric model', () => {
|
|
12
|
+
let state = { ...defaultModel.model };
|
|
13
|
+
let session = {};
|
|
14
|
+
let env, result;
|
|
15
|
+
|
|
16
|
+
it('returns no model for gather', async () => {
|
|
17
|
+
env = { mode: 'gather' };
|
|
18
|
+
result = await model(state, session, env);
|
|
19
|
+
expect(result).toEqual({});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns no model for student role', async () => {
|
|
23
|
+
env = { mode: 'gather', role: 'student' };
|
|
24
|
+
result = await model(state, session, env);
|
|
25
|
+
expect(result).toEqual({});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('returns model for instructor role and simple rubric', async () => {
|
|
29
|
+
env = { mode: 'gather', role: 'instructor' };
|
|
30
|
+
result = await model(state, session, env);
|
|
31
|
+
expect(result).toEqual({
|
|
32
|
+
...state,
|
|
33
|
+
rubrics: {
|
|
34
|
+
...state.rubrics,
|
|
35
|
+
multiTraitRubric: {
|
|
36
|
+
...state.rubrics.multiTraitRubric,
|
|
37
|
+
visible: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('returns model for instructor role and multi trait rubric', async () => {
|
|
44
|
+
env = { mode: 'gather', role: 'instructor' };
|
|
45
|
+
result = await model({ ...state, rubricType: 'multiTraitRubric' }, session, env);
|
|
46
|
+
expect(result).toEqual({
|
|
47
|
+
...state,
|
|
48
|
+
rubricType: 'multiTraitRubric',
|
|
49
|
+
rubrics: {
|
|
50
|
+
...state.rubrics,
|
|
51
|
+
simpleRubric: {
|
|
52
|
+
...state.rubrics.simpleRubric,
|
|
53
|
+
visible: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|