@pie-element/rubric 1.6.3-next.359 → 1.6.3-next.403
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/lib/main.js +20 -14
- package/lib/main.js.map +1 -1
- package/lib/print.js +114 -0
- package/lib/print.js.map +1 -0
- package/package.json +6 -2
- package/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +6 -6
- package/src/main.jsx +49 -40
- package/src/print.js +63 -0
package/lib/main.js
CHANGED
|
@@ -92,20 +92,14 @@ var Rubric = /*#__PURE__*/function (_React$Component) {
|
|
|
92
92
|
|
|
93
93
|
var _this$props = this.props,
|
|
94
94
|
value = _this$props.value,
|
|
95
|
-
classes = _this$props.classes
|
|
95
|
+
classes = _this$props.classes,
|
|
96
|
+
animationsDisabled = _this$props.animationsDisabled;
|
|
96
97
|
|
|
97
98
|
if (value && value.points) {
|
|
98
99
|
var points = value.points,
|
|
99
100
|
sampleAnswers = value.sampleAnswers;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}, /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
103
|
-
href: this.dudUrl,
|
|
104
|
-
onClick: this.toggleRubric
|
|
105
|
-
}, this.state.linkPrefix, " Rubric"), /*#__PURE__*/_react["default"].createElement(_Collapse["default"], {
|
|
106
|
-
"in": this.state.rubricOpen,
|
|
107
|
-
timeout: "auto"
|
|
108
|
-
}, /*#__PURE__*/_react["default"].createElement(_List["default"], {
|
|
101
|
+
|
|
102
|
+
var rubricList = /*#__PURE__*/_react["default"].createElement(_List["default"], {
|
|
109
103
|
component: "nav"
|
|
110
104
|
}, points.map(function (desc, index) {
|
|
111
105
|
return _this2.shouldRenderPoint(index, value) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
@@ -114,14 +108,14 @@ var Rubric = /*#__PURE__*/function (_React$Component) {
|
|
|
114
108
|
key: "P".concat(index)
|
|
115
109
|
}, /*#__PURE__*/_react["default"].createElement(_ListItemText["default"], {
|
|
116
110
|
className: classes.rubricCol,
|
|
117
|
-
primary: "".concat(index, " PTS")
|
|
111
|
+
primary: index === 1 ? "".concat(index, " PT") : "".concat(index, " PTS")
|
|
118
112
|
}), /*#__PURE__*/_react["default"].createElement(_ListItemText["default"], {
|
|
119
113
|
primary: /*#__PURE__*/_react["default"].createElement("div", {
|
|
120
114
|
dangerouslySetInnerHTML: {
|
|
121
115
|
__html: desc
|
|
122
116
|
}
|
|
123
117
|
})
|
|
124
|
-
})), sampleAnswers && sampleAnswers[index] &&
|
|
118
|
+
})), sampleAnswers && sampleAnswers[index] && /*#__PURE__*/_react["default"].createElement(_ListItem["default"], {
|
|
125
119
|
key: "S".concat(index)
|
|
126
120
|
}, /*#__PURE__*/_react["default"].createElement(_ListItemText["default"], {
|
|
127
121
|
className: classes.rubricCol,
|
|
@@ -136,7 +130,17 @@ var Rubric = /*#__PURE__*/function (_React$Component) {
|
|
|
136
130
|
}
|
|
137
131
|
})
|
|
138
132
|
})));
|
|
139
|
-
}))
|
|
133
|
+
}));
|
|
134
|
+
|
|
135
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
136
|
+
className: classes.root
|
|
137
|
+
}, !animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
138
|
+
href: this.dudUrl,
|
|
139
|
+
onClick: this.toggleRubric
|
|
140
|
+
}, this.state.linkPrefix, " Rubric"), /*#__PURE__*/_react["default"].createElement(_Collapse["default"], {
|
|
141
|
+
"in": this.state.rubricOpen,
|
|
142
|
+
timeout: "auto"
|
|
143
|
+
}, rubricList)) : rubricList);
|
|
140
144
|
} else {
|
|
141
145
|
return null;
|
|
142
146
|
}
|
|
@@ -147,13 +151,15 @@ var Rubric = /*#__PURE__*/function (_React$Component) {
|
|
|
147
151
|
|
|
148
152
|
(0, _defineProperty2["default"])(Rubric, "propTypes", {
|
|
149
153
|
classes: _propTypes["default"].object.isRequired,
|
|
154
|
+
animationsDisabled: _propTypes["default"].bool,
|
|
150
155
|
value: RubricType
|
|
151
156
|
});
|
|
152
157
|
|
|
153
158
|
var styles = function styles() {
|
|
154
159
|
return {
|
|
155
160
|
rubricCol: {
|
|
156
|
-
flex: '0 1 auto'
|
|
161
|
+
flex: '0 1 auto',
|
|
162
|
+
minWidth: 'fit-content'
|
|
157
163
|
}
|
|
158
164
|
};
|
|
159
165
|
};
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["RubricType","PropTypes","shape","excludeZero","bool","points","arrayOf","string","sampleAnswers","Rubric","props","index","value","state","rubricOpen","linkPrefix","toggleRubric","bind","setState","classes","
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["RubricType","PropTypes","shape","excludeZero","bool","points","arrayOf","string","sampleAnswers","Rubric","props","index","value","state","rubricOpen","linkPrefix","toggleRubric","bind","setState","classes","animationsDisabled","rubricList","map","desc","shouldRenderPoint","rubricCol","__html","marginLeft","root","dudUrl","React","Component","object","isRequired","styles","flex","minWidth"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,UAAU,GAAGC,sBAAUC,KAAV,CAAgB;AACxCC,EAAAA,WAAW,EAAEF,sBAAUG,IADiB;AAExCC,EAAAA,MAAM,EAAEJ,sBAAUK,OAAV,CAAkBL,sBAAUM,MAA5B,CAFgC;AAGxCC,EAAAA,aAAa,EAAEP,sBAAUK,OAAV,CAAkBL,sBAAUM,MAA5B;AAHyB,CAAhB,CAAnB;;;;IAMDE,M;;;;;AAGJ,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,+FAFV,cAEU;AAAA,0GAoBC,UAACC,KAAD,EAAQC,KAAR,EAAkB;AACpC,UAAI,CAACA,KAAK,CAACT,WAAX,EAAwB;AACtB,eA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MAAS;AAAA,SAAO;AACpBT,IAAAA,SAAS,EAAE;AACTU,MAAAA,IAAI,EAAE,UADG;AAETC,MAAAA,QAAQ,EAAE;AAFD;AADS,GAAP;AAAA,CAAf;;eAOe,wBAAWF,MAAX,EAAmBzB,MAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport ListItem from '@material-ui/core/ListItem';\nimport List from '@material-ui/core/List';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Link from '@material-ui/core/Link';\nimport Collapse from '@material-ui/core/Collapse';\nimport PropTypes from 'prop-types';\n\nexport const RubricType = PropTypes.shape({\n excludeZero: PropTypes.bool,\n points: PropTypes.arrayOf(PropTypes.string),\n sampleAnswers: PropTypes.arrayOf(PropTypes.string),\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 classes: 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 { value, classes, animationsDisabled } = this.props;\n\n if (value && value.points) {\n const { points, sampleAnswers } = value;\n\n const rubricList = <List component=\"nav\">\n {points.map(\n (desc, index) =>\n this.shouldRenderPoint(index, value) && (\n <React.Fragment key={index}>\n <ListItem key={`P${index}`}>\n <ListItemText\n className={classes.rubricCol}\n primary={index === 1 ? `${index} PT` : `${index} PTS`}\n />\n <ListItemText\n primary={\n <div dangerouslySetInnerHTML={{ __html: desc }} />\n }\n />\n </ListItem>\n {sampleAnswers && sampleAnswers[index] && (\n <ListItem key={`S${index}`}>\n <ListItemText\n className={classes.rubricCol}\n style={{marginLeft: '20px'}}\n primary={'Sample Answer'}\n />\n <ListItemText\n primary={\n <div dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />\n }\n />\n </ListItem>\n )}\n </React.Fragment>\n )\n )}\n </List>;\n\n return (\n <div className={classes.root}>\n {!animationsDisabled ?\n <React.Fragment>\n <Link href={this.dudUrl} onClick={this.toggleRubric}>\n {this.state.linkPrefix} Rubric\n </Link>\n <Collapse in={this.state.rubricOpen} timeout=\"auto\">\n {rubricList}\n </Collapse>\n </React.Fragment>\n : rubricList\n }\n </div>\n );\n } else {\n return null;\n }\n }\n}\n\nconst styles = () => ({\n rubricCol: {\n flex: '0 1 auto',\n minWidth: 'fit-content'\n },\n});\n\nexport default withStyles(styles)(Rubric);\n"],"file":"main.js"}
|
package/lib/print.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
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
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
+
|
|
30
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
31
|
+
|
|
32
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
33
|
+
|
|
34
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
35
|
+
|
|
36
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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
|
+
|
|
51
|
+
if (!instr) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
model.value = _objectSpread({}, model);
|
|
56
|
+
model.mode = 'evaluate';
|
|
57
|
+
model.animationsDisabled = true;
|
|
58
|
+
return model;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var RubricPrint = /*#__PURE__*/function (_HTMLElement) {
|
|
62
|
+
(0, _inherits2["default"])(RubricPrint, _HTMLElement);
|
|
63
|
+
|
|
64
|
+
var _super = _createSuper(RubricPrint);
|
|
65
|
+
|
|
66
|
+
function RubricPrint() {
|
|
67
|
+
var _this;
|
|
68
|
+
|
|
69
|
+
(0, _classCallCheck2["default"])(this, RubricPrint);
|
|
70
|
+
_this = _super.call(this);
|
|
71
|
+
_this._options = null;
|
|
72
|
+
_this._model = null;
|
|
73
|
+
_this._session = [];
|
|
74
|
+
_this._rerender = (0, _debounce["default"])(function () {
|
|
75
|
+
if (_this._model && _this._session) {
|
|
76
|
+
var printModel = preparePrintModel(_this._model, _this._options);
|
|
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 () {
|
|
81
|
+
log('render complete - render math');
|
|
82
|
+
(0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
log('skip');
|
|
86
|
+
}
|
|
87
|
+
}, 50, {
|
|
88
|
+
leading: false,
|
|
89
|
+
trailing: true
|
|
90
|
+
});
|
|
91
|
+
return _this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
(0, _createClass2["default"])(RubricPrint, [{
|
|
95
|
+
key: "options",
|
|
96
|
+
set: function set(o) {
|
|
97
|
+
this._options = o;
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "model",
|
|
101
|
+
set: function set(s) {
|
|
102
|
+
this._model = s;
|
|
103
|
+
|
|
104
|
+
this._rerender();
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "connectedCallback",
|
|
108
|
+
value: function connectedCallback() {}
|
|
109
|
+
}]);
|
|
110
|
+
return RubricPrint;
|
|
111
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
|
|
112
|
+
|
|
113
|
+
exports["default"] = RubricPrint;
|
|
114
|
+
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","value","mode","animationsDisabled","RubricPrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0BAAN,CAAZ;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;;AAEA,MAAI,CAACD,KAAL,EAAY;AACV,WAAO,EAAP;AACD;;AAEDF,EAAAA,KAAK,CAACI,KAAN,qBAAmBJ,KAAnB;AACAA,EAAAA,KAAK,CAACK,IAAN,GAAa,UAAb;AACAL,EAAAA,KAAK,CAACM,kBAAN,GAA2B,IAA3B;AAEA,SAAON,KAAP;AACD,CAZD;;IAcqBO,W;;;;;AACnB,yBAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,QAAL,GAAgB,IAAhB;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,EAAhB;AACA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAME,UAAU,GAAGb,iBAAiB,CAAC,MAAKU,MAAN,EAAc,MAAKD,QAAnB,CAApC;;AAEA,YAAMK,OAAO,GACX,MAAKL,QAAL,iBACAM,kBAAMC,aAAN,CAAoBC,gBAApB,oBACKJ,UADL,EAFF;;AAMAK,6BAASC,MAAT,CAAgBL,OAAhB,kDAA+B,YAAM;AACnCf,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAbD,MAaO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KAlBc,EAmBf,EAnBe,EAoBf;AAAEqB,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KApBe,CAAjB;AALY;AA2Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKb,QAAL,GAAgBa,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKb,MAAL,GAAca,CAAd;;AACA,WAAKX,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAtCiBY,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\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._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 ReactDOM.render(element, this, () => {\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"],"file":"print.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric",
|
|
3
|
-
"version": "1.6.3-next.
|
|
3
|
+
"version": "1.6.3-next.403+a63e6b6a4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"description": "Rubric Scoring Interaction",
|
|
@@ -14,8 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"author": "pie framework developers",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "a63e6b6a49a139626337d47b85fda7e741f21068",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"postpublish": "../../scripts/postpublish"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./src/index.js",
|
|
23
|
+
"./print": "./src/print.js"
|
|
20
24
|
}
|
|
21
25
|
}
|
|
@@ -2724,7 +2724,7 @@ exports[`rubric viewer expanded snapshot renders 1`] = `
|
|
|
2724
2724
|
<WithStyles(ListItemText)
|
|
2725
2725
|
className="Rubric-rubricCol-1"
|
|
2726
2726
|
key=".0"
|
|
2727
|
-
primary="1
|
|
2727
|
+
primary="1 PT"
|
|
2728
2728
|
>
|
|
2729
2729
|
<ListItemText
|
|
2730
2730
|
className="Rubric-rubricCol-1"
|
|
@@ -2740,7 +2740,7 @@ exports[`rubric viewer expanded snapshot renders 1`] = `
|
|
|
2740
2740
|
}
|
|
2741
2741
|
disableTypography={false}
|
|
2742
2742
|
inset={false}
|
|
2743
|
-
primary="1
|
|
2743
|
+
primary="1 PT"
|
|
2744
2744
|
theme={
|
|
2745
2745
|
Object {
|
|
2746
2746
|
"breakpoints": Object {
|
|
@@ -3549,7 +3549,7 @@ exports[`rubric viewer expanded snapshot renders 1`] = `
|
|
|
3549
3549
|
<span
|
|
3550
3550
|
className="MuiTypography-root-7 MuiTypography-subheading-14 MuiListItemText-primary-66"
|
|
3551
3551
|
>
|
|
3552
|
-
1
|
|
3552
|
+
1 PT
|
|
3553
3553
|
</span>
|
|
3554
3554
|
</Typography>
|
|
3555
3555
|
</WithStyles(Typography)>
|
|
@@ -14107,7 +14107,7 @@ exports[`rubric viewer snapshot renders 1`] = `
|
|
|
14107
14107
|
<WithStyles(ListItemText)
|
|
14108
14108
|
className="Rubric-rubricCol-1"
|
|
14109
14109
|
key=".0"
|
|
14110
|
-
primary="1
|
|
14110
|
+
primary="1 PT"
|
|
14111
14111
|
>
|
|
14112
14112
|
<ListItemText
|
|
14113
14113
|
className="Rubric-rubricCol-1"
|
|
@@ -14123,7 +14123,7 @@ exports[`rubric viewer snapshot renders 1`] = `
|
|
|
14123
14123
|
}
|
|
14124
14124
|
disableTypography={false}
|
|
14125
14125
|
inset={false}
|
|
14126
|
-
primary="1
|
|
14126
|
+
primary="1 PT"
|
|
14127
14127
|
theme={
|
|
14128
14128
|
Object {
|
|
14129
14129
|
"breakpoints": Object {
|
|
@@ -14932,7 +14932,7 @@ exports[`rubric viewer snapshot renders 1`] = `
|
|
|
14932
14932
|
<span
|
|
14933
14933
|
className="MuiTypography-root-7 MuiTypography-subheading-14 MuiListItemText-primary-66"
|
|
14934
14934
|
>
|
|
14935
|
-
1
|
|
14935
|
+
1 PT
|
|
14936
14936
|
</span>
|
|
14937
14937
|
</Typography>
|
|
14938
14938
|
</WithStyles(Typography)>
|
package/src/main.jsx
CHANGED
|
@@ -27,6 +27,7 @@ class Rubric extends React.Component {
|
|
|
27
27
|
|
|
28
28
|
static propTypes = {
|
|
29
29
|
classes: PropTypes.object.isRequired,
|
|
30
|
+
animationsDisabled: PropTypes.bool,
|
|
30
31
|
value: RubricType,
|
|
31
32
|
};
|
|
32
33
|
|
|
@@ -44,52 +45,59 @@ class Rubric extends React.Component {
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
render() {
|
|
47
|
-
const { value, classes } = this.props;
|
|
48
|
+
const { value, classes, animationsDisabled } = this.props;
|
|
48
49
|
|
|
49
50
|
if (value && value.points) {
|
|
50
51
|
const { points, sampleAnswers } = value;
|
|
51
52
|
|
|
53
|
+
const rubricList = <List component="nav">
|
|
54
|
+
{points.map(
|
|
55
|
+
(desc, index) =>
|
|
56
|
+
this.shouldRenderPoint(index, value) && (
|
|
57
|
+
<React.Fragment key={index}>
|
|
58
|
+
<ListItem key={`P${index}`}>
|
|
59
|
+
<ListItemText
|
|
60
|
+
className={classes.rubricCol}
|
|
61
|
+
primary={index === 1 ? `${index} PT` : `${index} PTS`}
|
|
62
|
+
/>
|
|
63
|
+
<ListItemText
|
|
64
|
+
primary={
|
|
65
|
+
<div dangerouslySetInnerHTML={{ __html: desc }} />
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
</ListItem>
|
|
69
|
+
{sampleAnswers && sampleAnswers[index] && (
|
|
70
|
+
<ListItem key={`S${index}`}>
|
|
71
|
+
<ListItemText
|
|
72
|
+
className={classes.rubricCol}
|
|
73
|
+
style={{marginLeft: '20px'}}
|
|
74
|
+
primary={'Sample Answer'}
|
|
75
|
+
/>
|
|
76
|
+
<ListItemText
|
|
77
|
+
primary={
|
|
78
|
+
<div dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
79
|
+
}
|
|
80
|
+
/>
|
|
81
|
+
</ListItem>
|
|
82
|
+
)}
|
|
83
|
+
</React.Fragment>
|
|
84
|
+
)
|
|
85
|
+
)}
|
|
86
|
+
</List>;
|
|
87
|
+
|
|
52
88
|
return (
|
|
53
89
|
<div className={classes.root}>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
className={classes.rubricCol}
|
|
66
|
-
primary={`${index} PTS`}
|
|
67
|
-
/>
|
|
68
|
-
<ListItemText
|
|
69
|
-
primary={
|
|
70
|
-
<div dangerouslySetInnerHTML={{ __html: desc }} />
|
|
71
|
-
}
|
|
72
|
-
/>
|
|
73
|
-
</ListItem>
|
|
74
|
-
{sampleAnswers && sampleAnswers[index] && sampleAnswers[index] !== 'null' && (
|
|
75
|
-
<ListItem key={`S${index}`}>
|
|
76
|
-
<ListItemText
|
|
77
|
-
className={classes.rubricCol}
|
|
78
|
-
style={{marginLeft: '20px'}}
|
|
79
|
-
primary={'Sample Answer'}
|
|
80
|
-
/>
|
|
81
|
-
<ListItemText
|
|
82
|
-
primary={
|
|
83
|
-
<div dangerouslySetInnerHTML={{ __html: sampleAnswers[index] }} />
|
|
84
|
-
}
|
|
85
|
-
/>
|
|
86
|
-
</ListItem>
|
|
87
|
-
)}
|
|
88
|
-
</React.Fragment>
|
|
89
|
-
)
|
|
90
|
-
)}
|
|
91
|
-
</List>
|
|
92
|
-
</Collapse>
|
|
90
|
+
{!animationsDisabled ?
|
|
91
|
+
<React.Fragment>
|
|
92
|
+
<Link href={this.dudUrl} onClick={this.toggleRubric}>
|
|
93
|
+
{this.state.linkPrefix} Rubric
|
|
94
|
+
</Link>
|
|
95
|
+
<Collapse in={this.state.rubricOpen} timeout="auto">
|
|
96
|
+
{rubricList}
|
|
97
|
+
</Collapse>
|
|
98
|
+
</React.Fragment>
|
|
99
|
+
: rubricList
|
|
100
|
+
}
|
|
93
101
|
</div>
|
|
94
102
|
);
|
|
95
103
|
} else {
|
|
@@ -101,6 +109,7 @@ class Rubric extends React.Component {
|
|
|
101
109
|
const styles = () => ({
|
|
102
110
|
rubricCol: {
|
|
103
111
|
flex: '0 1 auto',
|
|
112
|
+
minWidth: 'fit-content'
|
|
104
113
|
},
|
|
105
114
|
});
|
|
106
115
|
|
package/src/print.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import Main from './main';
|
|
5
|
+
import { renderMath } from '@pie-lib/math-rendering';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
|
|
8
|
+
const log = debug('pie-element:rubric:print');
|
|
9
|
+
|
|
10
|
+
const preparePrintModel = (model, opts) => {
|
|
11
|
+
const instr = opts.role === 'instructor';
|
|
12
|
+
|
|
13
|
+
if (!instr) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model.value = { ...model };
|
|
18
|
+
model.mode = 'evaluate';
|
|
19
|
+
model.animationsDisabled = true;
|
|
20
|
+
|
|
21
|
+
return model;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default class RubricPrint extends HTMLElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this._options = null;
|
|
28
|
+
this._model = null;
|
|
29
|
+
this._session = [];
|
|
30
|
+
this._rerender = debounce(
|
|
31
|
+
() => {
|
|
32
|
+
if (this._model && this._session) {
|
|
33
|
+
const printModel = preparePrintModel(this._model, this._options);
|
|
34
|
+
|
|
35
|
+
const element =
|
|
36
|
+
this._options &&
|
|
37
|
+
React.createElement(Main, {
|
|
38
|
+
...printModel,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
ReactDOM.render(element, this, () => {
|
|
42
|
+
log('render complete - render math');
|
|
43
|
+
renderMath(this);
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
log('skip');
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
50,
|
|
50
|
+
{ leading: false, trailing: true }
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
set options(o) {
|
|
54
|
+
this._options = o;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set model(s) {
|
|
58
|
+
this._model = s;
|
|
59
|
+
this._rerender();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
connectedCallback() {}
|
|
63
|
+
}
|