@pie-element/rubric 4.7.2-next.6 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
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
+ ## [4.7.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric@4.7.1...@pie-element/rubric@4.7.2) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
12
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
13
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
14
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
15
+ * **rubric:** disable and set excludeZero to false when maxPoints is 1 PD-4832 ([7b749c0](https://github.com/pie-framework/pie-elements/commit/7b749c0cbda239a0aac7322bf1e4a3a9f5ed53ed))
16
+
17
+
18
+
19
+
20
+
6
21
  ## [4.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric@4.7.0...@pie-element/rubric@4.7.1) (2025-05-22)
7
22
 
8
23
 
@@ -3,6 +3,21 @@
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
+ ## [4.6.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-configure@4.6.1...@pie-element/rubric-configure@4.6.2) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
12
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
13
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
14
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
15
+ * **rubric:** disable and set excludeZero to false when maxPoints is 1 PD-4832 ([7b749c0](https://github.com/pie-framework/pie-elements/commit/7b749c0cbda239a0aac7322bf1e4a3a9f5ed53ed))
16
+
17
+
18
+
19
+
20
+
6
21
  ## [4.6.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-configure@4.6.0...@pie-element/rubric-configure@4.6.1) (2025-05-22)
7
22
 
8
23
 
@@ -70,7 +70,12 @@ var RubricElement = /*#__PURE__*/function (_HTMLElement) {
70
70
  return currentModel;
71
71
  }
72
72
 
73
- var validatedModel = nextModel;
73
+ var validatedModel = _objectSpread({}, nextModel); // excludeZero should be false and disabled when maxPoints is 1
74
+
75
+
76
+ if (validatedModel.maxPoints === 1) {
77
+ validatedModel.excludeZero = false;
78
+ }
74
79
 
75
80
  var _ref = validatedModel || {},
76
81
  maxPoints = _ref.maxPoints,
@@ -169,8 +174,6 @@ var RubricElement = /*#__PURE__*/function (_HTMLElement) {
169
174
  }, {
170
175
  key: "_render",
171
176
  value: function _render() {
172
- console.log('THE MODEL', this._model);
173
-
174
177
  if (this._model) {
175
178
  var element = /*#__PURE__*/_react["default"].createElement(_main["default"], {
176
179
  model: this._model,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["modelWithDefaults","m","defaults","model","configurationWithDefaults","c","configuration","RubricElement","nextModel","currentModel","_model","validatedModel","maxPoints","excludeZero","points","sampleAnswers","howManyPointsShouldHave","howManyPointsDoesItHave","length","excludeZeroChanged","maxPointsChanged","i","push","slice","_configuration","onModelChanged","_render","debug","log","bind","onConfigurationChanged","updateModelAccordingToReceivedProps","dispatchEvent","ModelUpdatedEvent","handler","InsertImageEvent","src","done","DeleteImageEvent","console","element","React","createElement","Main","imageSupport","add","insertImage","onDeleteImage","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD;AAAA,yCAAYC,qBAASC,KAArB,GAA+BF,CAA/B;AAAA,CAA1B;;AACA,IAAMG,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,CAAD;AAAA,yCAAYH,qBAASI,aAArB,GAAuCD,CAAvC;AAAA,CAAlC;;IAEqBE,a;;;;;AAGjB,2BAAc;AAAA;;AAAA;AACV;AADU,4HASwB,UAACC,SAAD,EAAe;AACjD,UAAMC,YAAY,qBAAO,MAAKC,MAAZ,CAAlB;;AACA,UAAI,CAACF,SAAL,EAAgB;AACZ,eAAOC,YAAP;AACH;;AAED,UAAME,cAAc,GAAGH,SAAvB;;AACA,iBAAmCG,cAAc,IAAI,EAArD;AAAA,UAAQC,SAAR,QAAQA,SAAR;AAAA,UAAmBC,WAAnB,QAAmBA,WAAnB;;AAEAF,MAAAA,cAAc,CAACG,MAAf,GAAwBH,cAAc,CAACG,MAAf,uCAA4BH,cAAc,CAACG,MAA3C,IAAqD,EAA7E;AACAH,MAAAA,cAAc,CAACI,aAAf,GAA+BJ,cAAc,CAACI,aAAf,uCAAmCJ,cAAc,CAACI,aAAlD,IAAmE,EAAlG;AAEA,UAAMC,uBAAuB,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AAmC,KAAnC,CAAnB;AACH;;;WAYD,qBAAYwB,OAAZ,EAAqB;AACjB,WAAKF,aAAL,CAAmB,IAAIG,oCAAJ,CAAqBD,OAArB,CAAnB;AACH;;;WAED,uBAAcE,GAAd,EAAmBC,IAAnB,EAAyB;AACrB,WAAKL,aAAL,CAAmB,IAAIM,oCAAJ,CAAqBF,GAArB,EAA0BC,IAA1B,CAAnB;AACH;;;WAED,6BAAoB;AAChB,WAAKX,OAAL;AACH;;;WAED,mBAAU;AACNa,MAAAA,OAAO,CAACX,GAAR,CAAY,WAAZ,EAAyB,KAAKlB,MAA9B;;AACA,UAAI,KAAKA,MAAT,EAAiB;AACb,YAAI8B,OAAO,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACpCxC,UAAAA,KAAK,EAAE,KAAKO,MADwB;AAEpCJ,UAAAA,aAAa,EAAE,KAAKkB,cAFgB;AAGpCC,UAAAA,cAAc,EAAE,KAAKA,cAHe;AAIpCK,UAAAA,sBAAsB,EAAE,KAAKA,sBAJO;AAKpCc,UAAAA,YAAY,EAAE;AACVC,YAAAA,GAAG,EAAE,KAAKC,WAAL,CAAiBjB,IAAjB,CAAsB,IAAtB,CADK;AAEV,sBAAQ,KAAKkB,aAAL,CAAmBlB,IAAnB,CAAwB,IAAxB;AAFE;AALsB,SAA1B,CAAd;;AAWAmB,6BAASC,MAAT,CAAgBT,OAAhB,EAAyB,IAAzB;AACH;AACJ;;;kDA9GsCU,W","sourcesContent":["import {\n ModelUpdatedEvent,\n InsertImageEvent,\n DeleteImageEvent\n} from '@pie-framework/pie-configure-events';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\n\nimport Main from './main';\nimport defaults from './defaults';\n\nconst modelWithDefaults = (m) => ({...defaults.model, ...m});\nconst configurationWithDefaults = (c) => ({...defaults.configuration, ...c});\n\nexport default class RubricElement extends HTMLElement {\n\n\n constructor() {\n super();\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 if (!nextModel) {\n return currentModel;\n }\n\n const validatedModel = nextModel;\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 if (maxPointsChanged) {\n for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {\n validatedModel.points.push('');\n validatedModel.sampleAnswers.push(null);\n }\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 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 console.log('THE MODEL', this._model);\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 ReactDOM.render(element, this);\n }\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["modelWithDefaults","m","defaults","model","configurationWithDefaults","c","configuration","RubricElement","nextModel","currentModel","_model","validatedModel","maxPoints","excludeZero","points","sampleAnswers","howManyPointsShouldHave","howManyPointsDoesItHave","length","excludeZeroChanged","maxPointsChanged","i","push","slice","_configuration","onModelChanged","_render","debug","log","bind","onConfigurationChanged","updateModelAccordingToReceivedProps","dispatchEvent","ModelUpdatedEvent","handler","InsertImageEvent","src","done","DeleteImageEvent","element","React","createElement","Main","imageSupport","add","insertImage","onDeleteImage","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD;AAAA,yCAAaC,qBAASC,KAAtB,GAAgCF,CAAhC;AAAA,CAA1B;;AAEA,IAAMG,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,CAAD;AAAA,yCAAaH,qBAASI,aAAtB,GAAwCD,CAAxC;AAAA,CAAlC;;IAEqBE,a;;;;;AACnB,2BAAc;AAAA;;AAAA;AACZ;AADY,4HASwB,UAACC,SAAD,EAAe;AACnD,UAA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hB,IAAjB,CAAsB,IAAtB,CADO;AAEZ,sBAAQ,KAAKiB,aAAL,CAAmBjB,IAAnB,CAAwB,IAAxB;AAFI;AALwB,SAA1B,CAAd;;AAWAkB,6BAASC,MAAT,CAAgBT,OAAhB,EAAyB,IAAzB;AACD;AACF;;;kDAnHwCU,W","sourcesContent":["import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\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 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 ReactDOM.render(element, this);\n }\n }\n}\n"],"file":"index.js"}
@@ -283,9 +283,12 @@ var RawAuthoring = /*#__PURE__*/function (_React$Component) {
283
283
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeMaxPoints", function (maxPoints) {
284
284
  var _this$props3 = _this.props,
285
285
  value = _this$props3.value,
286
- onChange = _this$props3.onChange;
286
+ onChange = _this$props3.onChange; // excludeZero should be false and disabled when maxPoints is 1
287
+
288
+ var excludeZero = maxPoints === 1 ? false : value.excludeZero;
287
289
  onChange(_objectSpread(_objectSpread({}, value), {}, {
288
- maxPoints: maxPoints
290
+ maxPoints: maxPoints,
291
+ excludeZero: excludeZero
289
292
  }));
290
293
  });
291
294
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeContent", function (index, content, type) {
@@ -396,7 +399,8 @@ var RawAuthoring = /*#__PURE__*/function (_React$Component) {
396
399
  control: /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
397
400
  className: classes.customColor,
398
401
  checked: value.excludeZero,
399
- onChange: this.excludeZeros
402
+ onChange: this.excludeZeros,
403
+ disabled: maxPointsValue === 1
400
404
  })
401
405
  })), rubriclessInstructionEnabled && rubricless && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
402
406
  label: rubriclessInstruction.label,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pie-toolbox-rubric/authoring.jsx"],"names":["log","reorder","list","startIndex","endIndex","result","Array","from","splice","removed","RubricType","PropTypes","shape","excludeZero","bool","points","arrayOf","string","sampleAnswers","maxPoints","number","rubriclessInstruction","MaxPoints","theme","formControl","minWidth","margin","spacing","unit","props","value","onChange","max","classes","e","target","map","v","checkSampleAnswer","sampleAnswer","PointConfig","pointConfig","row","display","width","position","editor","backgroundColor","palette","common","white","dragIndicator","paddingTop","color","grey","pointsLabel","paddingBottom","textTransform","sampleAnswersEditor","paddingLeft","pointMenu","right","errorText","fontSize","typography","error","main","content","mathMlOptions","pluginOpts","imageSupport","pointsCount","showSampleAnswer","language","icon","onMenuChange","onSampleChange","RawAuthoring","destination","source","index","input","type","items","clickedItem","changeContent","className","config","rubricless","excludeZeroEnabled","maxPointsEnabled","errors","rubriclessInstructionEnabled","maxMaxPoints","pointsDescriptorsErrors","Number","isFinite","console","warn","maxPointsValue","rubricTitle","changeMaxPoints","customColor","excludeZeros","label","inputContainer","changeRubriclessInstruction","container","dragEnd","provided","droppableProps","innerRef","p","toString","configHolder","draggableProps","dragHandleProps","length","onPointMenuChange","placeholder","React","Component","object","isRequired","func","add","styles","borderWidth","borderStyle","borderColor","padding","marginBottom","tertiary","StyledRawAuthoring","Reverse","reverse","concat","propTypes","getIndex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0BAAN,CAAZ;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,UAAP,EAAmBC,QAAnB,EAAgC;AAC9C,MAAMC,MAAM,GAAGC,KAAK,CAACC,IAAN,CAAWL,IAAX,CAAf;;AACA,uBAAkBG,MAAM,CAACG,MAAP,CAAcL,UAAd,EAA0B,CAA1B,CAAlB;AAAA;AAAA,MAAOM,OAAP;;AAEAJ,EAAAA,MAAM,CAACG,MAAP,CAAcJ,QAAd,EAAwB,CAAxB,EAA2BK,OAA3B;AAEA,SAAOJ,MAAP;AACD,CAPD;;AASO,IAAMK,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,CAHyB;AAIxCE,EAAAA,SAAS,EAAER,sBAAUS,MAJmB;AAKxCC,EAAAA,qBAAqB,EAAEV,sBAAUM;AALO,CAAhB,CAAnB;;;AAQP,IAAMK,SAAS,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AACvCC,IAAAA,WAAW,EAAE;AACXC,MAAAA,QAAQ,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;AAGlBrD,EAAAA,UAAU,EAAE1D,sBAAU+G,MAHJ;AAIlBlC,EAAAA,UAAU,EAAE7E,sBAAUG,IAJJ;AAKlB4H,EAAAA,QAAQ,EAAE/H,sBAAUiH,IALF;AAMlB7F,EAAAA,QAAQ,EAAEpB,sBAAUiH,IANF;AAOlBtD,EAAAA,YAAY,EAAE3D,sBAAUC,KAAV,CAAgB;AAC5BiH,IAAAA,GAAG,EAAElH,sBAAUiH,IAAV,CAAeD,UADQ;AAE5B,cAAQhH,sBAAUiH,IAAV,CAAeD;AAFK,GAAhB;AAPI,CAApB;eAaeW,O","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport Select from '@material-ui/core/Select';\nimport FormControl from '@material-ui/core/FormControl';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport times from 'lodash/times';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormGroup from '@material-ui/core/FormGroup';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport grey from '@material-ui/core/colors/grey';\nimport Typography from '@material-ui/core/Typography';\nimport DragIndicator from '@material-ui/icons/DragIndicator';\nimport EditableHtml from '@pie-lib/pie-toolbox/editable-html';\nimport { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';\nimport debug from 'debug';\nimport PointMenu from './point-menu';\n\nimport range from 'lodash/range';\nimport { InputContainer } from '@pie-lib/pie-toolbox/config-ui';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\n\nconst log = debug('pie-lib:rubric:authoring');\n\nconst reorder = (list, startIndex, endIndex) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n\n result.splice(endIndex, 0, removed);\n\n return result;\n};\n\nexport const RubricType = PropTypes.shape({\n excludeZero: PropTypes.bool,\n points: PropTypes.arrayOf(PropTypes.string),\n sampleAnswers: PropTypes.arrayOf(PropTypes.string),\n maxPoints: PropTypes.number,\n rubriclessInstruction: PropTypes.string,\n});\n\nconst MaxPoints = withStyles((theme) => ({\n formControl: {\n minWidth: '120px',\n margin: theme.spacing.unit,\n },\n}))((props) => {\n const { value, onChange, max, classes } = props;\n\n return (\n <FormControl className={classes.formControl} variant=\"outlined\">\n <InputLabel width={100} htmlFor=\"...\">\n Max Points\n </InputLabel>\n <Select value={value} onChange={(e) => onChange(e.target.value)} input={<OutlinedInput labelWidth={80} />}>\n {range(1, max + 1).map((v) => (\n <MenuItem key={`${v}`} value={v}>\n {v}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n );\n});\n\n// if the value is null or 'null', the Sample Answer input field for that point will not be dispalyed\n// if the value is '', the Sample Answer input field will be empty\nconst checkSampleAnswer = (sampleAnswer) => sampleAnswer === null || sampleAnswer === 'null';\n\nexport const PointConfig = withStyles((theme) => ({\n pointConfig: {},\n row: {\n display: 'flex',\n width: '100%',\n position: 'relative',\n },\n editor: {\n width: '100%',\n backgroundColor: `${theme.palette.common.white} !important`,\n },\n dragIndicator: {\n paddingTop: theme.spacing.unit,\n color: grey[500],\n },\n pointsLabel: {\n color: grey[500],\n paddingBottom: theme.spacing.unit,\n textTransform: 'uppercase',\n },\n sampleAnswersEditor: {\n paddingLeft: theme.spacing.unit * 3,\n },\n pointMenu: {\n position: 'absolute',\n right: 0,\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingLeft: theme.spacing.unit * 3,\n paddingTop: theme.spacing.unit,\n },\n}))((props) => {\n const { points, content, classes, sampleAnswer, mathMlOptions = {}, error, pluginOpts = {}, excludeZero, imageSupport = {}, } = props;\n const pointsCount = excludeZero ? points + 1 : points;\n const pointsLabel = `${pointsCount} ${pointsCount === 1 ? 'pt' : 'pts'}`;\n const showSampleAnswer = checkSampleAnswer(sampleAnswer);\n\n return (\n <div className={classes.pointConfig}>\n <Typography variant=\"overline\" className={classes.pointsLabel}>\n {pointsLabel}\n </Typography>\n\n <div className={classes.row}>\n <DragIndicator className={classes.dragIndicator} />\n <EditableHtml\n className={classes.editor}\n error={error}\n pluginProps={pluginOpts}\n markup={content}\n onChange={props.onChange}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n <PointMenu\n classes={{\n icon: classes.pointMenu,\n }}\n showSampleAnswer={showSampleAnswer}\n onChange={props.onMenuChange}\n />\n </div>\n {error && <div className={classes.errorText}>{error}</div>}\n {!showSampleAnswer && (\n <div className={classes.sampleAnswersEditor}>\n <Typography variant=\"overline\" className={classes.dragIndicator}>\n Sample Response\n </Typography>\n <EditableHtml\n className={classes.editor}\n markup={sampleAnswer}\n pluginProps={pluginOpts}\n onChange={props.onSampleChange}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </div>\n )}\n </div>\n );\n});\n\nexport class RawAuthoring extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n value: RubricType,\n config: PropTypes.object,\n pluginOpts: PropTypes.object,\n rubricless: PropTypes.bool,\n onChange: PropTypes.func,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n static defaultProps = {};\n\n dragEnd = (result) => {\n if (!result.destination) {\n return;\n }\n\n const { value, onChange } = this.props;\n\n const points = reorder(value.points, result.source.index, result.destination.index);\n const sampleAnswers = reorder(value.sampleAnswers, result.source.index, result.destination.index);\n\n onChange({ ...value, points, sampleAnswers });\n };\n\n changeRubriclessInstruction = (input) => {\n const { value, onChange } = this.props;\n onChange({ ...value, rubriclessInstruction: input });\n };\n\n changeMaxPoints = (maxPoints) => {\n const { value, onChange } = this.props;\n\n onChange({ ...value, maxPoints });\n };\n\n changeContent = (index, content, type) => {\n // type could be 'points' or 'sampleAnswers'\n log(`changeModel[${type}]:`, index, content);\n\n if (type !== 'points' && type !== 'sampleAnswers') {\n return;\n }\n\n const { value, onChange } = this.props;\n const items = value[type] && Array.from(value[type]);\n\n items.splice(index, 1, content);\n log(`changeModel[${type}]:`, items);\n\n onChange({ ...value, [type]: items });\n };\n\n excludeZeros = () => {\n const { value, onChange } = this.props;\n\n onChange({ ...value, excludeZero: !value.excludeZero });\n };\n\n onPointMenuChange = (index, clickedItem) => {\n if (clickedItem === 'sample') {\n const { value } = this.props;\n const sampleAnswers = Array.from(value.sampleAnswers || []);\n\n if (checkSampleAnswer(sampleAnswers[index])) {\n // an empty string will display an empty Sample Answer input field\n this.changeContent(index, '', 'sampleAnswers');\n } else {\n // when the content is null or 'null', the Sample Answer input field will not be displayed\n this.changeContent(index, null, 'sampleAnswers');\n }\n }\n };\n\n render() {\n const {\n classes,\n className,\n value,\n mathMlOptions = {},\n config = {},\n rubricless = false,\n pluginOpts = {},\n imageSupport = {},\n } = this.props;\n let {\n excludeZeroEnabled = true,\n maxPointsEnabled = true,\n errors = {},\n rubriclessInstructionEnabled = false,\n maxPoints = 10,\n } = value || {};\n // rubric will contain a max value for maxPoints\n const { rubriclessInstruction = {}, maxMaxPoints = 10 } = config || {};\n const { pointsDescriptorsErrors } = errors || {};\n if (value && Number.isFinite(value.maxPoints)) {\n // eslint-disable-next-line no-console\n console.warn('maxPoints is deprecated - remove from model');\n }\n\n // for rubric value is computed based on points\n const maxPointsValue = maxPoints;\n\n return (\n <div className={classNames(classes.class, className)}>\n <Typography variant=\"h5\" className={classes.rubricTitle}>\n Rubric\n </Typography>\n <FormGroup row>\n {maxPointsEnabled && (\n <MaxPoints\n max={maxMaxPoints < 100 ? maxMaxPoints : 100}\n value={maxPointsValue}\n onChange={this.changeMaxPoints}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n />\n )}\n {excludeZeroEnabled && (\n <FormControlLabel\n label=\"Exclude zeros\"\n control={\n <Checkbox\n className={classes.customColor}\n checked={value.excludeZero}\n onChange={this.excludeZeros}\n />\n }\n />\n )}\n </FormGroup>\n\n {rubriclessInstructionEnabled && rubricless && (\n <InputContainer label={rubriclessInstruction.label} className={classes.inputContainer}>\n <EditableHtml\n className={classes.input}\n markup={value.rubriclessInstruction || ''}\n onChange={this.changeRubriclessInstruction}\n pluginProps={pluginOpts}\n nonEmpty={false}\n disableUnderline\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n />\n </InputContainer>\n )}\n\n <div className={rubricless ? classes.rubricless : classes.container}>\n <DragDropContext onDragEnd={this.dragEnd}>\n <Droppable droppableId=\"droppable\">\n {(provided) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {value.points.map(\n (p, index) => {\n return (\n <Draggable key={`${p.points}-${index}`} index={index} draggableId={index.toString()}>\n {(provided) => (\n <div\n className={classes.configHolder}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n >\n <PointConfig\n points={value.points.length - 1 - index}\n content={p}\n error={\n pointsDescriptorsErrors && pointsDescriptorsErrors[value.points.length - 1 - index]\n }\n sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}\n onChange={(content) => this.changeContent(index, content, 'points')}\n onSampleChange={(content) => this.changeContent(index, content, 'sampleAnswers')}\n onMenuChange={(clickedItem) => this.onPointMenuChange(index, clickedItem)}\n mathMlOptions={mathMlOptions}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n excludeZero={value.excludeZero}\n />\n </div>\n )}\n </Draggable>\n );\n },\n )}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n </div>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n container: {\n backgroundColor: grey[200],\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: grey[300],\n padding: theme.spacing.unit * 2,\n margin: theme.spacing.unit,\n },\n inputContainer: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n rubricless: {\n display: 'none',\n },\n configHolder: {\n paddingTop: theme.spacing.unit,\n paddingBottom: theme.spacing.unit,\n },\n rubricTitle: {\n paddingLeft: theme.spacing.unit,\n margin: theme.spacing.unit,\n },\n customColor: {\n color: `${color.tertiary()} !important`\n },\n});\n\nconst StyledRawAuthoring = withStyles(styles)(RawAuthoring);\n\nconst Reverse = (props) => {\n const { rubricless = false, config = {}, pluginOpts = {}, imageSupport = {} } = props || {};\n const points = Array.from(props.value.points || []).reverse();\n let sampleAnswers = Array.from(props.value.sampleAnswers || []).reverse();\n\n if (points.length > sampleAnswers.length) {\n sampleAnswers = times(points.length - sampleAnswers.length)\n .map(() => null)\n .concat(sampleAnswers);\n }\n\n const value = { ...props.value, points, sampleAnswers };\n\n const onChange = (value) => {\n props.onChange({\n ...value,\n points: Array.from(value.points || []).reverse(),\n sampleAnswers: Array.from(value.sampleAnswers || []).reverse(),\n });\n };\n\n return (\n <StyledRawAuthoring\n value={value}\n config={config}\n onChange={onChange}\n rubricless={rubricless}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n />\n );\n};\n\nReverse.propTypes = {\n value: RubricType,\n config: PropTypes.object,\n pluginOpts: PropTypes.object,\n rubricless: PropTypes.bool,\n getIndex: PropTypes.func,\n onChange: PropTypes.func,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n};\n\nexport default Reverse;\n"],"file":"authoring.js"}
1
+ {"version":3,"sources":["../../src/pie-toolbox-rubric/authoring.jsx"],"names":["log","reorder","list","startIndex","endIndex","result","Array","from","splice","removed","RubricType","PropTypes","shape","excludeZero","bool","points","arrayOf","string","sampleAnswers","maxPoints","number","rubriclessInstruction","MaxPoints","theme","formControl","minWidth","margin","spacing","unit","props","value","onChange","max","classes","e","target","map","v","checkSampleAnswer","sampleAnswer","PointConfig","pointConfig","row","display","width","position","editor","backgroundColor","palette","common","white","dragIndicator","paddingTop","color","grey","pointsLabel","paddingBottom","textTransform","sampleAnswersEditor","paddingLeft","pointMenu","right","errorText","fontSize","typography","error","main","content","mathMlOptions","pluginOpts","imageSupport","pointsCount","showSampleAnswer","language","icon","onMenuChange","onSampleChange","RawAuthoring","destination","source","index","input","type","items","clickedItem","changeContent","className","config","rubricless","excludeZeroEnabled","maxPointsEnabled","errors","rubriclessInstructionEnabled","maxMaxPoints","pointsDescriptorsErrors","Number","isFinite","console","warn","maxPointsValue","rubricTitle","changeMaxPoints","customColor","excludeZeros","label","inputContainer","changeRubriclessInstruction","container","dragEnd","provided","droppableProps","innerRef","p","toString","configHolder","draggableProps","dragHandleProps","length","onPointMenuChange","placeholder","React","Component","object","isRequired","func","add","styles","borderWidth","borderStyle","borderColor","padding","marginBottom","tertiary","StyledRawAuthoring","Reverse","reverse","concat","propTypes","getIndex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0BAAN,CAAZ;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,UAAP,EAAmBC,QAAnB,EAAgC;AAC9C,MAAMC,MAAM,GAAGC,KAAK,CAACC,IAAN,CAAWL,IAAX,CAAf;;AACA,uBAAkBG,MAAM,CAACG,MAAP,CAAcL,UAAd,EAA0B,CAA1B,CAAlB;AAAA;AAAA,MAAOM,OAAP;;AAEAJ,EAAAA,MAAM,CAACG,MAAP,CAAcJ,QAAd,EAAwB,CAAxB,EAA2BK,OAA3B;AAEA,SAAOJ,MAAP;AACD,CAPD;;AASO,IAAMK,UAAU,GAAGC,sBAAUC,KAAV,CAAgB;AACxCC,EAAAA,WAAW,EAAEF,sBAAUG,IADiB;AAExCC,EAAAA,MAAM,EAAEJ,sBAAUK,OAAV,CAAkB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uB,KAAK,CAACZ,aAAN,IAAuB,EAAlC,EAAsCqH,OAAtC;AAHjB;AAKD,GAND;;AAQA,sBACE,gCAAC,kBAAD;AACE,IAAA,KAAK,EAAEzG,KADT;AAEE,IAAA,MAAM,EAAEyD,MAFV;AAGE,IAAA,QAAQ,EAAExD,QAHZ;AAIE,IAAA,UAAU,EAAEyD,UAJd;AAKE,IAAA,UAAU,EAAEnB,UALd;AAME,IAAA,YAAY,EAAEC;AANhB,IADF;AAUD,CA/BD;;AAiCAgE,OAAO,CAACG,SAAR,GAAoB;AAClB3G,EAAAA,KAAK,EAAEpB,UADW;AAElB6E,EAAAA,MAAM,EAAE5E,sBAAU+G,MAFA;AAGlBrD,EAAAA,UAAU,EAAE1D,sBAAU+G,MAHJ;AAIlBlC,EAAAA,UAAU,EAAE7E,sBAAUG,IAJJ;AAKlB4H,EAAAA,QAAQ,EAAE/H,sBAAUiH,IALF;AAMlB7F,EAAAA,QAAQ,EAAEpB,sBAAUiH,IANF;AAOlBtD,EAAAA,YAAY,EAAE3D,sBAAUC,KAAV,CAAgB;AAC5BiH,IAAAA,GAAG,EAAElH,sBAAUiH,IAAV,CAAeD,UADQ;AAE5B,cAAQhH,sBAAUiH,IAAV,CAAeD;AAFK,GAAhB;AAPI,CAApB;eAaeW,O","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport Select from '@material-ui/core/Select';\nimport FormControl from '@material-ui/core/FormControl';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport times from 'lodash/times';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormGroup from '@material-ui/core/FormGroup';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport grey from '@material-ui/core/colors/grey';\nimport Typography from '@material-ui/core/Typography';\nimport DragIndicator from '@material-ui/icons/DragIndicator';\nimport EditableHtml from '@pie-lib/pie-toolbox/editable-html';\nimport { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';\nimport debug from 'debug';\nimport PointMenu from './point-menu';\n\nimport range from 'lodash/range';\nimport { InputContainer } from '@pie-lib/pie-toolbox/config-ui';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\n\nconst log = debug('pie-lib:rubric:authoring');\n\nconst reorder = (list, startIndex, endIndex) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n\n result.splice(endIndex, 0, removed);\n\n return result;\n};\n\nexport const RubricType = PropTypes.shape({\n excludeZero: PropTypes.bool,\n points: PropTypes.arrayOf(PropTypes.string),\n sampleAnswers: PropTypes.arrayOf(PropTypes.string),\n maxPoints: PropTypes.number,\n rubriclessInstruction: PropTypes.string,\n});\n\nconst MaxPoints = withStyles((theme) => ({\n formControl: {\n minWidth: '120px',\n margin: theme.spacing.unit,\n },\n}))((props) => {\n const { value, onChange, max, classes } = props;\n\n return (\n <FormControl className={classes.formControl} variant=\"outlined\">\n <InputLabel width={100} htmlFor=\"...\">\n Max Points\n </InputLabel>\n <Select value={value} onChange={(e) => onChange(e.target.value)} input={<OutlinedInput labelWidth={80} />}>\n {range(1, max + 1).map((v) => (\n <MenuItem key={`${v}`} value={v}>\n {v}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n );\n});\n\n// if the value is null or 'null', the Sample Answer input field for that point will not be dispalyed\n// if the value is '', the Sample Answer input field will be empty\nconst checkSampleAnswer = (sampleAnswer) => sampleAnswer === null || sampleAnswer === 'null';\n\nexport const PointConfig = withStyles((theme) => ({\n pointConfig: {},\n row: {\n display: 'flex',\n width: '100%',\n position: 'relative',\n },\n editor: {\n width: '100%',\n backgroundColor: `${theme.palette.common.white} !important`,\n },\n dragIndicator: {\n paddingTop: theme.spacing.unit,\n color: grey[500],\n },\n pointsLabel: {\n color: grey[500],\n paddingBottom: theme.spacing.unit,\n textTransform: 'uppercase',\n },\n sampleAnswersEditor: {\n paddingLeft: theme.spacing.unit * 3,\n },\n pointMenu: {\n position: 'absolute',\n right: 0,\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingLeft: theme.spacing.unit * 3,\n paddingTop: theme.spacing.unit,\n },\n}))((props) => {\n const {\n points,\n content,\n classes,\n sampleAnswer,\n mathMlOptions = {},\n error,\n pluginOpts = {},\n excludeZero,\n imageSupport = {},\n } = props;\n const pointsCount = excludeZero ? points + 1 : points;\n const pointsLabel = `${pointsCount} ${pointsCount === 1 ? 'pt' : 'pts'}`;\n const showSampleAnswer = checkSampleAnswer(sampleAnswer);\n\n return (\n <div className={classes.pointConfig}>\n <Typography variant=\"overline\" className={classes.pointsLabel}>\n {pointsLabel}\n </Typography>\n\n <div className={classes.row}>\n <DragIndicator className={classes.dragIndicator} />\n <EditableHtml\n className={classes.editor}\n error={error}\n pluginProps={pluginOpts}\n markup={content}\n onChange={props.onChange}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n <PointMenu\n classes={{\n icon: classes.pointMenu,\n }}\n showSampleAnswer={showSampleAnswer}\n onChange={props.onMenuChange}\n />\n </div>\n {error && <div className={classes.errorText}>{error}</div>}\n {!showSampleAnswer && (\n <div className={classes.sampleAnswersEditor}>\n <Typography variant=\"overline\" className={classes.dragIndicator}>\n Sample Response\n </Typography>\n <EditableHtml\n className={classes.editor}\n markup={sampleAnswer}\n pluginProps={pluginOpts}\n onChange={props.onSampleChange}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </div>\n )}\n </div>\n );\n});\n\nexport class RawAuthoring extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n value: RubricType,\n config: PropTypes.object,\n pluginOpts: PropTypes.object,\n rubricless: PropTypes.bool,\n onChange: PropTypes.func,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n static defaultProps = {};\n\n dragEnd = (result) => {\n if (!result.destination) {\n return;\n }\n\n const { value, onChange } = this.props;\n\n const points = reorder(value.points, result.source.index, result.destination.index);\n const sampleAnswers = reorder(value.sampleAnswers, result.source.index, result.destination.index);\n\n onChange({ ...value, points, sampleAnswers });\n };\n\n changeRubriclessInstruction = (input) => {\n const { value, onChange } = this.props;\n onChange({ ...value, rubriclessInstruction: input });\n };\n\n changeMaxPoints = (maxPoints) => {\n const { value, onChange } = this.props;\n // excludeZero should be false and disabled when maxPoints is 1\n const excludeZero = maxPoints === 1 ? false : value.excludeZero;\n\n onChange({ ...value, maxPoints, excludeZero });\n };\n\n changeContent = (index, content, type) => {\n // type could be 'points' or 'sampleAnswers'\n log(`changeModel[${type}]:`, index, content);\n\n if (type !== 'points' && type !== 'sampleAnswers') {\n return;\n }\n\n const { value, onChange } = this.props;\n const items = value[type] && Array.from(value[type]);\n\n items.splice(index, 1, content);\n log(`changeModel[${type}]:`, items);\n\n onChange({ ...value, [type]: items });\n };\n\n excludeZeros = () => {\n const { value, onChange } = this.props;\n\n onChange({ ...value, excludeZero: !value.excludeZero });\n };\n\n onPointMenuChange = (index, clickedItem) => {\n if (clickedItem === 'sample') {\n const { value } = this.props;\n const sampleAnswers = Array.from(value.sampleAnswers || []);\n\n if (checkSampleAnswer(sampleAnswers[index])) {\n // an empty string will display an empty Sample Answer input field\n this.changeContent(index, '', 'sampleAnswers');\n } else {\n // when the content is null or 'null', the Sample Answer input field will not be displayed\n this.changeContent(index, null, 'sampleAnswers');\n }\n }\n };\n\n render() {\n const {\n classes,\n className,\n value,\n mathMlOptions = {},\n config = {},\n rubricless = false,\n pluginOpts = {},\n imageSupport = {},\n } = this.props;\n let {\n excludeZeroEnabled = true,\n maxPointsEnabled = true,\n errors = {},\n rubriclessInstructionEnabled = false,\n maxPoints = 10,\n } = value || {};\n // rubric will contain a max value for maxPoints\n const { rubriclessInstruction = {}, maxMaxPoints = 10 } = config || {};\n const { pointsDescriptorsErrors } = errors || {};\n if (value && Number.isFinite(value.maxPoints)) {\n // eslint-disable-next-line no-console\n console.warn('maxPoints is deprecated - remove from model');\n }\n\n // for rubric value is computed based on points\n const maxPointsValue = maxPoints;\n\n return (\n <div className={classNames(classes.class, className)}>\n <Typography variant=\"h5\" className={classes.rubricTitle}>\n Rubric\n </Typography>\n <FormGroup row>\n {maxPointsEnabled && (\n <MaxPoints\n max={maxMaxPoints < 100 ? maxMaxPoints : 100}\n value={maxPointsValue}\n onChange={this.changeMaxPoints}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n />\n )}\n {excludeZeroEnabled && (\n <FormControlLabel\n label=\"Exclude zeros\"\n control={\n <Checkbox\n className={classes.customColor}\n checked={value.excludeZero}\n onChange={this.excludeZeros}\n disabled={maxPointsValue === 1}\n />\n }\n />\n )}\n </FormGroup>\n\n {rubriclessInstructionEnabled && rubricless && (\n <InputContainer label={rubriclessInstruction.label} className={classes.inputContainer}>\n <EditableHtml\n className={classes.input}\n markup={value.rubriclessInstruction || ''}\n onChange={this.changeRubriclessInstruction}\n pluginProps={pluginOpts}\n nonEmpty={false}\n disableUnderline\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n imageSupport={imageSupport}\n />\n </InputContainer>\n )}\n\n <div className={rubricless ? classes.rubricless : classes.container}>\n <DragDropContext onDragEnd={this.dragEnd}>\n <Droppable droppableId=\"droppable\">\n {(provided) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {value.points.map((p, index) => {\n return (\n <Draggable key={`${p.points}-${index}`} index={index} draggableId={index.toString()}>\n {(provided) => (\n <div\n className={classes.configHolder}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n >\n <PointConfig\n points={value.points.length - 1 - index}\n content={p}\n error={\n pointsDescriptorsErrors && pointsDescriptorsErrors[value.points.length - 1 - index]\n }\n sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}\n onChange={(content) => this.changeContent(index, content, 'points')}\n onSampleChange={(content) => this.changeContent(index, content, 'sampleAnswers')}\n onMenuChange={(clickedItem) => this.onPointMenuChange(index, clickedItem)}\n mathMlOptions={mathMlOptions}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n excludeZero={value.excludeZero}\n />\n </div>\n )}\n </Draggable>\n );\n })}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n </div>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n container: {\n backgroundColor: grey[200],\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: grey[300],\n padding: theme.spacing.unit * 2,\n margin: theme.spacing.unit,\n },\n inputContainer: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n rubricless: {\n display: 'none',\n },\n configHolder: {\n paddingTop: theme.spacing.unit,\n paddingBottom: theme.spacing.unit,\n },\n rubricTitle: {\n paddingLeft: theme.spacing.unit,\n margin: theme.spacing.unit,\n },\n customColor: {\n color: `${color.tertiary()} !important`,\n },\n});\n\nconst StyledRawAuthoring = withStyles(styles)(RawAuthoring);\n\nconst Reverse = (props) => {\n const { rubricless = false, config = {}, pluginOpts = {}, imageSupport = {} } = props || {};\n const points = Array.from(props.value.points || []).reverse();\n let sampleAnswers = Array.from(props.value.sampleAnswers || []).reverse();\n\n if (points.length > sampleAnswers.length) {\n sampleAnswers = times(points.length - sampleAnswers.length)\n .map(() => null)\n .concat(sampleAnswers);\n }\n\n const value = { ...props.value, points, sampleAnswers };\n\n const onChange = (value) => {\n props.onChange({\n ...value,\n points: Array.from(value.points || []).reverse(),\n sampleAnswers: Array.from(value.sampleAnswers || []).reverse(),\n });\n };\n\n return (\n <StyledRawAuthoring\n value={value}\n config={config}\n onChange={onChange}\n rubricless={rubricless}\n pluginOpts={pluginOpts}\n imageSupport={imageSupport}\n />\n );\n};\n\nReverse.propTypes = {\n value: RubricType,\n config: PropTypes.object,\n pluginOpts: PropTypes.object,\n rubricless: PropTypes.bool,\n getIndex: PropTypes.func,\n onChange: PropTypes.func,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n};\n\nexport default Reverse;\n"],"file":"authoring.js"}
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/rubric-configure",
3
3
  "private": true,
4
- "version": "4.6.1",
4
+ "version": "4.6.2",
5
5
  "description": "Rubric authoring view",
6
6
  "main": "lib/index.js",
7
7
  "author": "Pie Framework Authors",
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/pie-toolbox": "2.17.3",
11
+ "@pie-lib/pie-toolbox": "2.17.6",
12
12
  "debug": "^4.1.1",
13
13
  "react": "^16.8.6",
14
14
  "react-dom": "^16.8.6"
@@ -1,173 +1,167 @@
1
1
  import RubricElement from '../index';
2
2
  import defaults from '../defaults';
3
3
  import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
4
- import React from "react";
4
+ import React from 'react';
5
5
 
6
6
  jest.mock('react-dom', () => ({
7
- render: jest.fn(),
7
+ render: jest.fn(),
8
8
  }));
9
9
 
10
10
  const model = (extras) => ({
11
- id: '1',
12
- element: 'pie-rubric',
13
- points: ['A', 'B', 'C', 'D'],
14
- sampleAnswers: [true, true, false, false],
15
- maxPoints: 3,
16
- excludeZero: false,
17
- excludeZeroEnabled: true,
18
- maxPointsEnabled: true,
19
- ...extras,
11
+ id: '1',
12
+ element: 'pie-rubric',
13
+ points: ['A', 'B', 'C', 'D'],
14
+ sampleAnswers: [true, true, false, false],
15
+ maxPoints: 3,
16
+ excludeZero: false,
17
+ excludeZeroEnabled: true,
18
+ maxPointsEnabled: true,
19
+ ...extras,
20
20
  });
21
21
 
22
22
  const invalidModel = (extras) => ({
23
- id: '2',
24
- element: 'pie-rubric',
25
- points: ['A', 'B', 'C', 'D'],
26
- sampleAnswers: [true, true, false, false],
27
- maxPoints: 5,
28
- excludeZero: false,
29
- excludeZeroEnabled: true,
30
- maxPointsEnabled: true,
31
- ...extras,
23
+ id: '2',
24
+ element: 'pie-rubric',
25
+ points: ['A', 'B', 'C', 'D'],
26
+ sampleAnswers: [true, true, false, false],
27
+ maxPoints: 5,
28
+ excludeZero: false,
29
+ excludeZeroEnabled: true,
30
+ maxPointsEnabled: true,
31
+ ...extras,
32
32
  });
33
- const configuration = (c) => ({...defaults.configuration, ...c});
33
+ const configuration = (c) => ({ ...defaults.configuration, ...c });
34
34
 
35
35
  describe('RubricElement', () => {
36
- let element;
36
+ let element;
37
37
 
38
- beforeEach(() => {
39
- element = new RubricElement();
38
+ beforeEach(() => {
39
+ element = new RubricElement();
40
+ });
41
+
42
+ afterEach(() => {
43
+ jest.clearAllMocks();
44
+ });
45
+
46
+ describe('set model', () => {
47
+ it('should set the model correctly', () => {
48
+ const newModel = model();
49
+ element.model = newModel;
50
+ expect(element._model).toEqual(newModel);
51
+ });
52
+ });
53
+
54
+ describe('onModelChanged', () => {
55
+ it('should dispatch ModelUpdatedEvent on model change', () => {
56
+ const newModel = model();
57
+ const dispatchEventSpy = jest.spyOn(element, 'dispatchEvent');
58
+ element.onModelChanged(newModel);
59
+ expect(element._model).toEqual(newModel);
60
+ expect(dispatchEventSpy).toHaveBeenCalledWith(new ModelUpdatedEvent(newModel, false));
61
+ });
62
+ });
63
+
64
+ describe('set configuration', () => {
65
+ it('should set the configuration correctly', () => {
66
+ const newConfiguration = configuration();
67
+ element.configuration = newConfiguration;
68
+ expect(element._configuration).toEqual(newConfiguration);
69
+ });
70
+ });
71
+
72
+ describe('onConfigurationChanged', () => {
73
+ it('should call _render method on configuration change and overwrite the defaults with the new values', () => {
74
+ const newConfiguration = configuration({ maxMaxPoints: 10 });
75
+ const renderSpy = jest.spyOn(element, '_render');
76
+ element.onConfigurationChanged(newConfiguration);
77
+ expect(element._configuration.maxMaxPoints).toEqual(10);
78
+ expect(renderSpy).toHaveBeenCalled();
79
+ });
80
+ });
81
+
82
+ describe('updateModelAccordingToReceivedProps', () => {
83
+ it('should return the same model if it is already valid', () => {
84
+ const validModel = model();
85
+ const validatedModel = element.updateModelAccordingToReceivedProps(validModel);
86
+ expect(validatedModel).toEqual(validModel);
87
+ });
88
+
89
+ it('should return an empty model if the input model is undefined', () => {
90
+ const validatedModel = element.updateModelAccordingToReceivedProps(undefined);
91
+ expect(validatedModel).toEqual(defaults.model);
40
92
  });
41
93
 
42
- afterEach(() => {
43
- jest.clearAllMocks();
94
+ it('should return an empty model if the input model is null', () => {
95
+ const validatedModel = element.updateModelAccordingToReceivedProps(null);
96
+ expect(validatedModel).toEqual(defaults.model);
44
97
  });
45
-
46
- describe('set model', () => {
47
- it('should set the model correctly', () => {
48
- const newModel = model();
49
- element.model = newModel;
50
- expect(element._model).toEqual(newModel);
51
- });
98
+
99
+ it('should handle undefined properties in the input model', () => {
100
+ const validatedModel = element.updateModelAccordingToReceivedProps({});
101
+ expect(validatedModel).toEqual({ points: [], sampleAnswers: [] });
52
102
  });
53
103
 
54
- describe('onModelChanged', () => {
55
- it('should dispatch ModelUpdatedEvent on model change', () => {
56
- const newModel = model();
57
- const dispatchEventSpy = jest.spyOn(element, 'dispatchEvent');
58
- element.onModelChanged(newModel);
59
- expect(element._model).toEqual(newModel);
60
- expect(dispatchEventSpy).toHaveBeenCalledWith(new ModelUpdatedEvent(newModel, false));
61
- });
104
+ it('should handle null properties in the input model', () => {
105
+ const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: null, excludeZero: null });
106
+ expect(validatedModel).toEqual({
107
+ excludeZero: null,
108
+ maxPoints: null,
109
+ points: ['', ''],
110
+ sampleAnswers: [null, null],
111
+ });
62
112
  });
63
113
 
64
- describe('set configuration', () => {
65
- it('should set the configuration correctly', () => {
66
- const newConfiguration = configuration();
67
- element.configuration = newConfiguration;
68
- expect(element._configuration).toEqual(newConfiguration);
69
- });
114
+ it('should handle undefined points and sampleAnswers arrays', () => {
115
+ const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: 5, excludeZero: false });
116
+ expect(validatedModel.points).toEqual(['', '', '', '', '', '']);
117
+ expect(validatedModel.sampleAnswers).toEqual([null, null, null, null, null, null]);
70
118
  });
71
119
 
72
- describe('onConfigurationChanged', () => {
73
- it('should call _render method on configuration change and overwrite the defaults with the new values', () => {
74
- const newConfiguration = configuration({maxMaxPoints: 10});
75
- const renderSpy = jest.spyOn(element, '_render');
76
- element.onConfigurationChanged(newConfiguration);
77
- expect(element._configuration.maxMaxPoints).toEqual(10);
78
- expect(renderSpy).toHaveBeenCalled();
79
- });
120
+ it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave with maxPoints & excludeZero changed', () => {
121
+ const nextModel = model({
122
+ maxPoints: 7,
123
+ excludeZero: true,
124
+ });
125
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
126
+ expect(result.points).toEqual(['A', 'B', 'C', 'D', '', '', '']);
127
+ expect(result.sampleAnswers).toEqual([true, true, false, false, null, null, null]);
80
128
  });
81
129
 
82
- describe('updateModelAccordingToReceivedProps', () => {
83
- it('should return the same model if it is already valid', () => {
84
- const validModel = model();
85
- const validatedModel = element.updateModelAccordingToReceivedProps(validModel);
86
- expect(validatedModel).toEqual(validModel);
87
- });
88
-
89
- it('should return an empty model if the input model is undefined', () => {
90
- const validatedModel = element.updateModelAccordingToReceivedProps(undefined);
91
- expect(validatedModel).toEqual(defaults.model);
92
- });
93
-
94
- it('should return an empty model if the input model is null', () => {
95
- const validatedModel = element.updateModelAccordingToReceivedProps(null);
96
- expect(validatedModel).toEqual(defaults.model);
97
- });
98
-
99
- it('should handle undefined properties in the input model', () => {
100
- const validatedModel = element.updateModelAccordingToReceivedProps({});
101
- expect(validatedModel).toEqual({"points": [], "sampleAnswers": []});
102
- });
103
-
104
- it('should handle null properties in the input model', () => {
105
- const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: null, excludeZero: null });
106
- expect(validatedModel).toEqual( {"excludeZero": null, "maxPoints": null, "points": ["", ""], "sampleAnswers": [null, null]});
107
- });
108
-
109
- it('should handle undefined points and sampleAnswers arrays', () => {
110
- const validatedModel = element.updateModelAccordingToReceivedProps({ maxPoints: 5, excludeZero: false });
111
- expect(validatedModel.points).toEqual(['', '', '', '', '', '']);
112
- expect(validatedModel.sampleAnswers).toEqual([null, null, null, null, null, null]);
113
- });
114
-
115
- it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave with maxPoints & excludeZero changed', () => {
116
- const nextModel = model({
117
- maxPoints: 7,
118
- excludeZero: true,
119
- });
120
- const result = element.updateModelAccordingToReceivedProps(nextModel);
121
- expect(result.points).toEqual(['A', 'B', 'C', 'D', '', '', '']);
122
- expect(result.sampleAnswers).toEqual([true, true, false, false, null, null, null]);
123
- });
124
-
125
- it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave and maxPointsChanged', () => {
126
- const nextModel = model({
127
- maxPoints: 4,
128
- excludeZero: false
129
- });
130
- const result = element.updateModelAccordingToReceivedProps(nextModel);
131
- expect(result.points).toEqual(['A', 'B', 'C', 'D', '']);
132
- expect(result.sampleAnswers).toEqual([true, true, false, false, null]);
133
- });
134
-
135
- it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and excludeZeroChanged', () => {
136
- const nextModel = model({
137
- maxPoints: 3,
138
- excludeZero: true,
139
- });
140
- const result = element.updateModelAccordingToReceivedProps(nextModel);
141
- expect(result.points).toEqual(['B', 'C', 'D']);
142
- expect(result.sampleAnswers).toEqual([true, false, false]);
143
- });
144
-
145
- it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and maxPointsChanged', () => {
146
- const nextModel = model({
147
- maxPoints: 1,
148
- excludeZero: false,
149
- });
150
- const result = element.updateModelAccordingToReceivedProps(nextModel);
151
- expect(result.points).toEqual(['A','B']);
152
- expect(result.sampleAnswers).toEqual([true, true]);
153
- });
154
-
155
- it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave, maxPointsChanged & excludeZeroChanged', () => {
156
- const nextModel = model({
157
- maxPoints: 1,
158
- excludeZero: true,
159
- });
160
- const result = element.updateModelAccordingToReceivedProps(nextModel);
161
- expect(result.points).toEqual(['B']);
162
- expect(result.sampleAnswers).toEqual([true]);
163
- });
164
-
165
- it('should handle case if invalid model is set, after updateModelAccordingToReceivedProps the returned model is valid', () => {
166
- const newModel = invalidModel();
167
- element.onModelChanged(newModel);
168
- expect(element._model.points).toEqual(["A", "B", "C", "D", "", ""]);
169
- expect(element._model.sampleAnswers).toEqual([true, true, false, false, null, null]);
170
- });
130
+ it('should handle case when howManyPointsDoesItHave is less than howManyPointsShouldHave and maxPointsChanged', () => {
131
+ const nextModel = model({
132
+ maxPoints: 4,
133
+ excludeZero: false,
134
+ });
135
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
136
+ expect(result.points).toEqual(['A', 'B', 'C', 'D', '']);
137
+ expect(result.sampleAnswers).toEqual([true, true, false, false, null]);
171
138
  });
172
-
173
- });
139
+
140
+ it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and excludeZeroChanged', () => {
141
+ const nextModel = model({
142
+ maxPoints: 3,
143
+ excludeZero: true,
144
+ });
145
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
146
+ expect(result.points).toEqual(['B', 'C', 'D']);
147
+ expect(result.sampleAnswers).toEqual([true, false, false]);
148
+ });
149
+
150
+ it('should handle case when howManyPointsDoesItHave is greater than howManyPointsShouldHave and maxPointsChanged', () => {
151
+ const nextModel = model({
152
+ maxPoints: 1,
153
+ excludeZero: false,
154
+ });
155
+ const result = element.updateModelAccordingToReceivedProps(nextModel);
156
+ expect(result.points).toEqual(['A', 'B']);
157
+ expect(result.sampleAnswers).toEqual([true, true]);
158
+ });
159
+
160
+ it('should handle case if invalid model is set, after updateModelAccordingToReceivedProps the returned model is valid', () => {
161
+ const newModel = invalidModel();
162
+ element.onModelChanged(newModel);
163
+ expect(element._model.points).toEqual(['A', 'B', 'C', 'D', '', '']);
164
+ expect(element._model.sampleAnswers).toEqual([true, true, false, false, null, null]);
165
+ });
166
+ });
167
+ });
@@ -1,8 +1,4 @@
1
- import {
2
- ModelUpdatedEvent,
3
- InsertImageEvent,
4
- DeleteImageEvent
5
- } from '@pie-framework/pie-configure-events';
1
+ import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent } from '@pie-framework/pie-configure-events';
6
2
  import React from 'react';
7
3
  import ReactDOM from 'react-dom';
8
4
  import debug from 'debug';
@@ -10,118 +6,124 @@ import debug from 'debug';
10
6
  import Main from './main';
11
7
  import defaults from './defaults';
12
8
 
13
- const modelWithDefaults = (m) => ({...defaults.model, ...m});
14
- const configurationWithDefaults = (c) => ({...defaults.configuration, ...c});
9
+ const modelWithDefaults = (m) => ({ ...defaults.model, ...m });
10
+
11
+ const configurationWithDefaults = (c) => ({ ...defaults.configuration, ...c });
15
12
 
16
13
  export default class RubricElement extends HTMLElement {
14
+ constructor() {
15
+ super();
16
+ debug.log('constructor called');
17
+ this._model = modelWithDefaults();
18
+ this._configuration = configurationWithDefaults();
19
+ this.onModelChanged = this.onModelChanged.bind(this);
20
+ this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
21
+ }
22
+
23
+ updateModelAccordingToReceivedProps = (nextModel) => {
24
+ const currentModel = { ...this._model };
25
+
26
+ if (!nextModel) {
27
+ return currentModel;
28
+ }
17
29
 
30
+ const validatedModel = { ...nextModel };
18
31
 
19
- constructor() {
20
- super();
21
- debug.log('constructor called');
22
- this._model = modelWithDefaults();
23
- this._configuration = configurationWithDefaults();
24
- this.onModelChanged = this.onModelChanged.bind(this);
25
- this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
32
+ // excludeZero should be false and disabled when maxPoints is 1
33
+ if (validatedModel.maxPoints === 1) {
34
+ validatedModel.excludeZero = false;
26
35
  }
27
36
 
28
- updateModelAccordingToReceivedProps = (nextModel) => {
29
- const currentModel = {...this._model};
30
- if (!nextModel) {
31
- return currentModel;
32
- }
37
+ const { maxPoints, excludeZero } = validatedModel || {};
33
38
 
34
- const validatedModel = nextModel;
35
- const { maxPoints, excludeZero } = validatedModel || {};
36
-
37
- validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];
38
- validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];
39
-
40
- const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
41
- const howManyPointsDoesItHave = validatedModel.points.length;
42
-
43
- const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;
44
- const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;
45
-
46
- if (howManyPointsDoesItHave < howManyPointsShouldHave) {
47
- if (excludeZeroChanged && !excludeZero) {
48
- validatedModel.points = ['', ...validatedModel.points];
49
- validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];
50
- }
51
- if (maxPointsChanged) {
52
- for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {
53
- validatedModel.points.push('');
54
- validatedModel.sampleAnswers.push(null);
55
- }
56
- }
57
- }
58
- else if (howManyPointsDoesItHave > howManyPointsShouldHave) {
59
- if (excludeZeroChanged && excludeZero) {
60
- validatedModel.points = validatedModel.points.slice(1);
61
- validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);
62
- }
63
- if (maxPointsChanged) {
64
- validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);
65
- validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);
66
- }
67
- }
39
+ validatedModel.points = validatedModel.points ? [...validatedModel.points] : [];
40
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers ? [...validatedModel.sampleAnswers] : [];
68
41
 
69
- return validatedModel;
70
- }
42
+ const howManyPointsShouldHave = excludeZero ? maxPoints : maxPoints + 1;
43
+ const howManyPointsDoesItHave = validatedModel.points.length;
71
44
 
72
- set model(m) {
73
- this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
74
- this._render();
75
- }
45
+ const excludeZeroChanged = currentModel?.excludeZero !== nextModel?.excludeZero;
46
+ const maxPointsChanged = currentModel?.maxPoints !== nextModel?.maxPoints;
76
47
 
77
- set configuration(c) {
78
- this._configuration = configurationWithDefaults(c);
79
- this._render();
80
- }
48
+ if (howManyPointsDoesItHave < howManyPointsShouldHave) {
49
+ if (excludeZeroChanged && !excludeZero) {
50
+ validatedModel.points = ['', ...validatedModel.points];
51
+ validatedModel.sampleAnswers = [null, ...validatedModel.sampleAnswers];
52
+ }
81
53
 
82
- onModelChanged(m) {
83
- this._model = this.updateModelAccordingToReceivedProps(m);
84
- this._render();
85
- this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
54
+ if (maxPointsChanged) {
55
+ for (let i = 0; i < howManyPointsShouldHave - howManyPointsDoesItHave; i++) {
56
+ validatedModel.points.push('');
57
+ validatedModel.sampleAnswers.push(null);
58
+ }
59
+ }
60
+ } else if (howManyPointsDoesItHave > howManyPointsShouldHave) {
61
+ if (excludeZeroChanged && excludeZero) {
62
+ validatedModel.points = validatedModel.points.slice(1);
63
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(1);
64
+ }
65
+
66
+ if (maxPointsChanged) {
67
+ validatedModel.points = validatedModel.points.slice(0, howManyPointsShouldHave);
68
+ validatedModel.sampleAnswers = validatedModel.sampleAnswers.slice(0, howManyPointsShouldHave);
69
+ }
86
70
  }
87
71
 
88
- onConfigurationChanged = (c) => {
89
- this._configuration = configurationWithDefaults(c);
72
+ return validatedModel;
73
+ };
90
74
 
91
- if (this._model) {
92
- this.onModelChanged(this._model);
93
- }
75
+ set model(m) {
76
+ this._model = this.updateModelAccordingToReceivedProps(modelWithDefaults(m));
77
+ this._render();
78
+ }
94
79
 
95
- this._render();
96
- };
80
+ set configuration(c) {
81
+ this._configuration = configurationWithDefaults(c);
82
+ this._render();
83
+ }
97
84
 
98
- insertImage(handler) {
99
- this.dispatchEvent(new InsertImageEvent(handler));
100
- }
85
+ onModelChanged(m) {
86
+ this._model = this.updateModelAccordingToReceivedProps(m);
87
+ this._render();
88
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
89
+ }
101
90
 
102
- onDeleteImage(src, done) {
103
- this.dispatchEvent(new DeleteImageEvent(src, done));
104
- }
91
+ onConfigurationChanged = (c) => {
92
+ this._configuration = configurationWithDefaults(c);
105
93
 
106
- connectedCallback() {
107
- this._render();
94
+ if (this._model) {
95
+ this.onModelChanged(this._model);
108
96
  }
109
97
 
110
- _render() {
111
- console.log('THE MODEL', this._model);
112
- if (this._model) {
113
- let element = React.createElement(Main, {
114
- model: this._model,
115
- configuration: this._configuration,
116
- onModelChanged: this.onModelChanged,
117
- onConfigurationChanged: this.onConfigurationChanged,
118
- imageSupport: {
119
- add: this.insertImage.bind(this),
120
- delete: this.onDeleteImage.bind(this),
121
- },
122
- });
123
-
124
- ReactDOM.render(element, this);
125
- }
98
+ this._render();
99
+ };
100
+
101
+ insertImage(handler) {
102
+ this.dispatchEvent(new InsertImageEvent(handler));
103
+ }
104
+
105
+ onDeleteImage(src, done) {
106
+ this.dispatchEvent(new DeleteImageEvent(src, done));
107
+ }
108
+
109
+ connectedCallback() {
110
+ this._render();
111
+ }
112
+
113
+ _render() {
114
+ if (this._model) {
115
+ let element = React.createElement(Main, {
116
+ model: this._model,
117
+ configuration: this._configuration,
118
+ onModelChanged: this.onModelChanged,
119
+ onConfigurationChanged: this.onConfigurationChanged,
120
+ imageSupport: {
121
+ add: this.insertImage.bind(this),
122
+ delete: this.onDeleteImage.bind(this),
123
+ },
124
+ });
125
+
126
+ ReactDOM.render(element, this);
126
127
  }
128
+ }
127
129
  }
@@ -104,7 +104,17 @@ export const PointConfig = withStyles((theme) => ({
104
104
  paddingTop: theme.spacing.unit,
105
105
  },
106
106
  }))((props) => {
107
- const { points, content, classes, sampleAnswer, mathMlOptions = {}, error, pluginOpts = {}, excludeZero, imageSupport = {}, } = props;
107
+ const {
108
+ points,
109
+ content,
110
+ classes,
111
+ sampleAnswer,
112
+ mathMlOptions = {},
113
+ error,
114
+ pluginOpts = {},
115
+ excludeZero,
116
+ imageSupport = {},
117
+ } = props;
108
118
  const pointsCount = excludeZero ? points + 1 : points;
109
119
  const pointsLabel = `${pointsCount} ${pointsCount === 1 ? 'pt' : 'pts'}`;
110
120
  const showSampleAnswer = checkSampleAnswer(sampleAnswer);
@@ -193,8 +203,10 @@ export class RawAuthoring extends React.Component {
193
203
 
194
204
  changeMaxPoints = (maxPoints) => {
195
205
  const { value, onChange } = this.props;
206
+ // excludeZero should be false and disabled when maxPoints is 1
207
+ const excludeZero = maxPoints === 1 ? false : value.excludeZero;
196
208
 
197
- onChange({ ...value, maxPoints });
209
+ onChange({ ...value, maxPoints, excludeZero });
198
210
  };
199
211
 
200
212
  changeContent = (index, content, type) => {
@@ -283,12 +295,13 @@ export class RawAuthoring extends React.Component {
283
295
  <FormControlLabel
284
296
  label="Exclude zeros"
285
297
  control={
286
- <Checkbox
298
+ <Checkbox
287
299
  className={classes.customColor}
288
300
  checked={value.excludeZero}
289
301
  onChange={this.excludeZeros}
290
- />
291
- }
302
+ disabled={maxPointsValue === 1}
303
+ />
304
+ }
292
305
  />
293
306
  )}
294
307
  </FormGroup>
@@ -314,38 +327,36 @@ export class RawAuthoring extends React.Component {
314
327
  <Droppable droppableId="droppable">
315
328
  {(provided) => (
316
329
  <div {...provided.droppableProps} ref={provided.innerRef}>
317
- {value.points.map(
318
- (p, index) => {
319
- return (
320
- <Draggable key={`${p.points}-${index}`} index={index} draggableId={index.toString()}>
321
- {(provided) => (
322
- <div
323
- className={classes.configHolder}
324
- ref={provided.innerRef}
325
- {...provided.draggableProps}
326
- {...provided.dragHandleProps}
327
- >
328
- <PointConfig
329
- points={value.points.length - 1 - index}
330
- content={p}
331
- error={
332
- pointsDescriptorsErrors && pointsDescriptorsErrors[value.points.length - 1 - index]
333
- }
334
- sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}
335
- onChange={(content) => this.changeContent(index, content, 'points')}
336
- onSampleChange={(content) => this.changeContent(index, content, 'sampleAnswers')}
337
- onMenuChange={(clickedItem) => this.onPointMenuChange(index, clickedItem)}
338
- mathMlOptions={mathMlOptions}
339
- pluginOpts={pluginOpts}
340
- imageSupport={imageSupport}
341
- excludeZero={value.excludeZero}
342
- />
343
- </div>
344
- )}
345
- </Draggable>
346
- );
347
- },
348
- )}
330
+ {value.points.map((p, index) => {
331
+ return (
332
+ <Draggable key={`${p.points}-${index}`} index={index} draggableId={index.toString()}>
333
+ {(provided) => (
334
+ <div
335
+ className={classes.configHolder}
336
+ ref={provided.innerRef}
337
+ {...provided.draggableProps}
338
+ {...provided.dragHandleProps}
339
+ >
340
+ <PointConfig
341
+ points={value.points.length - 1 - index}
342
+ content={p}
343
+ error={
344
+ pointsDescriptorsErrors && pointsDescriptorsErrors[value.points.length - 1 - index]
345
+ }
346
+ sampleAnswer={value.sampleAnswers && value.sampleAnswers[index]}
347
+ onChange={(content) => this.changeContent(index, content, 'points')}
348
+ onSampleChange={(content) => this.changeContent(index, content, 'sampleAnswers')}
349
+ onMenuChange={(clickedItem) => this.onPointMenuChange(index, clickedItem)}
350
+ mathMlOptions={mathMlOptions}
351
+ pluginOpts={pluginOpts}
352
+ imageSupport={imageSupport}
353
+ excludeZero={value.excludeZero}
354
+ />
355
+ </div>
356
+ )}
357
+ </Draggable>
358
+ );
359
+ })}
349
360
  {provided.placeholder}
350
361
  </div>
351
362
  )}
@@ -383,7 +394,7 @@ const styles = (theme) => ({
383
394
  margin: theme.spacing.unit,
384
395
  },
385
396
  customColor: {
386
- color: `${color.tertiary()} !important`
397
+ color: `${color.tertiary()} !important`,
387
398
  },
388
399
  });
389
400
 
@@ -3,6 +3,20 @@
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
+ ## [3.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-controller@3.1.6...@pie-element/rubric-controller@3.1.7) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
12
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
13
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
14
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
15
+
16
+
17
+
18
+
19
+
6
20
  ## [3.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/rubric-controller@3.1.5...@pie-element/rubric-controller@3.1.6) (2025-05-22)
7
21
 
8
22
 
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@pie-element/rubric-controller",
3
3
  "private": true,
4
- "version": "3.1.6",
4
+ "version": "3.1.7",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
7
  "test": "./node_modules/.bin/jest"
8
8
  },
9
9
  "dependencies": {
10
- "@pie-lib/pie-toolbox": "2.17.3",
10
+ "@pie-lib/pie-toolbox": "2.17.6",
11
11
  "lodash": "^4.17.15"
12
12
  }
13
13
  }
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.2/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.1/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -42009,8 +42009,10 @@ const require$$32 = _dll_pie_lib__pie_toolbox_render_ui;
42009
42009
  });
42010
42010
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeMaxPoints", function (maxPoints) {
42011
42011
  var _this$props3 = _this.props, value = _this$props3.value, onChange = _this$props3.onChange;
42012
+ var excludeZero = maxPoints === 1 ? false : value.excludeZero;
42012
42013
  onChange(_objectSpread(_objectSpread({}, value), {}, {
42013
- maxPoints: maxPoints
42014
+ maxPoints: maxPoints,
42015
+ excludeZero: excludeZero
42014
42016
  }));
42015
42017
  });
42016
42018
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeContent", function (index, content, type) {
@@ -42073,7 +42075,8 @@ const require$$32 = _dll_pie_lib__pie_toolbox_render_ui;
42073
42075
  control: _react["default"].createElement(_Checkbox["default"], {
42074
42076
  className: classes.customColor,
42075
42077
  checked: value.excludeZero,
42076
- onChange: this.excludeZeros
42078
+ onChange: this.excludeZeros,
42079
+ disabled: maxPointsValue === 1
42077
42080
  })
42078
42081
  })), rubriclessInstructionEnabled && rubricless && _react["default"].createElement(_configUi.InputContainer, {
42079
42082
  label: rubriclessInstruction.label,
@@ -42550,7 +42553,10 @@ const require$$13 = _dll_debug;
42550
42553
  if (!nextModel) {
42551
42554
  return currentModel;
42552
42555
  }
42553
- var validatedModel = nextModel;
42556
+ var validatedModel = _objectSpread({}, nextModel);
42557
+ if (validatedModel.maxPoints === 1) {
42558
+ validatedModel.excludeZero = false;
42559
+ }
42554
42560
  var _ref = validatedModel || ({}), maxPoints = _ref.maxPoints, excludeZero = _ref.excludeZero;
42555
42561
  validatedModel.points = validatedModel.points ? (0, _toConsumableArray2["default"])(validatedModel.points) : [];
42556
42562
  validatedModel.sampleAnswers = validatedModel.sampleAnswers ? (0, _toConsumableArray2["default"])(validatedModel.sampleAnswers) : [];
@@ -42632,7 +42638,6 @@ const require$$13 = _dll_debug;
42632
42638
  }, {
42633
42639
  key: "_render",
42634
42640
  value: function _render() {
42635
- console.log('THE MODEL', this._model);
42636
42641
  if (this._model) {
42637
42642
  var element = _react["default"].createElement(_main["default"], {
42638
42643
  model: this._model,
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.2/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.1/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -4,11 +4,11 @@
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "4.1.2"
7
+ "version": "4.1.5"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "7.0.1"
11
+ "version": "7.0.4"
12
12
  }
13
13
  ]
14
14
  }
package/module/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.2/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.1/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/rubric",
3
- "version": "4.7.2-next.6+e5b8139f0",
3
+ "version": "4.7.2",
4
4
  "main": "lib/index.js",
5
5
  "module": "src/index.js",
6
6
  "description": "Rubric Scoring Interaction",
@@ -10,12 +10,12 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@material-ui/core": "^3.9.2",
13
- "@pie-lib/pie-toolbox": "2.17.3",
13
+ "@pie-lib/pie-toolbox": "2.17.6",
14
14
  "prop-types": "^15.7.2"
15
15
  },
16
16
  "author": "pie framework developers",
17
17
  "license": "ISC",
18
- "gitHead": "e5b8139f0c9d8b2a894051393c4d37fc33a09e84",
18
+ "gitHead": "148a29a55830c59e50e390d512b19d730e3d1663",
19
19
  "scripts": {
20
20
  "postpublish": "../../scripts/postpublish"
21
21
  },