@pie-element/complex-rubric 2.2.8 → 2.2.9-next.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.
@@ -158,10 +158,16 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
158
158
  exports.createCorrectResponseSession = createCorrectResponseSession;
159
159
 
160
160
  var validateSimpleRubric = function validateSimpleRubric(model) {
161
- var points = model.points;
161
+ var points = model.points,
162
+ excludeZero = model.excludeZero;
162
163
  var errors = {};
163
164
  var pointsDescriptorsErrors = {};
164
165
  (points || []).forEach(function (point, index) {
166
+ if (index === 0 && excludeZero) {
167
+ // if excludeZero is true, the 0 point is not displayed, so it should not be validated
168
+ return;
169
+ }
170
+
165
171
  if (!point || point === '<div></div>') {
166
172
  pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
167
173
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["RUBRIC_TYPES","SIMPLE_RUBRIC","MULTI_TRAIT_RUBRIC","createDefaultModel","model","Promise","resolve","defaults","normalize","question","session","env","normalizedQuestion","rubricType","role","rubrics","multiTraitRubric","visible","visibleToStudent","scales","excludeZero","parsedScales","map","scale","simpleRubric","rubricless","getScore","outcome","score","empty","createCorrectResponseSession","mode","id","validateSimpleRubric","points","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length","validateMultiTraitRubric","description","pointLabels","traitsErrors","scorePointsErrors","scaleIndex","traits","scorePointsLabels","scaleErrors","scorePointsLabelsErrors","scorePointLabel","scoreIndex","identicalScorePointLabel","s","trait","traitIndex","name","identicalTraitName","t","identicalTraitDescr","validate","config"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA;AACA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,aAAa,EAAE,cADI;AAEnBC,EAAAA,kBAAkB,EAAE,kBAFD;AAGnB,gBAAc;AAHK,CAArB;;AAMO,SAASC,kBAAT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;AACD,CAhBM","sourcesContent":["import defaults from './defaults';\nimport { markupToText } from './utils';\n\n// todo the import from pie-lib/rubric might break webpack\nconst RUBRIC_TYPES = {\n SIMPLE_RUBRIC: 'simpleRubric',\n MULTI_TRAIT_RUBRIC: 'multiTraitRubric',\n 'rubricless': 'rubricless',\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults.model, ...model }));\n}\n\nexport const normalize = (question) => ({ ...defaults.model, ...question });\n\n/**\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n\n if (normalizedQuestion.rubricType === RUBRIC_TYPES.SIMPLE_RUBRIC || normalizedQuestion.rubricType === 'rubricless') {\n return new Promise((resolve) => {\n resolve(\n env && env.role && env.role === 'instructor'\n ? {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n visible: false,\n },\n },\n }\n : {},\n );\n });\n } else {\n if (\n !env.role ||\n (env.role === 'student' && normalizedQuestion.rubrics && normalizedQuestion.rubrics.multiTraitRubric)\n ) {\n normalizedQuestion.rubrics.multiTraitRubric.visible = normalizedQuestion.visibleToStudent;\n } else {\n normalizedQuestion.rubrics.multiTraitRubric.visible = true;\n }\n\n // todo update pie-ui instead of parsing this here:\n const { scales, excludeZero } = normalizedQuestion.rubrics.multiTraitRubric || {};\n const parsedScales = (scales || []).map((scale) => ({ ...scale, excludeZero }));\n\n return {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n simpleRubric: {\n ...normalizedQuestion.rubrics.simpleRubric,\n visible: false,\n },\n rubricless: {\n ...normalizedQuestion.rubrics.rubricless,\n visible: false,\n },\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n scales: parsedScales,\n },\n },\n };\n }\n}\n\nexport const getScore = () => 0;\n\n/**\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome() {\n return new Promise((resolve) => resolve({ score: 0, empty: true }));\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({ id: '1' });\n } else {\n resolve(null);\n }\n });\n};\n\n// IMPORTANT! This function is a duplicate of rubric/controller/validate function!\n// If you make any changes to this function, please make sure you also update rubric/controller/validate function!“.\nconst validateSimpleRubric = (model) => {\n const { points } = model;\n const errors = {};\n const pointsDescriptorsErrors = {};\n\n (points || []).forEach((point, index) => {\n if(!point|| point === '<div></div>') {\n pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';\n }\n else{\n const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));\n\n if (identicalPointDescr) {\n pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';\n }\n }\n });\n\n if(Object.keys(pointsDescriptorsErrors).length > 0){\n errors.pointsDescriptorsErrors = pointsDescriptorsErrors;\n }\n\n return errors;\n};\n\n// IMPORTANT! This function is a duplicate of multi-trait-rubric/controller/validate function!\n// If you make any changes to this function, please make sure you also update multi-trait-rubric/controller/validate function!“.\nconst validateMultiTraitRubric = (model) => {\n const { scales, description = false, pointLabels = false } = model;\n const errors = {};\n const traitsErrors = {};\n const scorePointsErrors = {};\n\n (scales || []).forEach((scale, scaleIndex) => {\n const { traits = [] } = scale;\n const { scorePointsLabels = [] } = scale;\n const scaleErrors = {};\n const scorePointsLabelsErrors = {};\n\n if(pointLabels) {\n scorePointsLabels.forEach((scorePointLabel, scoreIndex) => {\n if (!scorePointLabel || scorePointLabel === '<div></div>') {\n scorePointsLabelsErrors[scoreIndex] = 'Points labels should not be empty.';\n } else {\n const identicalScorePointLabel = scorePointsLabels.slice(scoreIndex + 1).some(s => markupToText(s) === markupToText(scorePointLabel));\n\n if (identicalScorePointLabel) {\n scorePointsLabelsErrors[scoreIndex] = 'Points labels should be unique.';\n }\n }\n })\n }\n\n if(Object.keys(scorePointsLabelsErrors).length > 0){\n scorePointsErrors[scaleIndex] = scorePointsLabelsErrors;\n }\n\n traits.forEach((trait, traitIndex) => {\n if(!trait.name || trait.name === '<div></div>') {\n scaleErrors[traitIndex] = {name: 'Trait names should not be empty.'};\n }\n else{\n const identicalTraitName = traits.slice(traitIndex + 1).some(t => markupToText(t.name) === markupToText(trait.name));\n\n if (identicalTraitName) {\n scaleErrors[traitIndex] = {name: 'Trait names should be unique.'};\n }\n }\n if(description && (!trait.description || trait.description === '<div></div>')) {\n scaleErrors[traitIndex] = {... scaleErrors[traitIndex], description: 'Trait description should not be empty'};\n }\n else{\n const identicalTraitDescr = traits.slice(traitIndex + 1).some(t => markupToText(t.description) === markupToText(trait.description));\n\n if (description && identicalTraitDescr) {\n scaleErrors[traitIndex] = {... scaleErrors[traitIndex], description: 'Trait descriptions should be unique.'};\n }\n }\n\n });\n if(Object.keys(scaleErrors).length > 0){\n traitsErrors[scaleIndex] = scaleErrors;\n }\n });\n\n if(Object.keys(traitsErrors).length > 0){\n errors.traitsErrors = traitsErrors;\n }\n\n if(Object.keys(scorePointsErrors).length > 0){\n errors.scorePointsErrors = scorePointsErrors;\n }\n\n return errors;\n};\n\n\nexport const validate = (model = {}, config = {}) => {\n const { rubrics = {}, rubricType } = model;\n const { multiTraitRubric = {}, simpleRubric = {} } = rubrics;\n let errors = {};\n\n switch (rubricType) {\n case RUBRIC_TYPES.SIMPLE_RUBRIC:\n default:\n errors = validateSimpleRubric(simpleRubric);\n break;\n case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:\n errors = validateMultiTraitRubric(multiTraitRubric);\n break;\n }\n\n return errors;\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["RUBRIC_TYPES","SIMPLE_RUBRIC","MULTI_TRAIT_RUBRIC","createDefaultModel","model","Promise","resolve","defaults","normalize","question","session","env","normalizedQuestion","rubricType","role","rubrics","multiTraitRubric","visible","visibleToStudent","scales","excludeZero","parsedScales","map","scale","simpleRubric","rubricless","getScore","outcome","score","empty","createCorrectResponseSession","mode","id","validateSimpleRubric","points","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length","validateMultiTraitRubric","description","pointLabels","traitsErrors","scorePointsErrors","scaleIndex","traits","scorePointsLabels","scaleErrors","scorePointsLabelsErrors","scorePointLabel","scoreIndex","identicalScorePointLabel","s","trait","traitIndex","name","identicalTraitName","t","identicalTraitDescr","validate","config"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA;AACA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,aAAa,EAAE,cADI;AAEnBC,EAAAA,kBAAkB,EAAE,kBAFD;AAGnB,gBAAc;AAHK,CAArB;;AAMO,SAASC,kBAAT,GAAwC;AAAA,MAAZC,KAAY,uEAAJ,EAAI;AAC7C,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD;AAAA,WAAaA,OAAO,iCAAMC,qBAASH,KAAf,GAAyBA,KAAzB,EAApB;AAAA,GAAZ,CAAP;AACD;;AAEM,IAAMI,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD;AAAA,yCAAoBF,qBAASH,KAA7B,GAAuCK,QAAvC;AAAA,CAAlB;AAEP;AACA;AACA;AACA;AACA;;;;;SACsBL,K;;;;;yFAAf,iBAAqBK,QAArB,EAA+BC,OAA/B,EAAwCC,GAAxC;AAAA;;AAAA;AAAA;AAAA;AAAA;AACCC,YAAAA,kBADD,GACsBJ,SAAS,CAACC,QAAD,CAD/B;;AAAA,kBAGDG,kBAAkB,CAACC,UAAnB,KAAkCb,YAAY,CAACC,aAA/C,IAAgEW,kBAAkB,CAACC,UAAnB,KAAkC,YAHjG;AAAA;AAAA;AAAA;;AAAA,6CAII,IAAIR,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9BA,cAAAA,OAAO,CACLK,GAAG,IAAIA,GAAG,CAACG,IAAX,IAAmBH,GAAG,CAACG,IAAJ,KAAa,YAAhC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AAA,MAA5B/D,KAA4B,uEAApB,EAAoB;AAAA,MAAhBgE,MAAgB,uEAAP,EAAO;AACnD,uBAAqChE,KAArC,CAAQW,OAAR;AAAA,MAAQA,OAAR,+BAAkB,EAAlB;AAAA,MAAsBF,UAAtB,GAAqCT,KAArC,CAAsBS,UAAtB;AACA,8BAAqDE,OAArD,CAAQC,gBAAR;AAAA,MAAQA,gBAAR,sCAA2B,EAA3B;AAAA,8BAAqDD,OAArD,CAA+BS,YAA/B;AAAA,MAA+BA,YAA/B,sCAA8C,EAA9C;AACA,MAAIW,MAAM,GAAG,EAAb;;AAEA,UAAQtB,UAAR;AACE,SAAKb,YAAY,CAACC,aAAlB;AACA;AACEkC,MAAAA,MAAM,GAAGF,oBAAoB,CAACT,YAAD,CAA7B;AACA;;AACF,SAAKxB,YAAY,CAACE,kBAAlB;AACEiC,MAAAA,MAAM,GAAGY,wBAAwB,CAAC/B,gBAAD,CAAjC;AACA;AAPJ;;AAUA,SAAOmB,MAAP;AACD,CAhBM","sourcesContent":["import defaults from './defaults';\nimport { markupToText } from './utils';\n\n// todo the import from pie-lib/rubric might break webpack\nconst RUBRIC_TYPES = {\n SIMPLE_RUBRIC: 'simpleRubric',\n MULTI_TRAIT_RUBRIC: 'multiTraitRubric',\n 'rubricless': 'rubricless',\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults.model, ...model }));\n}\n\nexport const normalize = (question) => ({ ...defaults.model, ...question });\n\n/**\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n\n if (normalizedQuestion.rubricType === RUBRIC_TYPES.SIMPLE_RUBRIC || normalizedQuestion.rubricType === 'rubricless') {\n return new Promise((resolve) => {\n resolve(\n env && env.role && env.role === 'instructor'\n ? {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n visible: false,\n },\n },\n }\n : {},\n );\n });\n } else {\n if (\n !env.role ||\n (env.role === 'student' && normalizedQuestion.rubrics && normalizedQuestion.rubrics.multiTraitRubric)\n ) {\n normalizedQuestion.rubrics.multiTraitRubric.visible = normalizedQuestion.visibleToStudent;\n } else {\n normalizedQuestion.rubrics.multiTraitRubric.visible = true;\n }\n\n // todo update pie-ui instead of parsing this here:\n const { scales, excludeZero } = normalizedQuestion.rubrics.multiTraitRubric || {};\n const parsedScales = (scales || []).map((scale) => ({ ...scale, excludeZero }));\n\n return {\n ...normalizedQuestion,\n rubrics: {\n ...normalizedQuestion.rubrics,\n simpleRubric: {\n ...normalizedQuestion.rubrics.simpleRubric,\n visible: false,\n },\n rubricless: {\n ...normalizedQuestion.rubrics.rubricless,\n visible: false,\n },\n multiTraitRubric: {\n ...normalizedQuestion.rubrics.multiTraitRubric,\n scales: parsedScales,\n },\n },\n };\n }\n}\n\nexport const getScore = () => 0;\n\n/**\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome() {\n return new Promise((resolve) => resolve({ score: 0, empty: true }));\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({ id: '1' });\n } else {\n resolve(null);\n }\n });\n};\n\n// IMPORTANT! This function is a duplicate of rubric/controller/validate function!\n// If you make any changes to this function, please make sure you also update rubric/controller/validate function!“.\nconst validateSimpleRubric = (model) => {\n const { points, excludeZero } = model;\n const errors = {};\n const pointsDescriptorsErrors = {};\n\n (points || []).forEach((point, index) => {\n if (index === 0 && excludeZero) {\n // if excludeZero is true, the 0 point is not displayed, so it should not be validated\n return;\n }\n\n if (!point || point === '<div></div>') {\n pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';\n } else {\n const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));\n\n if (identicalPointDescr) {\n pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';\n }\n }\n });\n\n if (Object.keys(pointsDescriptorsErrors).length > 0) {\n errors.pointsDescriptorsErrors = pointsDescriptorsErrors;\n }\n\n return errors;\n};\n\n// IMPORTANT! This function is a duplicate of multi-trait-rubric/controller/validate function!\n// If you make any changes to this function, please make sure you also update multi-trait-rubric/controller/validate function!“.\nconst validateMultiTraitRubric = (model) => {\n const { scales, description = false, pointLabels = false } = model;\n const errors = {};\n const traitsErrors = {};\n const scorePointsErrors = {};\n\n (scales || []).forEach((scale, scaleIndex) => {\n const { traits = [] } = scale;\n const { scorePointsLabels = [] } = scale;\n const scaleErrors = {};\n const scorePointsLabelsErrors = {};\n\n if(pointLabels) {\n scorePointsLabels.forEach((scorePointLabel, scoreIndex) => {\n if (!scorePointLabel || scorePointLabel === '<div></div>') {\n scorePointsLabelsErrors[scoreIndex] = 'Points labels should not be empty.';\n } else {\n const identicalScorePointLabel = scorePointsLabels.slice(scoreIndex + 1).some(s => markupToText(s) === markupToText(scorePointLabel));\n\n if (identicalScorePointLabel) {\n scorePointsLabelsErrors[scoreIndex] = 'Points labels should be unique.';\n }\n }\n })\n }\n\n if(Object.keys(scorePointsLabelsErrors).length > 0){\n scorePointsErrors[scaleIndex] = scorePointsLabelsErrors;\n }\n\n traits.forEach((trait, traitIndex) => {\n if(!trait.name || trait.name === '<div></div>') {\n scaleErrors[traitIndex] = {name: 'Trait names should not be empty.'};\n }\n else{\n const identicalTraitName = traits.slice(traitIndex + 1).some(t => markupToText(t.name) === markupToText(trait.name));\n\n if (identicalTraitName) {\n scaleErrors[traitIndex] = {name: 'Trait names should be unique.'};\n }\n }\n if(description && (!trait.description || trait.description === '<div></div>')) {\n scaleErrors[traitIndex] = {... scaleErrors[traitIndex], description: 'Trait description should not be empty'};\n }\n else{\n const identicalTraitDescr = traits.slice(traitIndex + 1).some(t => markupToText(t.description) === markupToText(trait.description));\n\n if (description && identicalTraitDescr) {\n scaleErrors[traitIndex] = {... scaleErrors[traitIndex], description: 'Trait descriptions should be unique.'};\n }\n }\n\n });\n if(Object.keys(scaleErrors).length > 0){\n traitsErrors[scaleIndex] = scaleErrors;\n }\n });\n\n if(Object.keys(traitsErrors).length > 0){\n errors.traitsErrors = traitsErrors;\n }\n\n if(Object.keys(scorePointsErrors).length > 0){\n errors.scorePointsErrors = scorePointsErrors;\n }\n\n return errors;\n};\n\n\nexport const validate = (model = {}, config = {}) => {\n const { rubrics = {}, rubricType } = model;\n const { multiTraitRubric = {}, simpleRubric = {} } = rubrics;\n let errors = {};\n\n switch (rubricType) {\n case RUBRIC_TYPES.SIMPLE_RUBRIC:\n default:\n errors = validateSimpleRubric(simpleRubric);\n break;\n case RUBRIC_TYPES.MULTI_TRAIT_RUBRIC:\n errors = validateMultiTraitRubric(multiTraitRubric);\n break;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -98,15 +98,19 @@ export const createCorrectResponseSession = (question, env) => {
98
98
  // IMPORTANT! This function is a duplicate of rubric/controller/validate function!
99
99
  // If you make any changes to this function, please make sure you also update rubric/controller/validate function!“.
100
100
  const validateSimpleRubric = (model) => {
101
- const { points } = model;
101
+ const { points, excludeZero } = model;
102
102
  const errors = {};
103
103
  const pointsDescriptorsErrors = {};
104
104
 
105
105
  (points || []).forEach((point, index) => {
106
- if(!point|| point === '<div></div>') {
107
- pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
106
+ if (index === 0 && excludeZero) {
107
+ // if excludeZero is true, the 0 point is not displayed, so it should not be validated
108
+ return;
108
109
  }
109
- else{
110
+
111
+ if (!point || point === '<div></div>') {
112
+ pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
113
+ } else {
110
114
  const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
111
115
 
112
116
  if (identicalPointDescr) {
@@ -115,7 +119,7 @@ const validateSimpleRubric = (model) => {
115
119
  }
116
120
  });
117
121
 
118
- if(Object.keys(pointsDescriptorsErrors).length > 0){
122
+ if (Object.keys(pointsDescriptorsErrors).length > 0) {
119
123
  errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
120
124
  }
121
125
 
@@ -258,15 +258,19 @@ const createCorrectResponseSession = (question, env) => {
258
258
  // IMPORTANT! This function is a duplicate of rubric/controller/validate function!
259
259
  // If you make any changes to this function, please make sure you also update rubric/controller/validate function!“.
260
260
  const validateSimpleRubric = (model) => {
261
- const { points } = model;
261
+ const { points, excludeZero } = model;
262
262
  const errors = {};
263
263
  const pointsDescriptorsErrors = {};
264
264
 
265
265
  (points || []).forEach((point, index) => {
266
- if(!point|| point === '<div></div>') {
267
- pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
266
+ if (index === 0 && excludeZero) {
267
+ // if excludeZero is true, the 0 point is not displayed, so it should not be validated
268
+ return;
268
269
  }
269
- else {
270
+
271
+ if (!point || point === '<div></div>') {
272
+ pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
273
+ } else {
270
274
  const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
271
275
 
272
276
  if (identicalPointDescr) {
@@ -275,7 +279,7 @@ const validateSimpleRubric = (model) => {
275
279
  }
276
280
  });
277
281
 
278
- if(Object.keys(pointsDescriptorsErrors).length > 0){
282
+ if (Object.keys(pointsDescriptorsErrors).length > 0) {
279
283
  errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
280
284
  }
281
285
 
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/complex-rubric@2.2.7</title>
5
+ <title>@pie-element/complex-rubric@2.2.8</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/complex-rubric",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-module",
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/complex-rubric@2.2.7</title>
5
+ <title>@pie-element/complex-rubric@2.2.8</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@pie-element/complex-rubric",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "2.2.8",
4
+ "version": "2.2.9-next.2+7521f7fde",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
- "@pie-element/multi-trait-rubric": "^3.2.4",
11
- "@pie-element/rubric": "^3.1.7",
10
+ "@pie-element/multi-trait-rubric": "^3.2.5-next.2+7521f7fde",
11
+ "@pie-element/rubric": "^3.1.8-next.2+7521f7fde",
12
12
  "@pie-framework/pie-player-events": "^0.1.0",
13
13
  "classnames": "^2.2.5",
14
14
  "debug": "^4.1.1",
15
15
  "lodash": "^4.17.11",
16
16
  "prop-types": "^15.7.2"
17
17
  },
18
- "gitHead": "8c538028e6818d63da104cd1d897606e9e7b477f",
18
+ "gitHead": "7521f7fdef22c6f5918d299a7f323a4f54976023",
19
19
  "scripts": {
20
20
  "postpublish": "../../scripts/postpublish"
21
21
  },