@pie-element/complex-rubric 7.1.2-next.1 → 7.1.2
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 +1449 -0
- package/LICENSE.md +5 -0
- package/README.md +3 -0
- package/configure/CHANGELOG.md +1103 -0
- package/configure/lib/defaults.js +271 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +150 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +172 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/package.json +27 -0
- package/configure/src/__tests__/index.test.js +94 -0
- package/configure/src/__tests__/main.test.jsx +140 -0
- package/configure/src/defaults.js +213 -0
- package/configure/src/index.js +169 -0
- package/configure/src/main.jsx +162 -0
- package/controller/CHANGELOG.md +936 -0
- package/controller/lib/defaults.js +42 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +239 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +11 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +16 -0
- package/controller/src/__tests__/index.test.js +55 -0
- package/controller/src/defaults.js +39 -0
- package/controller/src/index.js +220 -0
- package/controller/src/utils.js +3 -0
- package/docs/config-schema.json +4255 -0
- package/docs/config-schema.json.md +3162 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +196 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +3302 -0
- package/docs/pie-schema.json.md +2364 -0
- package/lib/index.js +141 -0
- package/lib/index.js.map +1 -0
- package/lib/print.js +129 -0
- package/lib/print.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +262 -0
- package/module/demo.js +221 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +22 -0
- package/module/print-demo.js +259 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +22 -90
- package/src/__tests__/index.test.js +256 -0
- package/src/index.js +152 -0
- package/src/print.js +140 -0
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaults.d.ts +0 -231
- package/dist/author/defaults.js +0 -177
- package/dist/author/index.d.ts +0 -34
- package/dist/author/index.js +0 -87
- package/dist/author/main.d.ts +0 -23
- package/dist/author/main.js +0 -106
- package/dist/browser/author/index.js +0 -7384
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -145
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -96
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-DJUOd5EZ.js +0 -19
- package/dist/browser/dist-DJUOd5EZ.js.map +0 -1
- package/dist/browser/print/index.js +0 -84
- package/dist/browser/print/index.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -39
- package/dist/controller/defaults.js +0 -42
- package/dist/controller/index.d.ts +0 -25
- package/dist/controller/index.js +0 -107
- package/dist/controller/utils.d.ts +0 -9
- package/dist/controller/utils.js +0 -4
- package/dist/delivery/index.d.ts +0 -23
- package/dist/delivery/index.js +0 -96
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -145
- package/dist/index.js +0 -2
- package/dist/print/index.d.ts +0 -24
- package/dist/print/index.js +0 -84
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
jest.mock('@pie-element/rubric', () => {
|
|
2
|
+
class MockRubric {
|
|
3
|
+
constructor() {}
|
|
4
|
+
}
|
|
5
|
+
return MockRubric;
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
jest.mock('@pie-element/multi-trait-rubric', () => {
|
|
9
|
+
class MockMultiTraitRubric {
|
|
10
|
+
constructor() {}
|
|
11
|
+
}
|
|
12
|
+
return MockMultiTraitRubric;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
jest.mock('@pie-lib/rubric', () => ({
|
|
16
|
+
RUBRIC_TYPES: {
|
|
17
|
+
SIMPLE_RUBRIC: 'simpleRubric',
|
|
18
|
+
MULTI_TRAIT_RUBRIC: 'multiTraitRubric',
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const defaultModel = {
|
|
23
|
+
rubricType: 'simpleRubric',
|
|
24
|
+
rubrics: {
|
|
25
|
+
simpleRubric: {
|
|
26
|
+
points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
|
|
27
|
+
sampleAnswers: [null, 'just right', 'not left', null],
|
|
28
|
+
maxPoints: 4,
|
|
29
|
+
excludeZero: false,
|
|
30
|
+
},
|
|
31
|
+
multiTraitRubric: {
|
|
32
|
+
visibleToStudent: true,
|
|
33
|
+
halfScoring: false,
|
|
34
|
+
excludeZero: true,
|
|
35
|
+
pointLabels: true,
|
|
36
|
+
description: false,
|
|
37
|
+
standards: false,
|
|
38
|
+
scales: [
|
|
39
|
+
{
|
|
40
|
+
maxPoints: 4,
|
|
41
|
+
scorePointsLabels: ['Non-Scorable', 'Developing', 'Progressing', 'Effective', 'Strong'],
|
|
42
|
+
traitLabel: 'Trait',
|
|
43
|
+
traits: [
|
|
44
|
+
{
|
|
45
|
+
name: 'Ideas',
|
|
46
|
+
standards: [],
|
|
47
|
+
description: 'the main message',
|
|
48
|
+
scorePointsDescriptors: [
|
|
49
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
50
|
+
'Topic undefined and/or difficult to follow\n' + '\n' + 'Details are unclear',
|
|
51
|
+
'Topic too broad\n' + '\n' + 'Details are limited',
|
|
52
|
+
'Writing stays on topic\n' + '\n' + 'Complete details given',
|
|
53
|
+
'Strong control of topic\n' + '\n' + 'Relevant, accurate, specific details that support topic',
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Organization',
|
|
58
|
+
standards: [],
|
|
59
|
+
description: 'the internal structure of the piece',
|
|
60
|
+
scorePointsDescriptors: [
|
|
61
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
62
|
+
'Does not have a beginning, middle and/or end\n' +
|
|
63
|
+
'\n' +
|
|
64
|
+
'Does not have a lead and/or conclusion\n' +
|
|
65
|
+
'\n' +
|
|
66
|
+
'Transitions confusing and/or not present\n' +
|
|
67
|
+
'\n' +
|
|
68
|
+
'Not written in logical order\n' +
|
|
69
|
+
'\n' +
|
|
70
|
+
'No sign of paragraphing / incorrect paragraphing',
|
|
71
|
+
'Weak beginning, middle and end\n' +
|
|
72
|
+
'\n' +
|
|
73
|
+
'Has evidence of a lead and/or conclusion but missing elements\n' +
|
|
74
|
+
'\n' +
|
|
75
|
+
'Transitions are used sometimes\n' +
|
|
76
|
+
'\n' +
|
|
77
|
+
'Some logical order\n' +
|
|
78
|
+
'\n' +
|
|
79
|
+
'Most paragraphing incorrect',
|
|
80
|
+
'Has an acceptable beginning, middle and end\n' +
|
|
81
|
+
'\n' +
|
|
82
|
+
'Includes a lead and conclusion\n' +
|
|
83
|
+
'\n' +
|
|
84
|
+
'Transitions are used correctly\n' +
|
|
85
|
+
'\n' +
|
|
86
|
+
'Mostly logical order\n' +
|
|
87
|
+
'\n' +
|
|
88
|
+
'Mostly correct paragraphing',
|
|
89
|
+
'Has an effective beginning, middle and end\n' +
|
|
90
|
+
'\n' +
|
|
91
|
+
'Powerful introduction / lead and conclusion\n' +
|
|
92
|
+
'\n' +
|
|
93
|
+
'Effective transitions\n' +
|
|
94
|
+
'\n' +
|
|
95
|
+
'Logical order / sequencing\n' +
|
|
96
|
+
'\n' +
|
|
97
|
+
'Uses appropriate paragraphing',
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Word Choice',
|
|
102
|
+
standards: [],
|
|
103
|
+
description: 'the vocabulary a writer chooses to convey meaning',
|
|
104
|
+
scorePointsDescriptors: [
|
|
105
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
106
|
+
'Vocabulary is limited/used incorrectly\n' +
|
|
107
|
+
'\n' +
|
|
108
|
+
'No figurative language; words do not convey meaning',
|
|
109
|
+
'Generally correct words\n' +
|
|
110
|
+
'\n' +
|
|
111
|
+
'Attempt at figurative language\n' +
|
|
112
|
+
'\n' +
|
|
113
|
+
'and/or words convey general meaning',
|
|
114
|
+
'Some active verbs and precise nouns\n' +
|
|
115
|
+
'\n' +
|
|
116
|
+
'Effective use of figurative language and/or words that enhance meaning',
|
|
117
|
+
'Powerful and engaging words\n' + '\n' + 'Artful use of figurative language and/or sensory detail',
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'Sentence Fluency',
|
|
122
|
+
standards: [],
|
|
123
|
+
description: 'the rhythm and flow of the language',
|
|
124
|
+
scorePointsDescriptors: [
|
|
125
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
126
|
+
'No sentences are clear\n' +
|
|
127
|
+
'\n' +
|
|
128
|
+
'No variety in sentence structure\n' +
|
|
129
|
+
'\n' +
|
|
130
|
+
'Frequent run-ons and/or fragments are present',
|
|
131
|
+
'Some sentences are clear\n' +
|
|
132
|
+
'\n' +
|
|
133
|
+
'Sentence variety used rarely\n' +
|
|
134
|
+
'\n' +
|
|
135
|
+
'Some run-ons and/or fragments are present',
|
|
136
|
+
'Most sentences are clear\n' +
|
|
137
|
+
'\n' +
|
|
138
|
+
'Some sentence variety is used\n' +
|
|
139
|
+
'\n' +
|
|
140
|
+
'Run-ons and/or fragments are rare',
|
|
141
|
+
'All Sentences are clear\n' +
|
|
142
|
+
'\n' +
|
|
143
|
+
'Variety of sentence structure is used\n' +
|
|
144
|
+
'\n' +
|
|
145
|
+
'Run-ons and/or fragments are not present',
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'Conventions',
|
|
150
|
+
standards: [],
|
|
151
|
+
description: 'the mechanical correctness',
|
|
152
|
+
scorePointsDescriptors: [
|
|
153
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
154
|
+
'Many distracting errors are present in grammar, punctuation, capitalization and/or spelling',
|
|
155
|
+
'Errors in grammar, punctuation, capitalization and/or spelling are present and some distract from meaning',
|
|
156
|
+
'Errors in grammar, punctuation, capitalization and/or spelling are present but don’t distract from meaning',
|
|
157
|
+
'Few errors in grammar, punctuation,\n' + '\n' + 'capitalization and/or spelling',
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'Voice',
|
|
162
|
+
standards: [],
|
|
163
|
+
description: "the personal tone and flavor of the author's message",
|
|
164
|
+
scorePointsDescriptors: [
|
|
165
|
+
'Student’s response is blank, not in English, not legible, or does not respond to the prompt.',
|
|
166
|
+
'Not concerned with audience or purpose\n' +
|
|
167
|
+
'\n' +
|
|
168
|
+
'No viewpoint (perspective) used\n' +
|
|
169
|
+
'\n' +
|
|
170
|
+
'Writing is mechanical and lifeless',
|
|
171
|
+
'Shows beginning awareness of audience/purpose\n' +
|
|
172
|
+
'\n' +
|
|
173
|
+
'Some viewpoint (perspective) used throughout the piece\n' +
|
|
174
|
+
'\n' +
|
|
175
|
+
'Writing is distant, too formal or informal',
|
|
176
|
+
'Awareness of audience; purpose is clear most of the time\n' +
|
|
177
|
+
'\n' +
|
|
178
|
+
'Uses viewpoint (perspective) throughout most of the paper\n' +
|
|
179
|
+
'\n' +
|
|
180
|
+
'Writing is pleasant, agreeable and satisfying',
|
|
181
|
+
'Powerful connection with audience; purpose is clearly communicated\n' +
|
|
182
|
+
'\n' +
|
|
183
|
+
'Maintains strong viewpoint (perspective) throughout entire piece\n' +
|
|
184
|
+
'\n' +
|
|
185
|
+
'Writing is expressive, engaging and has lots of energy',
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
maxPoints: 5,
|
|
192
|
+
scorePointsLabels: ['Non-Scorable', 'Unsatisfactory', 'Satisfactory'],
|
|
193
|
+
traitLabel: 'Category',
|
|
194
|
+
traits: [
|
|
195
|
+
{
|
|
196
|
+
name: 'Presentation',
|
|
197
|
+
standards: [],
|
|
198
|
+
description: '',
|
|
199
|
+
scorePointsDescriptors: [
|
|
200
|
+
'Handwriting is unreadable, or response is blank, not in English, or too brief to evaluate. ',
|
|
201
|
+
'Handwriting poor\n' + '\n' + 'Overall appearance is distracting to unacceptable',
|
|
202
|
+
'Handwriting is generally legible\n' + '\n' + 'Overall appearance is acceptable or better',
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
describe('complex-rubric', () => {
|
|
213
|
+
let Def;
|
|
214
|
+
let el;
|
|
215
|
+
let complexRubric;
|
|
216
|
+
|
|
217
|
+
beforeAll(() => {
|
|
218
|
+
Def = require('../index').default;
|
|
219
|
+
// Register the custom element for testing
|
|
220
|
+
if (!customElements.get('complex-rubric-test')) {
|
|
221
|
+
customElements.define('complex-rubric-test', Def);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
beforeEach(() => {
|
|
226
|
+
el = document.createElement('complex-rubric-test');
|
|
227
|
+
|
|
228
|
+
// Mock _render to avoid innerHTML issues in jsdom
|
|
229
|
+
el._render = jest.fn();
|
|
230
|
+
|
|
231
|
+
complexRubric = {
|
|
232
|
+
simpleRubric: document.createElement('div'),
|
|
233
|
+
multiTraitRubric: document.createElement('div'),
|
|
234
|
+
};
|
|
235
|
+
el.querySelector = jest.fn((s) => {
|
|
236
|
+
if (s === '#simpleRubric') {
|
|
237
|
+
return complexRubric.simpleRubric;
|
|
238
|
+
} else {
|
|
239
|
+
return complexRubric.multiTraitRubric;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
el.model = defaultModel;
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe('model', () => {
|
|
246
|
+
it('should have set the model', () => {
|
|
247
|
+
expect(el._model).toEqual(defaultModel);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('sets rubric type', () => {
|
|
251
|
+
expect(el._type).toEqual('simpleRubric');
|
|
252
|
+
el.model = { ...el._model, rubricType: 'multiTraitRubric' };
|
|
253
|
+
expect(el._type).toEqual('multiTraitRubric');
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|
package/src/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import Rubric from '@pie-element/rubric';
|
|
2
|
+
import MultiTraitRubric from '@pie-element/multi-trait-rubric';
|
|
3
|
+
import { RUBRIC_TYPES } from '@pie-lib/rubric';
|
|
4
|
+
|
|
5
|
+
const RUBRIC_TAG_NAME = 'complex-rubric-simple';
|
|
6
|
+
const MULTI_TRAIT_RUBRIC_TAG_NAME = 'complex-rubric-multi-trait';
|
|
7
|
+
|
|
8
|
+
class ComplexRubricSimple extends Rubric {}
|
|
9
|
+
|
|
10
|
+
class ComplexRubricMultiTrait extends MultiTraitRubric {}
|
|
11
|
+
|
|
12
|
+
const defineRubrics = () => {
|
|
13
|
+
if (!customElements.get(RUBRIC_TAG_NAME)) {
|
|
14
|
+
customElements.define(RUBRIC_TAG_NAME, ComplexRubricSimple);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!customElements.get(MULTI_TRAIT_RUBRIC_TAG_NAME)) {
|
|
18
|
+
customElements.define(MULTI_TRAIT_RUBRIC_TAG_NAME, ComplexRubricMultiTrait);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
defineRubrics();
|
|
23
|
+
|
|
24
|
+
class ComplexRubric extends HTMLElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this._model = {};
|
|
28
|
+
this._type = RUBRIC_TYPES.SIMPLE_RUBRIC;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set type(t) {
|
|
32
|
+
this._type = t;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get type() {
|
|
36
|
+
return this._type;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set model(m) {
|
|
40
|
+
this._model = m;
|
|
41
|
+
const oldType = this._type;
|
|
42
|
+
this.type = m.rubricType;
|
|
43
|
+
|
|
44
|
+
switch (this._type) {
|
|
45
|
+
case RUBRIC_TYPES.SIMPLE_RUBRIC:
|
|
46
|
+
default:
|
|
47
|
+
customElements.whenDefined(RUBRIC_TAG_NAME).then(() => {
|
|
48
|
+
this.setRubricModel(this.simpleRubric);
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:
|
|
52
|
+
customElements.whenDefined(MULTI_TRAIT_RUBRIC_TAG_NAME).then(() => {
|
|
53
|
+
this.setMultiTraitRubricModel(this.multiTraitRubric);
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
case RUBRIC_TYPES.RUBRICLESS:
|
|
57
|
+
customElements.whenDefined(RUBRIC_TAG_NAME).then(() => {
|
|
58
|
+
this.setRubriclessModel(this.rubricless);
|
|
59
|
+
});
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (oldType !== this.type) {
|
|
64
|
+
this._render();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setRubricModel(simpleRubric) {
|
|
69
|
+
if (this._model && this._model.rubrics && this._model.rubrics.simpleRubric) {
|
|
70
|
+
const { mode } = this._model;
|
|
71
|
+
|
|
72
|
+
simpleRubric.model = {
|
|
73
|
+
...this._model.rubrics.simpleRubric,
|
|
74
|
+
mode,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setMultiTraitRubricModel(multiTraitRubric) {
|
|
80
|
+
if (this._model && this._model.rubrics && this._model.rubrics.multiTraitRubric) {
|
|
81
|
+
const { mode } = this._model;
|
|
82
|
+
|
|
83
|
+
multiTraitRubric.model = {
|
|
84
|
+
...this._model.rubrics.multiTraitRubric,
|
|
85
|
+
mode,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setRubriclessModel(rubricless) {
|
|
91
|
+
if (this._model && this._model.rubrics && this._model.rubrics.rubricless) {
|
|
92
|
+
const { mode } = this._model;
|
|
93
|
+
|
|
94
|
+
rubricless.model = {
|
|
95
|
+
...this._model.rubrics.rubricless,
|
|
96
|
+
mode,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get multiTraitRubric() {
|
|
102
|
+
return this.querySelector(`${MULTI_TRAIT_RUBRIC_TAG_NAME}#multiTraitRubric`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get simpleRubric() {
|
|
106
|
+
return this.querySelector(`${RUBRIC_TAG_NAME}#simpleRubric`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get rubricless() {
|
|
110
|
+
return this.querySelector(`${RUBRIC_TAG_NAME}#rubricless`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
connectedCallback() {
|
|
114
|
+
this._render();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
_render() {
|
|
118
|
+
let rubricTag;
|
|
119
|
+
if (this._type === RUBRIC_TYPES.SIMPLE_RUBRIC) {
|
|
120
|
+
rubricTag = `<${RUBRIC_TAG_NAME} id="simpleRubric" />`;
|
|
121
|
+
} else if (this._type === RUBRIC_TYPES.RUBRICLESS) {
|
|
122
|
+
rubricTag = `<${RUBRIC_TAG_NAME} id="rubricless" />`;
|
|
123
|
+
} else {
|
|
124
|
+
rubricTag = `<${MULTI_TRAIT_RUBRIC_TAG_NAME} id="multiTraitRubric" />`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.innerHTML = rubricTag;
|
|
128
|
+
|
|
129
|
+
// when item is re-rendered (due to connectedCallback), if the custom element is already defined,
|
|
130
|
+
// we need to set the model and session, otherwise the setters are not reached again
|
|
131
|
+
switch (this._type) {
|
|
132
|
+
case RUBRIC_TYPES.SIMPLE_RUBRIC:
|
|
133
|
+
default:
|
|
134
|
+
if (customElements.get(RUBRIC_TAG_NAME)) {
|
|
135
|
+
this.setRubricModel(this.simpleRubric);
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:
|
|
139
|
+
if (customElements.get(MULTI_TRAIT_RUBRIC_TAG_NAME)) {
|
|
140
|
+
this.setMultiTraitRubricModel(this.multiTraitRubric);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case RUBRIC_TYPES.RUBRICLESS:
|
|
144
|
+
if (customElements.get(RUBRIC_TAG_NAME)) {
|
|
145
|
+
this.setRubriclessModel(this.rubricless);
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default ComplexRubric;
|
package/src/print.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// here it is actually using rubric/src/index.js, instead of using rubric/src/print.js
|
|
2
|
+
import Rubric from '@pie-element/rubric';
|
|
3
|
+
// here it is actually using multi-trait-rubric/src/index.js, instead of using multi-trait-rubric/src/print.js
|
|
4
|
+
import MultiTraitRubric from '@pie-element/multi-trait-rubric';
|
|
5
|
+
import { RUBRIC_TYPES } from '@pie-lib/rubric';
|
|
6
|
+
|
|
7
|
+
const RUBRIC_TAG_NAME = 'complex-rubric-simple';
|
|
8
|
+
const MULTI_TRAIT_RUBRIC_TAG_NAME = 'complex-rubric-multi-trait';
|
|
9
|
+
|
|
10
|
+
class ComplexRubricSimple extends Rubric {}
|
|
11
|
+
class ComplexRubricMultiTrait extends MultiTraitRubric {}
|
|
12
|
+
|
|
13
|
+
const rubricTags = {
|
|
14
|
+
[RUBRIC_TYPES.SIMPLE_RUBRIC]: `<${RUBRIC_TAG_NAME} id="simpleRubric" />`,
|
|
15
|
+
[RUBRIC_TYPES.RUBRICLESS]: `<${RUBRIC_TAG_NAME} id="rubricless" />`,
|
|
16
|
+
[RUBRIC_TYPES.MULTI_TRAIT_RUBRIC]: `<${MULTI_TRAIT_RUBRIC_TAG_NAME} id="multiTraitRubric" />`,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const preparePrintModel = (model, opts) => {
|
|
20
|
+
const instr = opts.role === 'instructor';
|
|
21
|
+
|
|
22
|
+
if (!instr) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
model.mode = 'evaluate';
|
|
27
|
+
model.animationsDisabled = true;
|
|
28
|
+
|
|
29
|
+
return model;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const defineRubrics = () => {
|
|
33
|
+
if (!customElements.get(RUBRIC_TAG_NAME)) {
|
|
34
|
+
customElements.define(RUBRIC_TAG_NAME, ComplexRubricSimple);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!customElements.get(MULTI_TRAIT_RUBRIC_TAG_NAME)) {
|
|
38
|
+
customElements.define(MULTI_TRAIT_RUBRIC_TAG_NAME, ComplexRubricMultiTrait);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
defineRubrics();
|
|
43
|
+
|
|
44
|
+
class ComplexRubricPrint extends HTMLElement {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this._model = {};
|
|
48
|
+
this._type = RUBRIC_TYPES.SIMPLE_RUBRIC;
|
|
49
|
+
this._options = null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
set type(t) {
|
|
53
|
+
this._type = t;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get type() {
|
|
57
|
+
return this._type;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
set model(m) {
|
|
61
|
+
this._model = m;
|
|
62
|
+
const oldType = this._type;
|
|
63
|
+
this.type = m.rubricType;
|
|
64
|
+
|
|
65
|
+
switch (this._type) {
|
|
66
|
+
case RUBRIC_TYPES.SIMPLE_RUBRIC:
|
|
67
|
+
default:
|
|
68
|
+
customElements.whenDefined(RUBRIC_TAG_NAME).then(() => {
|
|
69
|
+
this.setRubricModel(this.simpleRubric);
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:
|
|
73
|
+
customElements.whenDefined(MULTI_TRAIT_RUBRIC_TAG_NAME).then(() => {
|
|
74
|
+
this.setMultiTraitRubricModel(this.multiTraitRubric);
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
case RUBRIC_TYPES.RUBRICLESS:
|
|
78
|
+
customElements.whenDefined(RUBRIC_TAG_NAME).then(() => {
|
|
79
|
+
this.setRubriclessModel(this.rubricless);
|
|
80
|
+
});
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (oldType !== this.type) {
|
|
85
|
+
this._render();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setRubricModel(simpleRubric) {
|
|
90
|
+
if (this._model && this._model.rubrics && this._model.rubrics.simpleRubric) {
|
|
91
|
+
simpleRubric.model = preparePrintModel(this._model.rubrics.simpleRubric, this._options);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setMultiTraitRubricModel(multiTraitRubric) {
|
|
96
|
+
if (this._model && this._model.rubrics && this._model.rubrics.multiTraitRubric) {
|
|
97
|
+
const { scales, excludeZero } = this._model.rubrics.multiTraitRubric || {};
|
|
98
|
+
const parsedScales = (scales || []).map((scale) => ({ ...scale, excludeZero }));
|
|
99
|
+
|
|
100
|
+
multiTraitRubric.model = {
|
|
101
|
+
...preparePrintModel(this._model.rubrics.multiTraitRubric, this._options),
|
|
102
|
+
visible: true,
|
|
103
|
+
arrowsDisabled: true,
|
|
104
|
+
scales: parsedScales,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setRubriclessModel(rubricless) {
|
|
110
|
+
if (this._model && this._model.rubrics && this._model.rubrics.rubricless) {
|
|
111
|
+
rubricless.model = preparePrintModel(this._model.rubrics.rubricless, this._options);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
set options(o) {
|
|
116
|
+
this._options = o;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get multiTraitRubric() {
|
|
120
|
+
return this.querySelector(`${MULTI_TRAIT_RUBRIC_TAG_NAME}#multiTraitRubric`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get simpleRubric() {
|
|
124
|
+
return this.querySelector(`${RUBRIC_TAG_NAME}#simpleRubric`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get rubricless() {
|
|
128
|
+
return this.querySelector(`${RUBRIC_TAG_NAME}#rubricless`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
connectedCallback() {
|
|
132
|
+
this._render();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_render() {
|
|
136
|
+
this.innerHTML = rubricTags[this._type] || '';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default ComplexRubricPrint;
|
package/configure.js
DELETED
package/controller.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/controller/index.js';
|