@pie-element/rubric 8.2.2-beta.6 → 8.2.2-beta.7
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 +4 -0
- package/configure/CHANGELOG.md +4 -0
- package/configure/lib/defaults.js +70 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +136 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +103 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +4 -0
- package/controller/lib/defaults.js +15 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +46 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +93 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +208 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +71 -0
- package/lib/print.js.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.2.2-beta.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric@8.2.2-beta.6...@pie-element/rubric@8.2.2-beta.7) (2026-09-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/rubric
|
|
9
|
+
|
|
6
10
|
## [8.2.2-beta.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric@8.2.2-beta.5...@pie-element/rubric@8.2.2-beta.6) (2026-09-24)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @pie-element/rubric
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-configure@7.4.0-beta.12...@pie-element/rubric-configure@7.4.0-beta.13) (2026-09-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/rubric-configure
|
|
9
|
+
|
|
6
10
|
# [7.4.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-configure@7.4.0-beta.11...@pie-element/rubric-configure@7.4.0-beta.12) (2026-09-24)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @pie-element/rubric-configure
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
model: {
|
|
9
|
+
points: ['', '', '', ''],
|
|
10
|
+
sampleAnswers: [null, null, null, null],
|
|
11
|
+
maxPoints: 3,
|
|
12
|
+
excludeZero: false,
|
|
13
|
+
excludeZeroEnabled: true,
|
|
14
|
+
maxPointsEnabled: true
|
|
15
|
+
},
|
|
16
|
+
configuration: {
|
|
17
|
+
baseInputConfiguration: {
|
|
18
|
+
h3: {
|
|
19
|
+
disabled: true
|
|
20
|
+
},
|
|
21
|
+
audio: {
|
|
22
|
+
disabled: false
|
|
23
|
+
},
|
|
24
|
+
video: {
|
|
25
|
+
disabled: false
|
|
26
|
+
},
|
|
27
|
+
image: {
|
|
28
|
+
disabled: false
|
|
29
|
+
},
|
|
30
|
+
textAlign: {
|
|
31
|
+
disabled: true
|
|
32
|
+
},
|
|
33
|
+
showParagraphs: {
|
|
34
|
+
disabled: false
|
|
35
|
+
},
|
|
36
|
+
separateParagraphs: {
|
|
37
|
+
disabled: true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
rubriclessInstruction: {
|
|
41
|
+
inputConfiguration: {
|
|
42
|
+
audio: {
|
|
43
|
+
disabled: false
|
|
44
|
+
},
|
|
45
|
+
video: {
|
|
46
|
+
disabled: false
|
|
47
|
+
},
|
|
48
|
+
image: {
|
|
49
|
+
disabled: false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
showExcludeZero: {
|
|
54
|
+
settings: true,
|
|
55
|
+
label: 'Ability to exclude zero'
|
|
56
|
+
},
|
|
57
|
+
showMaxPoint: {
|
|
58
|
+
settings: true,
|
|
59
|
+
label: 'Show max points dropdown'
|
|
60
|
+
},
|
|
61
|
+
settingsPanelDisabled: false,
|
|
62
|
+
// width: '500px'
|
|
63
|
+
mathMlOptions: {
|
|
64
|
+
mmlOutput: false,
|
|
65
|
+
mmlEditing: false
|
|
66
|
+
},
|
|
67
|
+
maxMaxPoints: 9
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["model","points","sampleAnswers","maxPoints","excludeZero","excludeZeroEnabled","maxPointsEnabled","configuration","baseInputConfiguration","h3","disabled","audio","video","image","textAlign","showParagraphs","separateParagraphs","rubriclessInstruction","inputConfiguration","showExcludeZero","settings","label","showMaxPoint","settingsPanelDisabled","mathMlOptions","mmlOutput","mmlEditing","maxMaxPoints"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n model: {\n points: ['', '', '', ''],\n sampleAnswers: [null, null, null, null],\n maxPoints: 3,\n excludeZero: false,\n excludeZeroEnabled: true,\n maxPointsEnabled: true,\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n rubriclessInstruction: {\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n showExcludeZero: {\n settings: true,\n label: 'Ability to exclude zero',\n },\n showMaxPoint: {\n settings: true,\n label: 'Show max points dropdown',\n },\n settingsPanelDisabled: false,\n // width: '500px'\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n maxMaxPoints: 9,\n },\n};\n"],"mappings":";;;;;;iCAAe;EACbA,KAAK,EAAE;IACLC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IACxBC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IACvCC,SAAS,EAAE,CAAC;IACZC,WAAW,EAAE,KAAK;IAClBC,kBAAkB,EAAE,IAAI;IACxBC,gBAAgB,EAAE;EACpB,CAAC;EACDC,aAAa,EAAE;IACbC,sBAAsB,EAAE;MACtBC,EAAE,EAAE;QAAEC,QAAQ,EAAE;MAAK,CAAC;MACtBC,KAAK,EAAE;QAAED,QAAQ,EAAE;MAAM,CAAC;MAC1BE,KAAK,EAAE;QAAEF,QAAQ,EAAE;MAAM,CAAC;MAC1BG,KAAK,EAAE;QAAEH,QAAQ,EAAE;MAAM,CAAC;MAC1BI,SAAS,EAAE;QAAEJ,QAAQ,EAAE;MAAK,CAAC;MAC7BK,cAAc,EAAE;QAAEL,QAAQ,EAAE;MAAM,CAAC;MACnCM,kBAAkB,EAAE;QAAEN,QAAQ,EAAE;MAAK;IACvC,CAAC;IACDO,qBAAqB,EAAE;MACrBC,kBAAkB,EAAE;QAClBP,KAAK,EAAE;UAAED,QAAQ,EAAE;QAAM,CAAC;QAC1BE,KAAK,EAAE;UAAEF,QAAQ,EAAE;QAAM,CAAC;QAC1BG,KAAK,EAAE;UAAEH,QAAQ,EAAE;QAAM;MAC3B;IACF,CAAC;IACDS,eAAe,EAAE;MACfC,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE;IACT,CAAC;IACDC,YAAY,EAAE;MACZF,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE;IACT,CAAC;IACDE,qBAAqB,EAAE,KAAK;IAC5B;IACAC,aAAa,EAAE;MACbC,SAAS,EAAE,KAAK;MAChBC,UAAU,EAAE;IACd,CAAC;IACDC,YAAY,EAAE;EAChB;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _client = require("react-dom/client");
|
|
12
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
14
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
15
|
+
const modelWithDefaults = m => ({
|
|
16
|
+
..._defaults.default.model,
|
|
17
|
+
...m
|
|
18
|
+
});
|
|
19
|
+
const configurationWithDefaults = c => ({
|
|
20
|
+
..._defaults.default.configuration,
|
|
21
|
+
...c
|
|
22
|
+
});
|
|
23
|
+
class RubricElement extends HTMLElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
(0, _defineProperty2.default)(this, "updateModelAccordingToReceivedProps", nextModel => {
|
|
27
|
+
const currentModel = {
|
|
28
|
+
...this._model
|
|
29
|
+
};
|
|
30
|
+
if (!nextModel) {
|
|
31
|
+
return currentModel;
|
|
32
|
+
}
|
|
33
|
+
const validatedModel = {
|
|
34
|
+
...nextModel
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// excludeZero should be false and disabled when maxPoints is 1
|
|
38
|
+
if (validatedModel.maxPoints === 1) {
|
|
39
|
+
validatedModel.excludeZero = false;
|
|
40
|
+
}
|
|
41
|
+
const {
|
|
42
|
+
maxPoints,
|
|
43
|
+
excludeZero
|
|
44
|
+
} = validatedModel || {};
|
|
45
|
+
validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];
|
|
46
|
+
validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];
|
|
47
|
+
const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
|
|
48
|
+
const howManyPointsDoesItHave = validatedModel.points.length;
|
|
49
|
+
const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;
|
|
50
|
+
const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;
|
|
51
|
+
if (howManyPointsDoesItHave < howManyPointsShouldHave) {
|
|
52
|
+
if (excludeZeroChanged && !excludeZero) {
|
|
53
|
+
validatedModel.points = ['', ...validatedModel.points];
|
|
54
|
+
validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];
|
|
55
|
+
}
|
|
56
|
+
if (maxPointsChanged) {
|
|
57
|
+
for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {
|
|
58
|
+
validatedModel.points.push('');
|
|
59
|
+
validatedModel.sampleAnswers.push(null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} else if (howManyPointsDoesItHave > howManyPointsShouldHave) {
|
|
63
|
+
if (excludeZeroChanged && excludeZero) {
|
|
64
|
+
validatedModel.points = validatedModel.points.slice(1);
|
|
65
|
+
validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);
|
|
66
|
+
}
|
|
67
|
+
if (maxPointsChanged) {
|
|
68
|
+
validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);
|
|
69
|
+
validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return validatedModel;
|
|
73
|
+
});
|
|
74
|
+
(0, _defineProperty2.default)(this, "onConfigurationChanged", c => {
|
|
75
|
+
this._configuration = configurationWithDefaults(c);
|
|
76
|
+
if (this._model) {
|
|
77
|
+
this.onModelChanged(this._model);
|
|
78
|
+
}
|
|
79
|
+
this._render();
|
|
80
|
+
});
|
|
81
|
+
this._root = null;
|
|
82
|
+
_debug.default.log('constructor called');
|
|
83
|
+
this._model = modelWithDefaults();
|
|
84
|
+
this._configuration = configurationWithDefaults();
|
|
85
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
86
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
87
|
+
}
|
|
88
|
+
set model(m) {
|
|
89
|
+
this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
|
|
90
|
+
this._render();
|
|
91
|
+
}
|
|
92
|
+
set configuration(c) {
|
|
93
|
+
this._configuration = configurationWithDefaults(c);
|
|
94
|
+
this._render();
|
|
95
|
+
}
|
|
96
|
+
onModelChanged(m) {
|
|
97
|
+
this._model = this.updateModelAccordingToReceivedProps(m);
|
|
98
|
+
this._render();
|
|
99
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, false));
|
|
100
|
+
}
|
|
101
|
+
insertImage(handler) {
|
|
102
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
103
|
+
}
|
|
104
|
+
onDeleteImage(src, done) {
|
|
105
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
106
|
+
}
|
|
107
|
+
connectedCallback() {
|
|
108
|
+
this._render();
|
|
109
|
+
}
|
|
110
|
+
_render() {
|
|
111
|
+
if (this._model) {
|
|
112
|
+
let element = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
113
|
+
model: this._model,
|
|
114
|
+
configuration: this._configuration,
|
|
115
|
+
onModelChanged: this.onModelChanged,
|
|
116
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
117
|
+
imageSupport: {
|
|
118
|
+
add: this.insertImage.bind(this),
|
|
119
|
+
delete: this.onDeleteImage.bind(this)
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (!this._root) {
|
|
123
|
+
this._root = (0, _client.createRoot)(this);
|
|
124
|
+
}
|
|
125
|
+
this._root.render(element);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
disconnectedCallback() {
|
|
129
|
+
if (this._root) {
|
|
130
|
+
this._root.unmount();
|
|
131
|
+
this._root = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.default = RubricElement;
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_debug","_main","_defaults","modelWithDefaults","m","defaults","model","configurationWithDefaults","c","configuration","RubricElement","HTMLElement","constructor","_defineProperty2","default","nextModel","currentModel","_model","validatedModel","maxPoints","excludeZero","points","sampleAnswers","howManyPointsShouldHave","howManyPointsDoesItHave","length","excludeZeroChanged","maxPointsChanged","i","push","slice","_configuration","onModelChanged","_render","_root","debug","log","bind","onConfigurationChanged","updateModelAccordingToReceivedProps","dispatchEvent","ModelUpdatedEvent","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","connectedCallback","element","React","createElement","Main","imageSupport","add","delete","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\n\nimport Main from './main';\nimport defaults from './defaults';\n\nconst modelWithDefaults = (m) => ({ ...defaults.model, ...m });\n\nconst configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });\n\nexport default class RubricElement extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n debug.log('constructor called');\n this._model = modelWithDefaults();\n this._configuration = configurationWithDefaults();\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n updateModelAccordingToReceivedProps = (nextModel) => {\n const currentModel = { ...this._model };\n\n if (!nextModel) {\n return currentModel;\n }\n\n const validatedModel = { ...nextModel };\n\n // excludeZero should be false and disabled when maxPoints is 1\n if (validatedModel.maxPoints === 1) {\n validatedModel.excludeZero = false;\n }\n\n const { maxPoints, excludeZero } = validatedModel || {};\n\n validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];\n validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];\n\n const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;\n const howManyPointsDoesItHave = validatedModel.points.length;\n\n const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;\n const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;\n\n if (howManyPointsDoesItHave < howManyPointsShouldHave) {\n if (excludeZeroChanged && !excludeZero) {\n validatedModel.points = ['', ...validatedModel.points];\n validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];\n }\n\n if (maxPointsChanged) {\n for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {\n validatedModel.points.push('');\n validatedModel.sampleAnswers.push(null);\n }\n }\n } else if (howManyPointsDoesItHave > howManyPointsShouldHave) {\n if (excludeZeroChanged && excludeZero) {\n validatedModel.points = validatedModel.points.slice(1);\n validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);\n }\n\n if (maxPointsChanged) {\n validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);\n validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);\n }\n }\n\n return validatedModel;\n };\n\n set model(m) {\n this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));\n this._render();\n }\n\n set configuration(c) {\n this._configuration = configurationWithDefaults(c);\n this._render();\n }\n\n onModelChanged(m) {\n this._model = this.updateModelAccordingToReceivedProps(m);\n this._render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n }\n\n onConfigurationChanged = (c) => {\n this._configuration = configurationWithDefaults(c);\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n };\n\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n connectedCallback() {\n this._render();\n }\n\n _render() {\n if (this._model) {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,KAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,SAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,MAAMO,iBAAiB,GAAIC,CAAC,KAAM;EAAE,GAAGC,iBAAQ,CAACC,KAAK;EAAE,GAAGF;AAAE,CAAC,CAAC;AAE9D,MAAMG,yBAAyB,GAAIC,CAAC,KAAM;EAAE,GAAGH,iBAAQ,CAACI,aAAa;EAAE,GAAGD;AAAE,CAAC,CAAC;AAE/D,MAAME,aAAa,SAASC,WAAW,CAAC;EACrDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,+CAS6BC,SAAS,IAAK;MACnD,MAAMC,YAAY,GAAG;QAAE,GAAG,IAAI,CAACC;MAAO,C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AC,IAAI,CAAC;UAChCmB,MAAM,EAAE,IAAI,CAACX,aAAa,CAACR,IAAI,CAAC,IAAI;QACtC;MACF,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAACH,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAuB,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACvB,KAAK,CAACwB,MAAM,CAACR,OAAO,CAAC;IAC5B;EACF;EAEAS,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACzB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAAC0B,OAAO,CAAC,CAAC;MACpB,IAAI,CAAC1B,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAAC2B,OAAA,CAAA/C,OAAA,GAAAJ,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _rubric = require("@pie-lib/rubric");
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
13
|
+
const {
|
|
14
|
+
Panel,
|
|
15
|
+
toggle
|
|
16
|
+
} = _configUi.settings;
|
|
17
|
+
const StyledDiv = (0, _styles.styled)('div')(({
|
|
18
|
+
theme,
|
|
19
|
+
width
|
|
20
|
+
}) => ({
|
|
21
|
+
maxWidth: width,
|
|
22
|
+
fontFamily: 'Cerebri Sans',
|
|
23
|
+
fontSize: theme.typography.fontSize
|
|
24
|
+
}));
|
|
25
|
+
class Main extends _react.default.Component {
|
|
26
|
+
constructor(...args) {
|
|
27
|
+
super(...args);
|
|
28
|
+
(0, _defineProperty2.default)(this, "verifyRubriclessModel", (m, config) => {
|
|
29
|
+
const {
|
|
30
|
+
rubricless = false
|
|
31
|
+
} = config || {};
|
|
32
|
+
return rubricless ? (({
|
|
33
|
+
points,
|
|
34
|
+
sampleAnswers,
|
|
35
|
+
...rest
|
|
36
|
+
}) => rest)(m) : m;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const {
|
|
41
|
+
model,
|
|
42
|
+
configuration,
|
|
43
|
+
onConfigurationChanged,
|
|
44
|
+
onModelChanged,
|
|
45
|
+
imageSupport
|
|
46
|
+
} = this.props || {};
|
|
47
|
+
const {
|
|
48
|
+
baseInputConfiguration = {},
|
|
49
|
+
contentDimensions = {},
|
|
50
|
+
settingsPanelDisabled,
|
|
51
|
+
showExcludeZero = {},
|
|
52
|
+
showMaxPoint = {},
|
|
53
|
+
mathMlOptions = {},
|
|
54
|
+
rubricless = false,
|
|
55
|
+
rubriclessInstruction,
|
|
56
|
+
width
|
|
57
|
+
} = configuration || {};
|
|
58
|
+
|
|
59
|
+
// ensure to eliminate points and sampleAnswers in case of rubricless
|
|
60
|
+
const value = this.verifyRubriclessModel(model, configuration);
|
|
61
|
+
const {
|
|
62
|
+
extraCSSRules
|
|
63
|
+
} = model;
|
|
64
|
+
const panelProperties = {
|
|
65
|
+
excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),
|
|
66
|
+
maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
|
|
67
|
+
rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label)
|
|
68
|
+
};
|
|
69
|
+
const getPluginProps = props => {
|
|
70
|
+
return Object.assign({
|
|
71
|
+
...baseInputConfiguration
|
|
72
|
+
}, props || {});
|
|
73
|
+
};
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
|
|
75
|
+
extraCSSRules: extraCSSRules,
|
|
76
|
+
dimensions: contentDimensions,
|
|
77
|
+
hideSettings: settingsPanelDisabled,
|
|
78
|
+
settings: /*#__PURE__*/_react.default.createElement(Panel, {
|
|
79
|
+
model: model,
|
|
80
|
+
onChangeModel: onModelChanged,
|
|
81
|
+
configuration: configuration,
|
|
82
|
+
onChangeConfiguration: onConfigurationChanged,
|
|
83
|
+
pluginOpts: getPluginProps(rubriclessInstruction?.inputConfiguration),
|
|
84
|
+
groups: {
|
|
85
|
+
Properties: panelProperties
|
|
86
|
+
},
|
|
87
|
+
imageSupport: imageSupport
|
|
88
|
+
})
|
|
89
|
+
}, /*#__PURE__*/_react.default.createElement(StyledDiv, {
|
|
90
|
+
width: width
|
|
91
|
+
}, /*#__PURE__*/_react.default.createElement(_rubric.Authoring, {
|
|
92
|
+
value: value,
|
|
93
|
+
config: configuration,
|
|
94
|
+
onChange: onModelChanged,
|
|
95
|
+
mathMlOptions: mathMlOptions,
|
|
96
|
+
rubricless: rubricless,
|
|
97
|
+
pluginOpts: baseInputConfiguration,
|
|
98
|
+
imageSupport: imageSupport
|
|
99
|
+
})));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var _default = exports.default = Main;
|
|
103
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_rubric","_styles","_configUi","Panel","toggle","settings","StyledDiv","styled","theme","width","maxWidth","fontFamily","fontSize","typography","Main","React","Component","constructor","args","_defineProperty2","default","m","config","rubricless","points","sampleAnswers","rest","render","model","configuration","onConfigurationChanged","onModelChanged","imageSupport","props","baseInputConfiguration","contentDimensions","settingsPanelDisabled","showExcludeZero","showMaxPoint","mathMlOptions","rubriclessInstruction","value","verifyRubriclessModel","extraCSSRules","panelProperties","excludeZeroEnabled","label","maxPointsEnabled","rubriclessInstructionEnabled","getPluginProps","Object","assign","createElement","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onChangeConfiguration","pluginOpts","inputConfiguration","groups","Properties","Authoring","onChange","_default","exports"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport { Authoring } from '@pie-lib/rubric';\nimport { styled } from '@mui/material/styles';\nimport { layout, settings } from '@pie-lib/config-ui';\n\nconst { Panel, toggle } = settings;\n\nconst StyledDiv = styled('div')(({ theme, width }) => ({\n maxWidth: width,\n fontFamily: 'Cerebri Sans',\n fontSize: theme.typography.fontSize,\n}));\n\nclass Main extends React.Component {\n verifyRubriclessModel = (m, config) => {\n const { rubricless = false } = config || {};\n return rubricless ? (({ points, sampleAnswers, ...rest }) => rest)(m) : m;\n };\n\n render() {\n const { model, configuration, onConfigurationChanged, onModelChanged, imageSupport } = this.props || {};\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n settingsPanelDisabled,\n showExcludeZero = {},\n showMaxPoint = {},\n mathMlOptions = {},\n rubricless = false,\n rubriclessInstruction,\n width,\n } = configuration || {};\n\n // ensure to eliminate points and sampleAnswers in case of rubricless\n const value = this.verifyRubriclessModel(model, configuration);\n const { extraCSSRules } = model;\n\n const panelProperties = {\n excludeZeroEnabled: showExcludeZero.settings && toggle(showExcludeZero.label),\n maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),\n rubriclessInstructionEnabled: rubricless && rubriclessInstruction.settings && toggle(rubriclessInstruction.label),\n };\n\n const getPluginProps = (props) => {\n return Object.assign(\n {\n ...baseInputConfiguration,\n },\n props || {},\n );\n };\n\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n pluginOpts={getPluginProps(rubriclessInstruction?.inputConfiguration)}\n groups={{\n Properties: panelProperties,\n }}\n imageSupport={imageSupport}\n />\n } >\n <StyledDiv width={width}>\n <Authoring\n value={value}\n config={configuration}\n onChange={onModelChanged}\n mathMlOptions={mathMlOptions}\n rubricless={rubricless}\n pluginOpts={baseInputConfiguration}\n imageSupport={imageSupport}\n />\n </StyledDiv>\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA,MAAM;EAAEI,KAAK;EAAEC;AAAO,CAAC,GAAGC,kBAAQ;AAElC,MAAMC,SAAS,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC,KAAK;EAAEC;AAAM,CAAC,MAAM;EACrDC,QAAQ,EAAED,KAAK;EACfE,UAAU,EAAE,cAAc;EAC1BC,QAAQ,EAAEJ,KAAK,CAACK,UAAU,CAACD;AAC7B,CAAC,CAAC,CAAC;AAEH,MAAME,IAAI,SAASC,cAAK,CAACC,SAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iCACT,CAACC,CAAC,EAAEC,MAAM,KAAK;MACrC,MAAM;QAAEC,UAAU,GAAG;MAAM,CAAC,GAAGD,MAAM,IAAI,CAAC,CAAC;MAC3C,OAAOC,UAAU,GAAG,CAAC,CAAC;QAAEC,MAAM;QAAEC,aAAa;QAAE,GAAGC;MAAK,CAAC,KAAKA,IAAI,EAAEL,CAAC,CAAC,GAAGA,CAAC;IAC3E,CAAC;EAAA;EAEDM,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,KAAK;MAAEC,aAAa;MAAEC,sBAAsB;MAAEC,cAAc;MAAEC;IAAa,CAAC,GAAG,IAAI,CAACC,KAAK,IAAI,CAAC,CAAC;IACvG,MAAM;MACJC,sBAAsB,GAAG,CAAC,CAAC;MAC3BC,iBAAiB,GAAG,CAAC,CAAC;MACtBC,qBAAqB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UACNC,UAAU,EAAElB;QACd,CAAE;QACFZ,YAAY,EAAEA;MAAa,CAC5B;IACF,gBACDnC,MAAA,CAAAuB,OAAA,CAAAgC,aAAA,CAAC9C,SAAS;MAACG,KAAK,EAAEA;IAAM,gBACtBZ,MAAA,CAAAuB,OAAA,CAAAgC,aAAA,CAACpD,OAAA,CAAA+D,SAAS;MACRtB,KAAK,EAAEA,KAAM;MACbnB,MAAM,EAAEO,aAAc;MACtBmC,QAAQ,EAAEjC,cAAe;MACzBQ,aAAa,EAAEA,aAAc;MAC7BhB,UAAU,EAAEA,UAAW;MACvBoC,UAAU,EAAEzB,sBAAuB;MACnCF,YAAY,EAAEA;IAAa,CAC5B,CACQ,CACQ,CAAC;EAE1B;AACF;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAA9C,OAAA,GAEcN,IAAI","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "7.4.0-beta.
|
|
4
|
+
"version": "7.4.0-beta.13",
|
|
5
5
|
"description": "Rubric authoring view",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"author": "Pie Framework Authors",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"@mui/icons-material": "^7.3.4",
|
|
12
12
|
"@mui/material": "^7.3.4",
|
|
13
13
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
14
|
-
"@pie-lib/config-ui": "13.0.22-beta.
|
|
15
|
-
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.
|
|
14
|
+
"@pie-lib/config-ui": "13.0.22-beta.2",
|
|
15
|
+
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.2",
|
|
16
16
|
"@pie-lib/render-ui": "6.1.3",
|
|
17
|
-
"@pie-lib/rubric": "2.0.22-beta.
|
|
17
|
+
"@pie-lib/rubric": "2.0.22-beta.2",
|
|
18
18
|
"debug": "^4.1.1",
|
|
19
19
|
"react": "18.3.1",
|
|
20
20
|
"react-dom": "18.3.1"
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.3.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-controller@6.3.0-beta.12...@pie-element/rubric-controller@6.3.0-beta.13) (2026-09-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/rubric-controller
|
|
9
|
+
|
|
6
10
|
# [6.3.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-controller@6.3.0-beta.11...@pie-element/rubric-controller@6.3.0-beta.12) (2026-09-24)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @pie-element/rubric-controller
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
points: ['', '', '', ''],
|
|
9
|
+
sampleAnswers: [null, null, null, null],
|
|
10
|
+
maxPoints: 3,
|
|
11
|
+
maxPointsEnabled: true,
|
|
12
|
+
excludeZero: false,
|
|
13
|
+
excludeZeroEnabled: true
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["points","sampleAnswers","maxPoints","maxPointsEnabled","excludeZero","excludeZeroEnabled"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n points: ['', '', '', ''],\n sampleAnswers: [null, null, null, null],\n maxPoints: 3,\n maxPointsEnabled: true,\n excludeZero: false,\n excludeZeroEnabled: true,\n};\n"],"mappings":";;;;;;iCAAe;EACbA,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;EACxBC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;EACvCC,SAAS,EAAE,CAAC;EACZC,gBAAgB,EAAE,IAAI;EACtBC,WAAW,EAAE,KAAK;EAClBC,kBAAkB,EAAE;AACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.model = model;
|
|
8
|
+
exports.validate = validate;
|
|
9
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
10
|
+
const normalize = model => ({
|
|
11
|
+
..._defaults.default,
|
|
12
|
+
...model
|
|
13
|
+
});
|
|
14
|
+
function model(model, session, env) {
|
|
15
|
+
return new Promise(resolve => {
|
|
16
|
+
const modelResult = normalize(model || {});
|
|
17
|
+
resolve(env && env.role && env.role === 'instructor' ? modelResult : {});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function markupToText(s) {
|
|
21
|
+
return (s || '').replace(/(<([^>]+)>)/gi, '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.
|
|
25
|
+
function validate(model) {
|
|
26
|
+
const {
|
|
27
|
+
points
|
|
28
|
+
} = model;
|
|
29
|
+
const errors = {};
|
|
30
|
+
const pointsDescriptorsErrors = {};
|
|
31
|
+
(points || []).forEach((point, index) => {
|
|
32
|
+
if (!point || point === '<div></div>') {
|
|
33
|
+
pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
|
|
34
|
+
} else {
|
|
35
|
+
const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
|
|
36
|
+
if (identicalPointDescr) {
|
|
37
|
+
pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (Object.keys(pointsDescriptorsErrors).length > 0) {
|
|
42
|
+
errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
|
|
43
|
+
}
|
|
44
|
+
return errors;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","normalize","model","defaults","session","env","Promise","resolve","modelResult","role","markupToText","s","replace","validate","points","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\n\nconst normalize = (model) => ({ ...defaults, ...model });\n\nexport function model(model, session, env) {\n return new Promise((resolve) => {\n const modelResult = normalize(model || {});\n\n resolve(env && env.role && env.role === 'instructor' ? modelResult : {});\n });\n}\n\nfunction markupToText(s) {\n return (s || '').replace(/(<([^>]+)>)/gi, '');\n}\n\n// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.\nexport function validate(model) {\n const { points } = model;\n const errors = {};\n const pointsDescriptorsErrors = {};\n\n (points || []).forEach((point, index) => {\n\n if (!point || point === '<div></div>') {\n pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';\n } else {\n const identicalPointDescr = points.slice(index + 1).some((p) => markupToText(p) === markupToText(point));\n\n if (identicalPointDescr) {\n pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';\n }\n }\n });\n\n if (Object.keys(pointsDescriptorsErrors).length > 0) {\n errors.pointsDescriptorsErrors = pointsDescriptorsErrors;\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAA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,uBAAuB,CAAC,CAACU,MAAM,GAAG,CAAC,EAAE;IACnDX,MAAM,CAACC,uBAAuB,GAAGA,uBAAuB;EAC1D;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
package/controller/package.json
CHANGED
package/lib/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _client = require("react-dom/client");
|
|
12
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
14
|
+
class RubricRender extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
// React commits asynchronously, so a queueMicrotask(renderMath) can run before
|
|
18
|
+
// the LaTeX spans are in the DOM and leave raw LaTeX on first render — this is
|
|
19
|
+
// especially visible when rubric is mounted inside complex-rubric, which swaps
|
|
20
|
+
// its innerHTML and re-defines the inner element. Observing the DOM and
|
|
21
|
+
// typesetting after each commit keeps math in sync regardless of timing.
|
|
22
|
+
(0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
|
|
23
|
+
if (this._mathRenderPending) return;
|
|
24
|
+
this._mathRenderPending = true;
|
|
25
|
+
requestAnimationFrame(() => {
|
|
26
|
+
if (this._mathObserver) {
|
|
27
|
+
this._mathObserver.disconnect();
|
|
28
|
+
}
|
|
29
|
+
(0, _mathRendering.renderMath)(this);
|
|
30
|
+
this._mathRenderPending = false;
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
if (this._mathObserver) {
|
|
33
|
+
this._mathObserver.observe(this, {
|
|
34
|
+
childList: true,
|
|
35
|
+
subtree: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, 50);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
_debug.default.log('constructor called');
|
|
42
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
43
|
+
this._root = null;
|
|
44
|
+
this._mathObserver = null;
|
|
45
|
+
this._mathRenderPending = false;
|
|
46
|
+
}
|
|
47
|
+
_initMathObserver() {
|
|
48
|
+
if (this._mathObserver) return;
|
|
49
|
+
this._mathObserver = new MutationObserver(this._scheduleMathRender);
|
|
50
|
+
this._mathObserver.observe(this, {
|
|
51
|
+
childList: true,
|
|
52
|
+
subtree: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_disconnectMathObserver() {
|
|
56
|
+
if (this._mathObserver) {
|
|
57
|
+
this._mathObserver.disconnect();
|
|
58
|
+
this._mathObserver = null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
set model(s) {
|
|
62
|
+
this._model = s;
|
|
63
|
+
this._render();
|
|
64
|
+
}
|
|
65
|
+
onModelChanged(m) {
|
|
66
|
+
this._model = m;
|
|
67
|
+
this._render();
|
|
68
|
+
}
|
|
69
|
+
connectedCallback() {
|
|
70
|
+
this._initMathObserver();
|
|
71
|
+
this._render();
|
|
72
|
+
}
|
|
73
|
+
_render() {
|
|
74
|
+
if (this._model) {
|
|
75
|
+
this._initMathObserver();
|
|
76
|
+
const el = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
77
|
+
value: this._model
|
|
78
|
+
});
|
|
79
|
+
if (!this._root) {
|
|
80
|
+
this._root = (0, _client.createRoot)(this);
|
|
81
|
+
}
|
|
82
|
+
this._root.render(el);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
disconnectedCallback() {
|
|
86
|
+
this._disconnectMathObserver();
|
|
87
|
+
if (this._root) {
|
|
88
|
+
this._root.unmount();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.default = RubricRender;
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_debug","_mathRendering","RubricRender","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","debug","log","onModelChanged","bind","_root","_initMathObserver","MutationObserver","_scheduleMathRender","_disconnectMathObserver","model","s","_model","_render","m","connectedCallback","el","React","createElement","Rubric","value","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import Rubric from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nexport default class RubricRender extends HTMLElement {\n constructor() {\n super();\n debug.log('constructor called');\n this.onModelChanged = this.onModelChanged.bind(this);\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n }\n\n // React commits asynchronously, so a queueMicrotask(renderMath) can run before\n // the LaTeX spans are in the DOM and leave raw LaTeX on first render — this is\n // especially visible when rubric is mounted inside complex-rubric, which swaps\n // its innerHTML and re-defines the inner element. Observing the DOM and\n // typesetting after each commit keeps math in sync regardless of timing.\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n set model(s) {\n this._model = s;\n this._render();\n }\n\n onModelChanged(m) {\n this._model = m;\n this._render();\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._render();\n }\n\n _render() {\n if (this._model) {\n this._initMathObserver();\n\n const el = React.createElement(Rubric, { value: this._model });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEe,MAAMK,YAAY,SAASC,WAAW,CAAC;EACpDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAQT;IACA;IACA;IACA;IACA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,+BACsB,MAAM;MAC1B,IAAI,IAAI,CAACC,kBAAkB,EAAE;MAC7B,IAAI,CAACA,kBAAkB,GAAG,IAAI;MAE9BC,qBAAqB,CAAC,MAAM;QAC1B,IAAI,IAAI,CAACC,aAAa,EAAE;UACtB,IAAI,CAACA,aAAa,CAACC,UAAU,CAAC,CAAC;QACjC;QACA,IAAAC,yBAAU,EAAC,IAAI,CAAC;QAChB,IAAI,CAACJ,kBAAkB,GAAG,KAAK;QAC/BK,UAAU,CAAC,MAAM;UACf,IAAI,IAAI,CAACH,aAAa,EAAE;YACtB,IAAI,CAACA,aAAa,CAACI,OAAO,CAAC,IAAI,EAAE;cAAEC,SAAS,EAAE,IAAI;cAAEC,OAAO,EAAE;YAAK,CAAC,CAAC;UACtE;QACF,CAAC,EAAE,EAAE,CAAC;MACR,CAAC,CAAC;IACJ,CAAC;IA5BCC,c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IAAI,CAACP,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAgB,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAAChB,KAAK,CAACiB,MAAM,CAACN,EAAE,CAAC;IACvB;EACF;EAEAO,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACd,uBAAuB,CAAC,CAAC;IAC9B,IAAI,IAAI,CAACJ,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACmB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAlC,OAAA,GAAAJ,YAAA","ignoreList":[]}
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.RubricType = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _styles = require("@mui/material/styles");
|
|
11
|
+
var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
|
|
12
|
+
var _List = _interopRequireDefault(require("@mui/material/List"));
|
|
13
|
+
var _Collapse = _interopRequireDefault(require("@mui/material/Collapse"));
|
|
14
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
+
const StyledUiLayout = (0, _styles.styled)(_renderUi.UiLayout)({
|
|
17
|
+
color: _renderUi.color.text(),
|
|
18
|
+
backgroundColor: _renderUi.color.background(),
|
|
19
|
+
// apply styles to tables to match the rest of the UI
|
|
20
|
+
'&:not(.MathJax) table': {
|
|
21
|
+
borderCollapse: 'collapse'
|
|
22
|
+
},
|
|
23
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
24
|
+
padding: '8px 12px',
|
|
25
|
+
textAlign: 'left'
|
|
26
|
+
},
|
|
27
|
+
// reset paragraph margins and line-height inside lists to override client styles
|
|
28
|
+
'& ul p, & ol p': {
|
|
29
|
+
marginBottom: 0,
|
|
30
|
+
marginTop: 0,
|
|
31
|
+
lineHeight: 'normal'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const StyledListItem = (0, _styles.styled)(_ListItem.default)({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
alignItems: 'flex-start',
|
|
38
|
+
padding: '12px 0px'
|
|
39
|
+
});
|
|
40
|
+
const Text = (0, _styles.styled)('div')({
|
|
41
|
+
color: _renderUi.color.text()
|
|
42
|
+
});
|
|
43
|
+
const TitleText = (0, _styles.styled)('h3')({
|
|
44
|
+
color: _renderUi.color.text(),
|
|
45
|
+
fontSize: '16px',
|
|
46
|
+
fontWeight: '700',
|
|
47
|
+
margin: 0,
|
|
48
|
+
paddingBottom: '6px'
|
|
49
|
+
});
|
|
50
|
+
const SampleTitleText = (0, _styles.styled)('h4')({
|
|
51
|
+
color: _renderUi.color.text(),
|
|
52
|
+
fontSize: '16px',
|
|
53
|
+
fontWeight: 'normal',
|
|
54
|
+
margin: 0,
|
|
55
|
+
paddingBottom: '6px'
|
|
56
|
+
});
|
|
57
|
+
const RubricToggle = (0, _styles.styled)('h2')(({
|
|
58
|
+
theme
|
|
59
|
+
}) => ({
|
|
60
|
+
display: 'flex',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
cursor: 'pointer',
|
|
63
|
+
userSelect: 'none',
|
|
64
|
+
fontSize: theme.typography.fontSize,
|
|
65
|
+
fontWeight: '500',
|
|
66
|
+
color: _renderUi.color.tertiary(),
|
|
67
|
+
margin: 0
|
|
68
|
+
}));
|
|
69
|
+
const ChevronStyle = (0, _styles.styled)('span')({
|
|
70
|
+
display: 'inline-flex',
|
|
71
|
+
transition: 'transform 0.2s',
|
|
72
|
+
marginLeft: 2,
|
|
73
|
+
alignSelf: 'center'
|
|
74
|
+
});
|
|
75
|
+
const HiddenScreenReader = (0, _styles.styled)('h2')({
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
width: '1px',
|
|
78
|
+
height: '1px',
|
|
79
|
+
padding: 0,
|
|
80
|
+
margin: '-1px',
|
|
81
|
+
overflow: 'hidden',
|
|
82
|
+
clip: 'rect(0,0,0,0)',
|
|
83
|
+
border: 0,
|
|
84
|
+
whiteSpace: 'nowrap'
|
|
85
|
+
});
|
|
86
|
+
const RubricType = exports.RubricType = _propTypes.default.shape({
|
|
87
|
+
excludeZero: _propTypes.default.bool,
|
|
88
|
+
points: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
89
|
+
sampleAnswers: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
90
|
+
animationsDisabled: _propTypes.default.bool
|
|
91
|
+
});
|
|
92
|
+
class Rubric extends _react.default.Component {
|
|
93
|
+
constructor(props) {
|
|
94
|
+
super(props);
|
|
95
|
+
(0, _defineProperty2.default)(this, "dudUrl", 'javascript:;');
|
|
96
|
+
(0, _defineProperty2.default)(this, "shouldRenderPoint", (index, value) => {
|
|
97
|
+
if (!value.excludeZero) {
|
|
98
|
+
return true;
|
|
99
|
+
} else {
|
|
100
|
+
return index !== 0;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
this.state = {
|
|
104
|
+
rubricOpen: false,
|
|
105
|
+
linkPrefix: 'Show'
|
|
106
|
+
};
|
|
107
|
+
this.toggleRubric = this.toggleRubric.bind(this);
|
|
108
|
+
}
|
|
109
|
+
toggleRubric() {
|
|
110
|
+
this.setState({
|
|
111
|
+
rubricOpen: !this.state.rubricOpen
|
|
112
|
+
});
|
|
113
|
+
this.setState({
|
|
114
|
+
linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
const {
|
|
119
|
+
model,
|
|
120
|
+
value
|
|
121
|
+
} = this.props;
|
|
122
|
+
let {
|
|
123
|
+
animationsDisabled
|
|
124
|
+
} = this.props;
|
|
125
|
+
animationsDisabled = animationsDisabled || value.animationsDisabled;
|
|
126
|
+
if (value && value.points) {
|
|
127
|
+
const {
|
|
128
|
+
extraCSSRules
|
|
129
|
+
} = model || {};
|
|
130
|
+
const {
|
|
131
|
+
points,
|
|
132
|
+
sampleAnswers
|
|
133
|
+
} = value;
|
|
134
|
+
const rubricList = /*#__PURE__*/_react.default.createElement(_List.default, {
|
|
135
|
+
component: "nav"
|
|
136
|
+
}, points.slice(0).reverse().map((desc, index) => {
|
|
137
|
+
index = points.length - index - 1;
|
|
138
|
+
const pointsLabel = value.excludeZero ? index + 1 : index;
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
140
|
+
key: index
|
|
141
|
+
}, /*#__PURE__*/_react.default.createElement(StyledListItem, {
|
|
142
|
+
key: `P${index}`
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement(TitleText, null, pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`), /*#__PURE__*/_react.default.createElement(Text, {
|
|
144
|
+
dangerouslySetInnerHTML: {
|
|
145
|
+
__html: desc
|
|
146
|
+
}
|
|
147
|
+
})), sampleAnswers && sampleAnswers[index] && /*#__PURE__*/_react.default.createElement(StyledListItem, {
|
|
148
|
+
key: `S${index}`
|
|
149
|
+
}, /*#__PURE__*/_react.default.createElement(SampleTitleText, null, "Sample Answer"), /*#__PURE__*/_react.default.createElement(Text, {
|
|
150
|
+
dangerouslySetInnerHTML: {
|
|
151
|
+
__html: sampleAnswers[index]
|
|
152
|
+
}
|
|
153
|
+
})));
|
|
154
|
+
}));
|
|
155
|
+
return /*#__PURE__*/_react.default.createElement(StyledUiLayout, {
|
|
156
|
+
extraCSSRules: extraCSSRules
|
|
157
|
+
}, /*#__PURE__*/_react.default.createElement(HiddenScreenReader, null, "Rubric"), !animationsDisabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(RubricToggle, {
|
|
158
|
+
id: 'rubric-toggle',
|
|
159
|
+
tabIndex: 0,
|
|
160
|
+
role: "button",
|
|
161
|
+
"aria-expanded": this.state.rubricOpen,
|
|
162
|
+
onClick: this.toggleRubric,
|
|
163
|
+
onKeyPress: e => {
|
|
164
|
+
if (e.key === 'Enter' || e.key === ' ') this.toggleRubric();
|
|
165
|
+
}
|
|
166
|
+
}, this.state.linkPrefix, " Rubric", /*#__PURE__*/_react.default.createElement(ChevronStyle, {
|
|
167
|
+
"aria-hidden": "true"
|
|
168
|
+
}, this.state.rubricOpen ? /*#__PURE__*/_react.default.createElement("svg", {
|
|
169
|
+
width: "20",
|
|
170
|
+
height: "20",
|
|
171
|
+
viewBox: "0 0 24 24",
|
|
172
|
+
fill: "none",
|
|
173
|
+
stroke: "currentColor",
|
|
174
|
+
strokeWidth: "2",
|
|
175
|
+
strokeLinecap: "round",
|
|
176
|
+
strokeLinejoin: "round"
|
|
177
|
+
}, /*#__PURE__*/_react.default.createElement("polyline", {
|
|
178
|
+
points: "18 15 12 9 6 15"
|
|
179
|
+
})) : /*#__PURE__*/_react.default.createElement("svg", {
|
|
180
|
+
width: "20",
|
|
181
|
+
height: "20",
|
|
182
|
+
viewBox: "0 0 24 24",
|
|
183
|
+
fill: "none",
|
|
184
|
+
stroke: "currentColor",
|
|
185
|
+
strokeWidth: "2",
|
|
186
|
+
strokeLinecap: "round",
|
|
187
|
+
strokeLinejoin: "round"
|
|
188
|
+
}, /*#__PURE__*/_react.default.createElement("polyline", {
|
|
189
|
+
points: "6 9 12 15 18 9"
|
|
190
|
+
})))), /*#__PURE__*/_react.default.createElement(_Collapse.default, {
|
|
191
|
+
in: this.state.rubricOpen,
|
|
192
|
+
timeout: {
|
|
193
|
+
enter: 225,
|
|
194
|
+
exit: 195
|
|
195
|
+
}
|
|
196
|
+
}, rubricList)) : rubricList);
|
|
197
|
+
} else {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
(0, _defineProperty2.default)(Rubric, "propTypes", {
|
|
203
|
+
model: _propTypes.default.object.isRequired,
|
|
204
|
+
animationsDisabled: _propTypes.default.bool,
|
|
205
|
+
value: RubricType
|
|
206
|
+
});
|
|
207
|
+
var _default = exports.default = Rubric;
|
|
208
|
+
//# sourceMappingURL=main.js.map
|
package/lib/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_styles","_ListItem","_List","_Collapse","_renderUi","_propTypes","StyledUiLayout","styled","UiLayout","color","text","backgroundColor","background","borderCollapse","padding","textAlign","marginBottom","marginTop","lineHeight","StyledListItem","ListItem","display","flexDirection","alignItems","Text","TitleText","fontSize","fontWeight","margin","paddingBottom","SampleTitleText","RubricToggle","theme","cursor","userSelect","typography","tertiary","ChevronStyle","transition","marginLeft","alignSelf","HiddenScreenReader","position","width","height","overflow","clip","border","whiteSpace","RubricType","exports","PropTypes","shape","excludeZero","bool","points","arrayOf","string","sampleAnswers","animationsDisabled","Rubric","React","Component","constructor","props","_defineProperty2","default","index","value","state","rubricOpen","linkPrefix","toggleRubric","bind","setState","render","model","extraCSSRules","rubricList","createElement","component","slice","reverse","map","desc","length","pointsLabel","Fragment","key","dangerouslySetInnerHTML","__html","id","tabIndex","role","onClick","onKeyPress","e","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","in","timeout","enter","exit","object","isRequired","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport { styled } from '@mui/material/styles';\nimport ListItem from '@mui/material/ListItem';\nimport List from '@mui/material/List';\nimport Collapse from '@mui/material/Collapse';\nimport { color, UiLayout } from '@pie-lib/render-ui';\nimport PropTypes from 'prop-types';\n\nconst StyledUiLayout = styled(UiLayout)({\n color: color.text(),\n backgroundColor: color.background(),\n // apply styles to tables to match the rest of the UI\n '&:not(.MathJax) table': {\n borderCollapse: 'collapse',\n },\n '&:not(.MathJax) table td, &:not(.MathJax) table th': {\n padding: '8px 12px',\n textAlign: 'left',\n },\n // reset paragraph margins and line-height inside lists to override client styles\n '& ul p, & ol p': {\n marginBottom: 0,\n marginTop: 0,\n lineHeight: 'normal',\n },\n});\n\nconst StyledListItem = styled(ListItem)({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'flex-start',\n padding: '12px 0px',\n});\n\nconst Text = styled('div')({\n color: color.text(),\n});\n\nconst TitleText = styled('h3')({\n color: color.text(),\n fontSize: '16px',\n fontWeight: '700',\n margin: 0,\n paddingBottom: '6px',\n});\n\nconst SampleTitleText = styled('h4')({\n color: color.text(),\n fontSize: '16px',\n fontWeight: 'normal',\n margin: 0,\n paddingBottom: '6px',\n});\n\nconst RubricToggle = styled('h2')(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n userSelect: 'none',\n fontSize: theme.typography.fontSize,\n fontWeight: '500',\n color: color.tertiary(),\n margin: 0,\n}));\n\nconst ChevronStyle = styled('span')({\n display: 'inline-flex',\n transition: 'transform 0.2s',\n marginLeft: 2,\n alignSelf: 'center',\n});\n\nconst HiddenScreenReader = styled('h2')({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0,0,0,0)',\n border: 0,\n whiteSpace: 'nowrap',\n});\n\nexport const RubricType = PropTypes.shape({\n excludeZero: PropTypes.bool,\n points: PropTypes.arrayOf(PropTypes.string),\n sampleAnswers: PropTypes.arrayOf(PropTypes.string),\n animationsDisabled: PropTypes.bool,\n});\n\nclass Rubric extends React.Component {\n dudUrl = 'javascript:;';\n\n constructor(props) {\n super(props);\n this.state = {\n rubricOpen: false,\n linkPrefix: 'Show',\n };\n this.toggleRubric = this.toggleRubric.bind(this);\n }\n\n static propTypes = {\n model: PropTypes.object.isRequired,\n animationsDisabled: PropTypes.bool,\n value: RubricType,\n };\n\n toggleRubric() {\n this.setState({ rubricOpen: !this.state.rubricOpen });\n this.setState({ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide' });\n }\n\n shouldRenderPoint = (index, value) => {\n if (!value.excludeZero) {\n return true;\n } else {\n return index !== 0;\n }\n };\n\n render() {\n const { model, value } = this.props;\n let { animationsDisabled } = this.props;\n animationsDisabled = animationsDisabled || value.animationsDisabled;\n\n if (value && value.points) {\n const { extraCSSRules } = model || {};\n const { points, sampleAnswers } = value;\n\n const rubricList = (\n <List component=\"nav\">\n {points\n .slice(0)\n .reverse()\n .map((desc, index) => {\n index = points.length - index - 1;\n const pointsLabel = value.excludeZero ? index + 1 : index;\n\n return (\n <React.Fragment key={index}>\n <StyledListItem key={`P${index}`}>\n <TitleText>\n {pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`}\n </TitleText>\n <Text dangerouslySetInnerHTML={{ __html: desc }} />\n </StyledListItem>\n\n {sampleAnswers && sampleAnswers[index] && (\n <StyledListItem key={`S${index}`}>\n <SampleTitleText>\n Sample Answer\n </SampleTitleText>\n <Text dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />\n </StyledListItem>\n )}\n </React.Fragment>\n );\n })}\n </List>\n );\n\n return (\n <StyledUiLayout extraCSSRules={extraCSSRules}>\n {/* screen reader only heading for navigation as per PD-5057 */}\n <HiddenScreenReader>Rubric</HiddenScreenReader>\n {!animationsDisabled ? (\n <React.Fragment>\n <RubricToggle\n id={'rubric-toggle'}\n tabIndex={0}\n role=\"button\"\n aria-expanded={this.state.rubricOpen}\n onClick={this.toggleRubric}\n onKeyPress={(e) => {\n if (e.key === 'Enter' || e.key === ' ') this.toggleRubric();\n }}\n >\n {this.state.linkPrefix} Rubric\n <ChevronStyle aria-hidden=\"true\">\n {this.state.rubricOpen ? (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"18 15 12 9 6 15\"></polyline>\n </svg>\n ) : (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n )}\n </ChevronStyle>\n </RubricToggle>\n <Collapse in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>\n {rubricList}\n </Collapse>\n </React.Fragment>\n ) : (\n rubricList\n )}\n </StyledUiLayout>\n );\n } else {\n return null;\n }\n }\n}\n\nexport default Rubric;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAP,sBAAA,CAAAC,OAAA;AAEA,MAAMO,cAAc,GAAG,IAAAC,cAAM,EAACC,kBAAQ,CAAC,CAAC;EACtCC,KAAK,EAAEA,eAAK,CAACC,IAAI,CAAC,CAAC;EACnBC,eAAe,EAAEF,eAAK,CAACG,UAAU,CAAC,CAAC;EACnC;EACA,uBAAuB,EAAE;IACvBC,cAAc,EAAE;EAClB,CAAC;EACD,oDAAoD,EAAE;IACpDC,OAAO,EAAE,UAAU;IACnBC,SAAS,EAAE;EACb,CAAC;EACD;EACA,gBAAgB,EAAE;IAChBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE,CAAC;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,MAAMC,cAAc,GAAG,IAAAZ,cAAM,EAACa,iBAAQ,CAAC,CAAC;EACtCC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wD,MAAM,CAACC,UAAU;EAClCjD,kBAAkB,EAAER,kBAAS,CAACG,IAAI;EAClCc,KAAK,EAAEnB;AACT,CAAC;AAAA,IAAA4D,QAAA,GAAA3D,OAAA,CAAAgB,OAAA,GAsHYN,MAAM","ignoreList":[]}
|
package/lib/print.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _client = require("react-dom/client");
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
12
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
13
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
14
|
+
const log = (0, _debug.default)('pie-element:rubric:print');
|
|
15
|
+
const preparePrintModel = (model, opts) => {
|
|
16
|
+
const instr = opts.role === 'instructor';
|
|
17
|
+
if (!instr) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
model.value = {
|
|
21
|
+
...model
|
|
22
|
+
};
|
|
23
|
+
model.mode = 'evaluate';
|
|
24
|
+
model.animationsDisabled = true;
|
|
25
|
+
return model;
|
|
26
|
+
};
|
|
27
|
+
class RubricPrint extends HTMLElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this._options = null;
|
|
31
|
+
this._model = null;
|
|
32
|
+
this._session = [];
|
|
33
|
+
this._root = null;
|
|
34
|
+
this._rerender = (0, _lodashEs.debounce)(() => {
|
|
35
|
+
if (this._model && this._session) {
|
|
36
|
+
const printModel = preparePrintModel(this._model, this._options);
|
|
37
|
+
const element = this._options && /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
38
|
+
...printModel
|
|
39
|
+
});
|
|
40
|
+
if (!this._root) {
|
|
41
|
+
this._root = (0, _client.createRoot)(this);
|
|
42
|
+
}
|
|
43
|
+
this._root.render(element);
|
|
44
|
+
queueMicrotask(() => {
|
|
45
|
+
log('render complete - render math');
|
|
46
|
+
(0, _mathRendering.renderMath)(this);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
log('skip');
|
|
50
|
+
}
|
|
51
|
+
}, 50, {
|
|
52
|
+
leading: false,
|
|
53
|
+
trailing: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
set options(o) {
|
|
57
|
+
this._options = o;
|
|
58
|
+
}
|
|
59
|
+
set model(s) {
|
|
60
|
+
this._model = s;
|
|
61
|
+
this._rerender();
|
|
62
|
+
}
|
|
63
|
+
connectedCallback() {}
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
if (this._root) {
|
|
66
|
+
this._root.unmount();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.default = RubricPrint;
|
|
71
|
+
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_lodashEs","_main","_mathRendering","_debug","log","debug","preparePrintModel","model","opts","instr","role","value","mode","animationsDisabled","RubricPrint","HTMLElement","constructor","_options","_model","_session","_root","_rerender","debounce","printModel","element","React","createElement","Main","createRoot","render","queueMicrotask","renderMath","leading","trailing","options","o","s","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\n\nconst log = debug('pie-element:rubric:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n if (!instr) {\n return {};\n }\n\n model.value = { ...model };\n model.mode = 'evaluate';\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class RubricPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n ...printModel,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,0BAA0B,CAAC;AAE7C,MAAMC,iBAAiB,GAAGA,CAACC,KAAK,EAAEC,IAAI,KAAK;EACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,KAAK,YAAY;EAExC,IAAI,CAACD,KAAK,EAAE;IACV,OAAO,CAAC,CAAC;EACX;EAEAF,KAAK,CAACI,KAAK,GAAG;IAAE,GAAGJ;EAAM,CAAC;EAC1BA,KAAK,CAACK,IAAI,GAAG,UAAU;EACvBL,KAAK,CAACM,kBAAkB,GAAG,IAAI;EAE/B,OAAON,KAAK;AACd,CAAC;AAEc,MAAMO,WAAW,SAASC,WAAW,CAAC;EACnDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;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AACA,KAAK,CAACmB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA3B,WAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "8.2.2-beta.
|
|
4
|
+
"version": "8.2.2-beta.7",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "pie framework developers",
|
|
32
32
|
"license": "ISC",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5f941f4fe6387747a9a7465feaff7f6e54c1ed29",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"postpublish": "../../scripts/postpublish"
|
|
36
36
|
}
|