@pie-element/rubric 6.3.4-next.3 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/defaults.js +2 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +90 -152
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +90 -149
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +11 -7
- package/configure/src/__tests__/index.test.jsx +12 -2
- package/configure/src/index.js +12 -2
- package/configure/src/main.jsx +11 -13
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +15 -28
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/index.js +38 -80
- package/lib/index.js.map +1 -1
- package/lib/main.js +182 -244
- package/lib/main.js.map +1 -1
- package/lib/print.js +41 -84
- package/lib/print.js.map +1 -1
- package/package.json +8 -13
- package/src/__tests__/rubric-view.test.jsx +12 -24
- package/src/index.js +14 -3
- package/src/main.jsx +100 -93
- package/src/print.js +13 -2
- package/configure/lib/pie-toolbox-rubric/authoring.js +0 -573
- package/configure/lib/pie-toolbox-rubric/authoring.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/index.js +0 -24
- package/configure/lib/pie-toolbox-rubric/index.js.map +0 -1
- package/configure/lib/pie-toolbox-rubric/point-menu.js +0 -172
- package/configure/lib/pie-toolbox-rubric/point-menu.js.map +0 -1
- package/configure/src/pie-toolbox-rubric/authoring.jsx +0 -449
- package/configure/src/pie-toolbox-rubric/index.js +0 -9
- package/configure/src/pie-toolbox-rubric/point-menu.jsx +0 -94
- package/esm/configure.js +0 -34632
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -68
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -12909
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
- package/esm/print.js +0 -13482
- package/esm/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -113
- package/module/demo.js +0 -33
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -71
- package/module/print.html +0 -18
- package/module/print.js +0 -1
- package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +0 -2521
package/lib/print.js
CHANGED
|
@@ -1,85 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
23
|
-
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
7
|
+
exports.default = void 0;
|
|
26
8
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
-
|
|
9
|
+
var _client = require("react-dom/client");
|
|
30
10
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
31
|
-
|
|
32
11
|
var _main = _interopRequireDefault(require("./main"));
|
|
33
|
-
|
|
34
12
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
35
|
-
|
|
36
13
|
var _debug = _interopRequireDefault(require("debug"));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
|
-
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; }
|
|
45
|
-
|
|
46
|
-
var log = (0, _debug["default"])('pie-element:rubric:print');
|
|
47
|
-
|
|
48
|
-
var preparePrintModel = function preparePrintModel(model, opts) {
|
|
49
|
-
var instr = opts.role === 'instructor';
|
|
50
|
-
|
|
14
|
+
const log = (0, _debug.default)('pie-element:rubric:print');
|
|
15
|
+
const preparePrintModel = (model, opts) => {
|
|
16
|
+
const instr = opts.role === 'instructor';
|
|
51
17
|
if (!instr) {
|
|
52
18
|
return {};
|
|
53
19
|
}
|
|
54
|
-
|
|
55
|
-
|
|
20
|
+
model.value = {
|
|
21
|
+
...model
|
|
22
|
+
};
|
|
56
23
|
model.mode = 'evaluate';
|
|
57
24
|
model.animationsDisabled = true;
|
|
58
25
|
return model;
|
|
59
26
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], _objectSpread({}, printModel));
|
|
79
|
-
|
|
80
|
-
_reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
|
|
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, _debounce.default)(() => {
|
|
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(() => {
|
|
81
45
|
log('render complete - render math');
|
|
82
|
-
(0, _mathRendering.renderMath)(
|
|
46
|
+
(0, _mathRendering.renderMath)(this);
|
|
83
47
|
});
|
|
84
48
|
} else {
|
|
85
49
|
log('skip');
|
|
@@ -88,27 +52,20 @@ var RubricPrint = /*#__PURE__*/function (_HTMLElement) {
|
|
|
88
52
|
leading: false,
|
|
89
53
|
trailing: true
|
|
90
54
|
});
|
|
91
|
-
return _this;
|
|
92
55
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this._rerender();
|
|
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();
|
|
105
67
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}]);
|
|
110
|
-
return RubricPrint;
|
|
111
|
-
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
|
|
112
|
-
|
|
113
|
-
exports["default"] = RubricPrint;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.default = RubricPrint;
|
|
114
71
|
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_debounce","_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/debounce';\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,GAAAH,sBAAA,CAAAC,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;IACP,IAAI,CAACC,QAAQ,GAAG,IAAI;IACpB,IAAI,CAACC,MAAM,GAAG,IAAI;IAClB,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,SAAS,GAAG,IAAAC,iBAAQ,EACvB,MAAM;MACJ,IAAI,IAAI,CAACJ,MAAM,IAAI,IAAI,CAACC,QAAQ,EAAE;QAChC,MAAMI,UAAU,GAAGjB,iBAAiB,CAAC,IAAI,CAACY,MAAM,EAAE,IAAI,CAACD,QAAQ,CAAC;QAEhE,MAAMO,OAAO,GACX,IAAI,CAACP,QAAQ,iBACbQ,cAAK,CAACC,aAAa,CAACC,aAAI,EAAE;UACxB,GAAGJ;QACL,CAAC,CAAC;QAEJ,IAAI,CAAC,IAAI,CAACH,KAAK,EAAE;UACf,IAAI,CAACA,KAAK,GAAG,IAAAQ,kBAAU,EAAC,IAAI,CAAC;QAC/B;QACA,IAAI,CAACR,KAAK,CAACS,MAAM,CAACL,OAAO,CAAC;QAC1BM,cAAc,CAAC,MAAM;UACnB1B,GAAG,CAAC,+BAA+B,CAAC;UACpC,IAAA2B,yBAAU,EAAC,IAAI,CAAC;QAClB,CAAC,CAAC;MACJ,CAAC,MAAM;QACL3B,GAAG,CAAC,MAAM,CAAC;MACb;IACF,CAAC,EACD,EAAE,EACF;MAAE4B,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAK,CACnC,CAAC;EACH;EACA,IAAIC,OAAOA,CAACC,CAAC,EAAE;IACb,IAAI,CAAClB,QAAQ,GAAGkB,CAAC;EACnB;EAEA,IAAI5B,KAAKA,CAAC6B,CAAC,EAAE;IACX,IAAI,CAAClB,MAAM,GAAGkB,CAAC;IACf,IAAI,CAACf,SAAS,CAAC,CAAC;EAClB;EAEAgB,iBAAiBA,CAAA,EAAG,CAAC;EAErBC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAAClB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACmB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA3B,WAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"description": "Rubric Scoring Interaction",
|
|
@@ -9,23 +9,18 @@
|
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
12
|
+
"@emotion/react": "^11.14.0",
|
|
13
|
+
"@emotion/style": "^0.8.0",
|
|
14
|
+
"@mui/icons-material": "^7.3.4",
|
|
15
|
+
"@mui/material": "^7.3.4",
|
|
16
|
+
"@pie-lib/math-rendering": "3.22.3-next.0",
|
|
17
|
+
"@pie-lib/render-ui": "4.35.4-next.0",
|
|
15
18
|
"prop-types": "^15.7.2"
|
|
16
19
|
},
|
|
17
20
|
"author": "pie framework developers",
|
|
18
21
|
"license": "ISC",
|
|
19
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "f7170c384c729616bce308c461c7443d6bc65ccc",
|
|
20
23
|
"scripts": {
|
|
21
24
|
"postpublish": "../../scripts/postpublish"
|
|
22
|
-
},
|
|
23
|
-
"exports": {
|
|
24
|
-
".": "./src/index.js",
|
|
25
|
-
"./print": "./src/print.js",
|
|
26
|
-
"./esm": "./esm/element.js",
|
|
27
|
-
"./configure/esm": "./esm/configure.js",
|
|
28
|
-
"./controller/esm": "./esm/controller.js",
|
|
29
|
-
"./print/esm": "./esm/print.js"
|
|
30
25
|
}
|
|
31
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import Rubric from '../main';
|
|
4
5
|
|
|
@@ -13,37 +14,24 @@ describe('rubric viewer', () => {
|
|
|
13
14
|
},
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
return
|
|
17
|
+
return render(<Rubric {...props} />);
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
describe('snapshot', () => {
|
|
20
|
-
it('renders', () => {
|
|
21
|
-
const w = wrapper();
|
|
22
|
-
expect(w).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('expanded snapshot', () => {
|
|
27
|
-
it('renders', () => {
|
|
28
|
-
const w = wrapper();
|
|
29
|
-
w.find('#rubric-toggle').simulate('click');
|
|
30
|
-
expect(w).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
20
|
describe('exclude zeros', () => {
|
|
35
|
-
it('renders correctly with excluded zeroes', () => {
|
|
36
|
-
let
|
|
21
|
+
it('renders correctly with excluded zeroes', async () => {
|
|
22
|
+
let result = wrapper({
|
|
37
23
|
excludeZero: true,
|
|
38
24
|
points: ['a teeny bit right', 'mostly right', 'bingo'],
|
|
39
25
|
sampleAnswers: ['just right', 'not left', null]
|
|
40
26
|
});
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
let toggle = result.container.querySelector('#rubric-toggle');
|
|
28
|
+
await userEvent.click(toggle);
|
|
29
|
+
expect(result.container.querySelectorAll('li').length).toEqual(5);
|
|
43
30
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
result = wrapper({excludeZero: false});
|
|
32
|
+
toggle = result.container.querySelector('#rubric-toggle');
|
|
33
|
+
await userEvent.click(toggle);
|
|
34
|
+
expect(result.container.querySelectorAll('li').length).toEqual(6);
|
|
47
35
|
});
|
|
48
36
|
});
|
|
49
37
|
});
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Rubric from './main';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import debug from 'debug';
|
|
5
5
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ export default class RubricRender extends HTMLElement {
|
|
|
9
9
|
super();
|
|
10
10
|
debug.log('constructor called');
|
|
11
11
|
this.onModelChanged = this.onModelChanged.bind(this);
|
|
12
|
+
this._root = null;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
set model(s) {
|
|
@@ -27,11 +28,21 @@ export default class RubricRender extends HTMLElement {
|
|
|
27
28
|
|
|
28
29
|
_render() {
|
|
29
30
|
if (this._model) {
|
|
30
|
-
const el =
|
|
31
|
+
const el = React.createElement(Rubric, { value: this._model });
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
if (!this._root) {
|
|
34
|
+
this._root = createRoot(this);
|
|
35
|
+
}
|
|
36
|
+
this._root.render(el);
|
|
37
|
+
queueMicrotask(() => {
|
|
33
38
|
renderMath(this);
|
|
34
39
|
});
|
|
35
40
|
}
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
if (this._root) {
|
|
45
|
+
this._root.unmount();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
}
|
package/src/main.jsx
CHANGED
|
@@ -1,11 +1,87 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import ListItem from '@material
|
|
4
|
-
import List from '@material
|
|
5
|
-
import Collapse from '@material
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import ListItem from '@mui/material/ListItem';
|
|
4
|
+
import List from '@mui/material/List';
|
|
5
|
+
import Collapse from '@mui/material/Collapse';
|
|
6
6
|
import { color, UiLayout } from '@pie-lib/render-ui';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
|
+
const StyledUiLayout = styled(UiLayout)({
|
|
10
|
+
color: color.text(),
|
|
11
|
+
backgroundColor: color.background(),
|
|
12
|
+
// apply styles to tables to match the rest of the UI
|
|
13
|
+
'&:not(.MathJax) table': {
|
|
14
|
+
borderCollapse: 'collapse',
|
|
15
|
+
},
|
|
16
|
+
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
17
|
+
padding: '8px 12px',
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
},
|
|
20
|
+
// reset paragraph margins and line-height inside lists to override client styles
|
|
21
|
+
'& ul p, & ol p': {
|
|
22
|
+
marginBottom: 0,
|
|
23
|
+
marginTop: 0,
|
|
24
|
+
lineHeight: 'normal',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const StyledListItem = styled(ListItem)({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
alignItems: 'flex-start',
|
|
32
|
+
padding: '12px 0px',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const Text = styled('div')({
|
|
36
|
+
color: color.text(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const TitleText = styled('h3')({
|
|
40
|
+
color: color.text(),
|
|
41
|
+
fontSize: '16px',
|
|
42
|
+
fontWeight: '700',
|
|
43
|
+
margin: 0,
|
|
44
|
+
paddingBottom: '6px',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const SampleTitleText = styled('h4')({
|
|
48
|
+
color: color.text(),
|
|
49
|
+
fontSize: '16px',
|
|
50
|
+
fontWeight: 'normal',
|
|
51
|
+
margin: 0,
|
|
52
|
+
paddingBottom: '6px',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const RubricToggle = styled('h2')(({ theme }) => ({
|
|
56
|
+
display: 'flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
userSelect: 'none',
|
|
60
|
+
fontSize: theme.typography.fontSize,
|
|
61
|
+
fontWeight: '500',
|
|
62
|
+
color: color.tertiary(),
|
|
63
|
+
margin: 0,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const ChevronStyle = styled('span')({
|
|
67
|
+
display: 'inline-flex',
|
|
68
|
+
transition: 'transform 0.2s',
|
|
69
|
+
marginLeft: 2,
|
|
70
|
+
alignSelf: 'center',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const HiddenScreenReader = styled('h2')({
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
width: '1px',
|
|
76
|
+
height: '1px',
|
|
77
|
+
padding: 0,
|
|
78
|
+
margin: '-1px',
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
clip: 'rect(0,0,0,0)',
|
|
81
|
+
border: 0,
|
|
82
|
+
whiteSpace: 'nowrap',
|
|
83
|
+
});
|
|
84
|
+
|
|
9
85
|
export const RubricType = PropTypes.shape({
|
|
10
86
|
excludeZero: PropTypes.bool,
|
|
11
87
|
points: PropTypes.arrayOf(PropTypes.string),
|
|
@@ -26,7 +102,6 @@ class Rubric extends React.Component {
|
|
|
26
102
|
}
|
|
27
103
|
|
|
28
104
|
static propTypes = {
|
|
29
|
-
classes: PropTypes.object.isRequired,
|
|
30
105
|
model: PropTypes.object.isRequired,
|
|
31
106
|
animationsDisabled: PropTypes.bool,
|
|
32
107
|
value: RubricType,
|
|
@@ -46,7 +121,7 @@ class Rubric extends React.Component {
|
|
|
46
121
|
};
|
|
47
122
|
|
|
48
123
|
render() {
|
|
49
|
-
const { model, value
|
|
124
|
+
const { model, value } = this.props;
|
|
50
125
|
let { animationsDisabled } = this.props;
|
|
51
126
|
animationsDisabled = animationsDisabled || value.animationsDisabled;
|
|
52
127
|
|
|
@@ -65,20 +140,20 @@ class Rubric extends React.Component {
|
|
|
65
140
|
|
|
66
141
|
return (
|
|
67
142
|
<React.Fragment key={index}>
|
|
68
|
-
<
|
|
69
|
-
<
|
|
143
|
+
<StyledListItem key={`P${index}`}>
|
|
144
|
+
<TitleText>
|
|
70
145
|
{pointsLabel === 1 ? `${pointsLabel} PT` : `${pointsLabel} PTS`}
|
|
71
|
-
</
|
|
72
|
-
<
|
|
73
|
-
</
|
|
146
|
+
</TitleText>
|
|
147
|
+
<Text dangerouslySetInnerHTML={{ __html: desc }} />
|
|
148
|
+
</StyledListItem>
|
|
74
149
|
|
|
75
150
|
{sampleAnswers && sampleAnswers[index] && (
|
|
76
|
-
<
|
|
77
|
-
<
|
|
151
|
+
<StyledListItem key={`S${index}`}>
|
|
152
|
+
<SampleTitleText>
|
|
78
153
|
Sample Answer
|
|
79
|
-
</
|
|
80
|
-
<
|
|
81
|
-
</
|
|
154
|
+
</SampleTitleText>
|
|
155
|
+
<Text dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
156
|
+
</StyledListItem>
|
|
82
157
|
)}
|
|
83
158
|
</React.Fragment>
|
|
84
159
|
);
|
|
@@ -87,14 +162,13 @@ class Rubric extends React.Component {
|
|
|
87
162
|
);
|
|
88
163
|
|
|
89
164
|
return (
|
|
90
|
-
<
|
|
165
|
+
<StyledUiLayout extraCSSRules={extraCSSRules}>
|
|
91
166
|
{/* screen reader only heading for navigation as per PD-5057 */}
|
|
92
|
-
<
|
|
167
|
+
<HiddenScreenReader>Rubric</HiddenScreenReader>
|
|
93
168
|
{!animationsDisabled ? (
|
|
94
169
|
<React.Fragment>
|
|
95
|
-
<
|
|
170
|
+
<RubricToggle
|
|
96
171
|
id={'rubric-toggle'}
|
|
97
|
-
className={classes.rubricToggle}
|
|
98
172
|
tabIndex={0}
|
|
99
173
|
role="button"
|
|
100
174
|
aria-expanded={this.state.rubricOpen}
|
|
@@ -104,7 +178,7 @@ class Rubric extends React.Component {
|
|
|
104
178
|
}}
|
|
105
179
|
>
|
|
106
180
|
{this.state.linkPrefix} Rubric
|
|
107
|
-
<
|
|
181
|
+
<ChevronStyle aria-hidden="true">
|
|
108
182
|
{this.state.rubricOpen ? (
|
|
109
183
|
<svg
|
|
110
184
|
width="20"
|
|
@@ -132,16 +206,16 @@ class Rubric extends React.Component {
|
|
|
132
206
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
133
207
|
</svg>
|
|
134
208
|
)}
|
|
135
|
-
</
|
|
136
|
-
</
|
|
137
|
-
<Collapse in={this.state.rubricOpen} timeout=
|
|
209
|
+
</ChevronStyle>
|
|
210
|
+
</RubricToggle>
|
|
211
|
+
<Collapse in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>
|
|
138
212
|
{rubricList}
|
|
139
213
|
</Collapse>
|
|
140
214
|
</React.Fragment>
|
|
141
215
|
) : (
|
|
142
216
|
rubricList
|
|
143
217
|
)}
|
|
144
|
-
</
|
|
218
|
+
</StyledUiLayout>
|
|
145
219
|
);
|
|
146
220
|
} else {
|
|
147
221
|
return null;
|
|
@@ -149,71 +223,4 @@ class Rubric extends React.Component {
|
|
|
149
223
|
}
|
|
150
224
|
}
|
|
151
225
|
|
|
152
|
-
|
|
153
|
-
root: {
|
|
154
|
-
color: color.text(),
|
|
155
|
-
backgroundColor: color.background(),
|
|
156
|
-
// apply styles to tables to match the rest of the UI
|
|
157
|
-
'&:not(.MathJax) table': {
|
|
158
|
-
borderCollapse: 'collapse',
|
|
159
|
-
},
|
|
160
|
-
'&:not(.MathJax) table td, &:not(.MathJax) table th': {
|
|
161
|
-
padding: '8px 12px',
|
|
162
|
-
textAlign: 'left',
|
|
163
|
-
},
|
|
164
|
-
// reset paragraph margins and line-height inside lists to override client styles
|
|
165
|
-
'& ul p, & ol p': {
|
|
166
|
-
marginBottom: 0,
|
|
167
|
-
marginTop: 0,
|
|
168
|
-
lineHeight: 'normal',
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
listColumn: {
|
|
172
|
-
display: 'flex',
|
|
173
|
-
flexDirection: 'column',
|
|
174
|
-
alignItems: 'flex-start',
|
|
175
|
-
padding: '12px 0px',
|
|
176
|
-
},
|
|
177
|
-
listColumnItem: {
|
|
178
|
-
padding: 0,
|
|
179
|
-
},
|
|
180
|
-
text: {
|
|
181
|
-
color: color.text(),
|
|
182
|
-
},
|
|
183
|
-
titleText: {
|
|
184
|
-
color: color.text(),
|
|
185
|
-
fontSize: '16px',
|
|
186
|
-
fontWeight: '700',
|
|
187
|
-
margin: 0,
|
|
188
|
-
paddingBottom: '6px',
|
|
189
|
-
},
|
|
190
|
-
rubricToggle: {
|
|
191
|
-
display: 'flex',
|
|
192
|
-
alignItems: 'center',
|
|
193
|
-
cursor: 'pointer',
|
|
194
|
-
userSelect: 'none',
|
|
195
|
-
fontSize: theme.typography.fontSize,
|
|
196
|
-
fontWeight: '500',
|
|
197
|
-
color: color.tertiary(),
|
|
198
|
-
margin: 0,
|
|
199
|
-
},
|
|
200
|
-
chevronStyle: {
|
|
201
|
-
display: 'inline-flex',
|
|
202
|
-
transition: 'transform 0.2s',
|
|
203
|
-
marginLeft: 2,
|
|
204
|
-
alignSelf: 'center',
|
|
205
|
-
},
|
|
206
|
-
hiddenScreenReader: {
|
|
207
|
-
position: 'absolute',
|
|
208
|
-
width: '1px',
|
|
209
|
-
height: '1px',
|
|
210
|
-
padding: 0,
|
|
211
|
-
margin: '-1px',
|
|
212
|
-
overflow: 'hidden',
|
|
213
|
-
clip: 'rect(0,0,0,0)',
|
|
214
|
-
border: 0,
|
|
215
|
-
whiteSpace: 'nowrap',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
export default withStyles(styles)(Rubric);
|
|
226
|
+
export default Rubric;
|
package/src/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import Main from './main';
|
|
5
5
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
@@ -27,6 +27,7 @@ export default class RubricPrint extends HTMLElement {
|
|
|
27
27
|
this._options = null;
|
|
28
28
|
this._model = null;
|
|
29
29
|
this._session = [];
|
|
30
|
+
this._root = null;
|
|
30
31
|
this._rerender = debounce(
|
|
31
32
|
() => {
|
|
32
33
|
if (this._model && this._session) {
|
|
@@ -38,7 +39,11 @@ export default class RubricPrint extends HTMLElement {
|
|
|
38
39
|
...printModel,
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
if (!this._root) {
|
|
43
|
+
this._root = createRoot(this);
|
|
44
|
+
}
|
|
45
|
+
this._root.render(element);
|
|
46
|
+
queueMicrotask(() => {
|
|
42
47
|
log('render complete - render math');
|
|
43
48
|
renderMath(this);
|
|
44
49
|
});
|
|
@@ -60,4 +65,10 @@ export default class RubricPrint extends HTMLElement {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
connectedCallback() {}
|
|
68
|
+
|
|
69
|
+
disconnectedCallback() {
|
|
70
|
+
if (this._root) {
|
|
71
|
+
this._root.unmount();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
63
74
|
}
|