@pie-element/complex-rubric 1.12.0 → 1.12.1-beta.1

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/configure/CHANGELOG.md +19 -0
  3. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.json +1 -0
  4. package/configure/node_modules/@pie-element/multi-trait-rubric/CHANGELOG.md +932 -0
  5. package/configure/node_modules/@pie-element/multi-trait-rubric/LICENSE.md +5 -0
  6. package/configure/node_modules/@pie-element/multi-trait-rubric/README.md +55 -0
  7. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.json +1 -0
  8. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/CHANGELOG.md +823 -0
  9. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js +502 -0
  10. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/common.js.map +1 -0
  11. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js +98 -0
  12. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/defaults.js.map +1 -0
  13. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js +126 -0
  14. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/index.js.map +1 -0
  15. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js +553 -0
  16. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/main.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js +361 -0
  18. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/modals.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js +552 -0
  20. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/scale.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js +371 -0
  22. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/trait.js.map +1 -0
  23. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js +270 -0
  24. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/traitsHeader.js.map +1 -0
  25. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js +29 -0
  26. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/lib/utils.js.map +1 -0
  27. package/configure/node_modules/@pie-element/multi-trait-rubric/configure/package.json +22 -0
  28. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.json +1 -0
  29. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/CHANGELOG.md +175 -0
  30. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js +94 -0
  31. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/defaults.js.map +1 -0
  32. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js +161 -0
  33. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/index.js.map +1 -0
  34. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js +13 -0
  35. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/lib/utils.js.map +1 -0
  36. package/configure/node_modules/@pie-element/multi-trait-rubric/controller/package.json +15 -0
  37. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json +272 -0
  38. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/config-schema.json.md +206 -0
  39. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/config.js +8 -0
  40. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/generate.js +180 -0
  41. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/index.html +1 -0
  42. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/demo/session.js +6 -0
  43. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json +298 -0
  44. package/configure/node_modules/@pie-element/multi-trait-rubric/docs/pie-schema.json.md +201 -0
  45. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js +85 -0
  46. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/index.js.map +1 -0
  47. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js +161 -0
  48. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/main.js.map +1 -0
  49. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js +330 -0
  50. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/scale.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js +103 -0
  52. package/configure/node_modules/@pie-element/multi-trait-rubric/lib/trait.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multi-trait-rubric/package.json +24 -0
  54. package/configure/node_modules/@pie-element/rubric/CHANGELOG.json +257 -0
  55. package/configure/node_modules/@pie-element/rubric/CHANGELOG.md +1213 -0
  56. package/configure/node_modules/@pie-element/rubric/LICENSE.md +5 -0
  57. package/configure/node_modules/@pie-element/rubric/README.md +3 -0
  58. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.json +197 -0
  59. package/configure/node_modules/@pie-element/rubric/configure/CHANGELOG.md +1053 -0
  60. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js +34 -0
  61. package/configure/node_modules/@pie-element/rubric/configure/lib/defaults.js.map +1 -0
  62. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js +130 -0
  63. package/configure/node_modules/@pie-element/rubric/configure/lib/index.js.map +1 -0
  64. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js +108 -0
  65. package/configure/node_modules/@pie-element/rubric/configure/lib/main.js.map +1 -0
  66. package/configure/node_modules/@pie-element/rubric/configure/package.json +18 -0
  67. package/configure/node_modules/@pie-element/rubric/configure/src/defaults.js +26 -0
  68. package/configure/node_modules/@pie-element/rubric/configure/src/index.js +64 -0
  69. package/configure/node_modules/@pie-element/rubric/configure/src/main.jsx +56 -0
  70. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.json +17 -0
  71. package/configure/node_modules/@pie-element/rubric/controller/CHANGELOG.md +157 -0
  72. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js +14 -0
  73. package/configure/node_modules/@pie-element/rubric/controller/lib/index.js.map +1 -0
  74. package/configure/node_modules/@pie-element/rubric/controller/package.json +13 -0
  75. package/configure/node_modules/@pie-element/rubric/controller/src/__tests__/index.test.js +31 -0
  76. package/configure/node_modules/@pie-element/rubric/controller/src/index.js +6 -0
  77. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json +160 -0
  78. package/configure/node_modules/@pie-element/rubric/docs/config-schema.json.md +127 -0
  79. package/configure/node_modules/@pie-element/rubric/docs/demo/config.js +8 -0
  80. package/configure/node_modules/@pie-element/rubric/docs/demo/generate.js +8 -0
  81. package/configure/node_modules/@pie-element/rubric/docs/demo/index.html +2 -0
  82. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json +96 -0
  83. package/configure/node_modules/@pie-element/rubric/docs/pie-schema.json.md +65 -0
  84. package/configure/node_modules/@pie-element/rubric/lib/index.js +88 -0
  85. package/configure/node_modules/@pie-element/rubric/lib/index.js.map +1 -0
  86. package/configure/node_modules/@pie-element/rubric/lib/main.js +188 -0
  87. package/configure/node_modules/@pie-element/rubric/lib/main.js.map +1 -0
  88. package/configure/node_modules/@pie-element/rubric/lib/print.js +114 -0
  89. package/configure/node_modules/@pie-element/rubric/lib/print.js.map +1 -0
  90. package/configure/node_modules/@pie-element/rubric/package.json +26 -0
  91. package/configure/node_modules/@pie-element/rubric/src/__tests__/__snapshots__/rubric-view.test.jsx.snap +23003 -0
  92. package/configure/node_modules/@pie-element/rubric/src/__tests__/rubric-view.test.jsx +46 -0
  93. package/configure/node_modules/@pie-element/rubric/src/index.js +34 -0
  94. package/configure/node_modules/@pie-element/rubric/src/main.jsx +136 -0
  95. package/configure/node_modules/@pie-element/rubric/src/print.js +63 -0
  96. package/configure/package.json +7 -7
  97. package/controller/CHANGELOG.md +8 -0
  98. package/controller/package.json +1 -1
  99. package/package.json +4 -4
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createCorrectResponseSession = void 0;
9
+ exports.createDefaultModel = createDefaultModel;
10
+ exports.getScore = void 0;
11
+ exports.model = model;
12
+ exports.normalize = void 0;
13
+ exports.outcome = outcome;
14
+ exports.validate = void 0;
15
+
16
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
17
+
18
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
22
+ var _defaults = _interopRequireDefault(require("./defaults"));
23
+
24
+ var _utils = require("./utils");
25
+
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
+
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
+
30
+ function createDefaultModel() {
31
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
+ return new Promise(function (resolve) {
33
+ return resolve(_objectSpread(_objectSpread({}, _defaults["default"]), model));
34
+ });
35
+ }
36
+
37
+ var normalize = function normalize(question) {
38
+ return _objectSpread(_objectSpread({}, _defaults["default"]), question);
39
+ };
40
+ /**
41
+ *
42
+ * @param {*} question
43
+ * @param {*} session
44
+ * @param {*} env
45
+ */
46
+
47
+
48
+ exports.normalize = normalize;
49
+
50
+ function model(_x, _x2, _x3) {
51
+ return _model.apply(this, arguments);
52
+ }
53
+
54
+ function _model() {
55
+ _model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env) {
56
+ var normalizedQuestion, _ref, scales, excludeZero, parsedScales;
57
+
58
+ return _regenerator["default"].wrap(function _callee$(_context) {
59
+ while (1) {
60
+ switch (_context.prev = _context.next) {
61
+ case 0:
62
+ normalizedQuestion = normalize(question);
63
+
64
+ if (!env.role || env.role === 'student') {
65
+ normalizedQuestion.visible = normalizedQuestion.visibleToStudent;
66
+ } else {
67
+ normalizedQuestion.visible = true;
68
+ } // todo update pie-ui instead of parsing this here:
69
+
70
+
71
+ _ref = normalizedQuestion || {}, scales = _ref.scales, excludeZero = _ref.excludeZero;
72
+ parsedScales = (scales || []).map(function (scale) {
73
+ return _objectSpread(_objectSpread({}, scale), {}, {
74
+ excludeZero: excludeZero
75
+ });
76
+ });
77
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, normalizedQuestion), {}, {
78
+ scales: parsedScales
79
+ }));
80
+
81
+ case 5:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }
86
+ }, _callee);
87
+ }));
88
+ return _model.apply(this, arguments);
89
+ }
90
+
91
+ var getScore = function getScore() {
92
+ return 0;
93
+ };
94
+ /**
95
+ * @param {Object} model - the main model
96
+ * @param {*} session
97
+ * @param {Object} env
98
+ */
99
+
100
+
101
+ exports.getScore = getScore;
102
+
103
+ function outcome() {
104
+ return new Promise(function (resolve) {
105
+ return resolve({
106
+ score: 0,
107
+ empty: true
108
+ });
109
+ });
110
+ }
111
+
112
+ var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
113
+ return new Promise(function (resolve) {
114
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
115
+ resolve({
116
+ id: '1'
117
+ });
118
+ } else {
119
+ resolve(null);
120
+ }
121
+ });
122
+ };
123
+
124
+ exports.createCorrectResponseSession = createCorrectResponseSession;
125
+
126
+ var validate = function validate(model, config) {
127
+ var scales = model.scales;
128
+ var errors = {};
129
+ var traitsErrors = {};
130
+ (scales || []).forEach(function (scale, scaleIndex) {
131
+ var _scale$traits = scale.traits,
132
+ traits = _scale$traits === void 0 ? [] : _scale$traits;
133
+ var scaleErrors = {};
134
+ traits.forEach(function (trait, traitIndex) {
135
+ if (!trait.name || trait.name === '<div></div>') {
136
+ scaleErrors[traitIndex] = 'Trait names should not be empty.';
137
+ } else {
138
+ var identicalTraitName = traits.slice(traitIndex + 1).some(function (t) {
139
+ return (0, _utils.markupToText)(t.name) === (0, _utils.markupToText)(trait.name);
140
+ });
141
+
142
+ if (identicalTraitName) {
143
+ scaleErrors[traitIndex] = 'Trait names should be unique.';
144
+ }
145
+ }
146
+ });
147
+
148
+ if (Object.keys(scaleErrors).length > 0) {
149
+ traitsErrors[scaleIndex] = scaleErrors;
150
+ }
151
+ });
152
+
153
+ if (Object.keys(traitsErrors).length > 0) {
154
+ errors.traitsErrors = traitsErrors;
155
+ }
156
+
157
+ return errors;
158
+ };
159
+
160
+ exports.validate = validate;
161
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":["createDefaultModel","model","Promise","resolve","defaults","normalize","question","session","env","normalizedQuestion","role","visible","visibleToStudent","scales","excludeZero","parsedScales","map","scale","getScore","outcome","score","empty","createCorrectResponseSession","mode","id","validate","config","errors","traitsErrors","forEach","scaleIndex","traits","scaleErrors","trait","traitIndex","name","identicalTraitName","slice","some","t","Object","keys","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,SAASA,kBAAT,GAAwC;AAAA,MAAZC,KAAY,uEAAJ,EAAI;AAC7C,SAAO,IAAIC,OAAJ,CAAY,UAACC,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AA3B;;AAEA,YAAIC,kBAAJ,EAAwB;AACtBJ,UAAAA,WAAW,CAACE,UAAD,CAAX,GAA0B,+BAA1B;AACD;AACF;AACF,KAXD;;AAYA,QAAGM,MAAM,CAACC,IAAP,CAAYT,WAAZ,EAAyBU,MAAzB,GAAkC,CAArC,EAAuC;AACrCd,MAAAA,YAAY,CAACE,UAAD,CAAZ,GAA2BE,WAA3B;AACD;AACF,GAlBD;;AAmBA,MAAGQ,MAAM,CAACC,IAAP,CAAYb,YAAZ,EAA0Bc,MAA1B,GAAmC,CAAtC,EAAwC;AACtCf,IAAAA,MAAM,CAACC,YAAP,GAAsBA,YAAtB;AACD;;AAED,SAAOD,MAAP;AACD,CA7BM","sourcesContent":["import defaults from './defaults';\nimport { markupToText } from './utils';\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\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 (!env.role || env.role === 'student') {\n normalizedQuestion.visible = normalizedQuestion.visibleToStudent;\n } else {\n normalizedQuestion.visible = true;\n }\n\n // todo update pie-ui instead of parsing this here:\n const { scales, excludeZero } = normalizedQuestion || {};\n const parsedScales = (scales || []).map((scale) => ({ ...scale, excludeZero }));\n\n return {\n ...normalizedQuestion,\n scales: parsedScales,\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\nexport const validate = (model, config) => {\n const { scales } = model;\n const errors = {};\n const traitsErrors = {};\n\n (scales || []).forEach((scale, scaleIndex) => {\n const { traits = [] } = scale;\n const scaleErrors = {};\n traits.forEach((trait, traitIndex) => {\n if(!trait.name || trait.name === '<div></div>') {\n scaleErrors[traitIndex] = '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] = 'Trait names should be unique.';\n }\n }\n });\n if(Object.keys(scaleErrors).length > 0){\n traitsErrors[scaleIndex] = scaleErrors;\n }\n });\n if(Object.keys(traitsErrors).length > 0){\n errors.traitsErrors = traitsErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.markupToText = void 0;
7
+
8
+ var markupToText = function markupToText(s) {
9
+ return (s || '').replace(/(<([^>]+)>)/ig, '');
10
+ };
11
+
12
+ exports.markupToText = markupToText;
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.js"],"names":["markupToText","s","replace"],"mappings":";;;;;;;AAAO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,CAAD,EAAO;AAC/B,SAAO,CAACA,CAAC,IAAI,EAAN,EAAUC,OAAV,CAAkB,eAAlB,EAAmC,EAAnC,CAAP;AACH,CAFM","sourcesContent":["export const markupToText = (s) => {\n return (s || '').replace(/(<([^>]+)>)/ig, '');\n};\n"],"file":"utils.js"}
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@pie-element/multi-trait-rubric-controller",
3
+ "private": true,
4
+ "version": "1.4.0",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "author": "",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "@pie-lib/controller-utils": "^0.2.44",
12
+ "debug": "^3.1.0",
13
+ "lodash": "^4.17.15"
14
+ }
15
+ }
@@ -0,0 +1,272 @@
1
+ {
2
+ "description": "Config Object for @pie-elements/multi-trait-rubric",
3
+ "additionalProperties": false,
4
+ "type": "object",
5
+ "properties": {
6
+ "excludeZeroDialogBoxContent": {
7
+ "title": "DialogContent",
8
+ "type": "object",
9
+ "properties": {
10
+ "title": {
11
+ "description": "Dialog box title",
12
+ "type": "string",
13
+ "title": "title"
14
+ },
15
+ "text": {
16
+ "description": "Dialog box text",
17
+ "type": "string",
18
+ "title": "text"
19
+ }
20
+ }
21
+ },
22
+ "includeZeroDialogBoxContent": {
23
+ "title": "DialogContent",
24
+ "type": "object",
25
+ "properties": {
26
+ "title": {
27
+ "description": "Dialog box title",
28
+ "type": "string",
29
+ "title": "title"
30
+ },
31
+ "text": {
32
+ "description": "Dialog box text",
33
+ "type": "string",
34
+ "title": "text"
35
+ }
36
+ }
37
+ },
38
+ "deleteScaleDialogBoxContent": {
39
+ "title": "DialogContent",
40
+ "type": "object",
41
+ "properties": {
42
+ "title": {
43
+ "description": "Dialog box title",
44
+ "type": "string",
45
+ "title": "title"
46
+ },
47
+ "text": {
48
+ "description": "Dialog box text",
49
+ "type": "string",
50
+ "title": "text"
51
+ }
52
+ }
53
+ },
54
+ "maxPointsDialogBoxContent": {
55
+ "title": "DialogContent",
56
+ "type": "object",
57
+ "properties": {
58
+ "title": {
59
+ "description": "Dialog box title",
60
+ "type": "string",
61
+ "title": "title"
62
+ },
63
+ "text": {
64
+ "description": "Dialog box text",
65
+ "type": "string",
66
+ "title": "text"
67
+ }
68
+ }
69
+ },
70
+ "settingsPanelDisabled": {
71
+ "description": "Indicates if the settings panel is not available",
72
+ "type": "boolean",
73
+ "title": "settingsPanelDisabled"
74
+ },
75
+ "showExcludeZero": {
76
+ "title": "ConfigureProp",
77
+ "type": "object",
78
+ "properties": {
79
+ "settings": {
80
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
81
+ "type": "boolean",
82
+ "title": "settings"
83
+ },
84
+ "label": {
85
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
86
+ "type": "string",
87
+ "title": "label"
88
+ }
89
+ }
90
+ },
91
+ "showScorePointLabels": {
92
+ "title": "ConfigureProp",
93
+ "type": "object",
94
+ "properties": {
95
+ "settings": {
96
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
97
+ "type": "boolean",
98
+ "title": "settings"
99
+ },
100
+ "label": {
101
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
102
+ "type": "string",
103
+ "title": "label"
104
+ }
105
+ }
106
+ },
107
+ "showDescription": {
108
+ "title": "ConfigureProp",
109
+ "type": "object",
110
+ "properties": {
111
+ "settings": {
112
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
113
+ "type": "boolean",
114
+ "title": "settings"
115
+ },
116
+ "label": {
117
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
118
+ "type": "string",
119
+ "title": "label"
120
+ }
121
+ }
122
+ },
123
+ "showVisibleToStudent": {
124
+ "title": "ConfigureProp",
125
+ "type": "object",
126
+ "properties": {
127
+ "settings": {
128
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
129
+ "type": "boolean",
130
+ "title": "settings"
131
+ },
132
+ "label": {
133
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
134
+ "type": "string",
135
+ "title": "label"
136
+ }
137
+ }
138
+ },
139
+ "showHalfScoring": {
140
+ "title": "ConfigureProp",
141
+ "type": "object",
142
+ "properties": {
143
+ "settings": {
144
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
145
+ "type": "boolean",
146
+ "title": "settings"
147
+ },
148
+ "label": {
149
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
150
+ "type": "string",
151
+ "title": "label"
152
+ }
153
+ }
154
+ },
155
+ "spellCheck": {
156
+ "title": "ConfigureProp",
157
+ "type": "object",
158
+ "properties": {
159
+ "settings": {
160
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
161
+ "type": "boolean",
162
+ "title": "settings"
163
+ },
164
+ "label": {
165
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
166
+ "type": "string",
167
+ "title": "label"
168
+ }
169
+ }
170
+ },
171
+ "width": {
172
+ "description": "How large (in px) should multi-trait-rubric be",
173
+ "type": "string",
174
+ "title": "width"
175
+ },
176
+ "minNoOfTraits": {
177
+ "description": "Minimum number of traits",
178
+ "type": "number",
179
+ "title": "minNoOfTraits"
180
+ },
181
+ "maxNoOfTraits": {
182
+ "description": "Maximum number of traits",
183
+ "type": "number",
184
+ "title": "maxNoOfTraits"
185
+ },
186
+ "minNoOfScales": {
187
+ "description": "Minimum number of scales",
188
+ "type": "number",
189
+ "title": "minNoOfScales"
190
+ },
191
+ "maxNoOfScales": {
192
+ "description": "Maximum number of scales",
193
+ "type": "number",
194
+ "title": "maxNoOfScales"
195
+ },
196
+ "defaultTraitLabel": {
197
+ "description": "The default trait label for new created scales.\nIf it's not defined, it will default to the label of the first trait.",
198
+ "type": "string",
199
+ "title": "defaultTraitLabel"
200
+ },
201
+ "mathMlOptions": {
202
+ "title": "ConfigureMathMLProp",
203
+ "type": "object",
204
+ "properties": {
205
+ "mmlOutput": {
206
+ "description": "Indicates if model should have mathML output instead of latex",
207
+ "type": "number",
208
+ "title": "mmlOutput"
209
+ },
210
+ "mmlEditing": {
211
+ "description": "Indicates if mathML that's already in model should be editable",
212
+ "type": "number",
213
+ "title": "mmlEditing"
214
+ }
215
+ }
216
+ }
217
+ },
218
+ "required": [
219
+ "width"
220
+ ],
221
+ "definitions": {
222
+ "DialogContent": {
223
+ "title": "DialogContent",
224
+ "type": "object",
225
+ "properties": {
226
+ "title": {
227
+ "description": "Dialog box title",
228
+ "type": "string",
229
+ "title": "title"
230
+ },
231
+ "text": {
232
+ "description": "Dialog box text",
233
+ "type": "string",
234
+ "title": "text"
235
+ }
236
+ }
237
+ },
238
+ "ConfigureProp": {
239
+ "title": "ConfigureProp",
240
+ "type": "object",
241
+ "properties": {
242
+ "settings": {
243
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
244
+ "type": "boolean",
245
+ "title": "settings"
246
+ },
247
+ "label": {
248
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
249
+ "type": "string",
250
+ "title": "label"
251
+ }
252
+ }
253
+ },
254
+ "ConfigureMathMLProp": {
255
+ "title": "ConfigureMathMLProp",
256
+ "type": "object",
257
+ "properties": {
258
+ "mmlOutput": {
259
+ "description": "Indicates if model should have mathML output instead of latex",
260
+ "type": "number",
261
+ "title": "mmlOutput"
262
+ },
263
+ "mmlEditing": {
264
+ "description": "Indicates if mathML that's already in model should be editable",
265
+ "type": "number",
266
+ "title": "mmlEditing"
267
+ }
268
+ }
269
+ }
270
+ },
271
+ "$schema": "http://json-schema.org/draft-07/schema#"
272
+ }
@@ -0,0 +1,206 @@
1
+ Config Object for @pie-elements/multi-trait-rubric
2
+
3
+ The schema defines the following properties:
4
+
5
+ # `excludeZeroDialogBoxContent` (object)
6
+
7
+ Properties of the `excludeZeroDialogBoxContent` object:
8
+
9
+ ## `title` (string)
10
+
11
+ Dialog box title
12
+
13
+ ## `text` (string)
14
+
15
+ Dialog box text
16
+
17
+ # `includeZeroDialogBoxContent` (object)
18
+
19
+ Properties of the `includeZeroDialogBoxContent` object:
20
+
21
+ ## `title` (string)
22
+
23
+ Dialog box title
24
+
25
+ ## `text` (string)
26
+
27
+ Dialog box text
28
+
29
+ # `deleteScaleDialogBoxContent` (object)
30
+
31
+ Properties of the `deleteScaleDialogBoxContent` object:
32
+
33
+ ## `title` (string)
34
+
35
+ Dialog box title
36
+
37
+ ## `text` (string)
38
+
39
+ Dialog box text
40
+
41
+ # `maxPointsDialogBoxContent` (object)
42
+
43
+ Properties of the `maxPointsDialogBoxContent` object:
44
+
45
+ ## `title` (string)
46
+
47
+ Dialog box title
48
+
49
+ ## `text` (string)
50
+
51
+ Dialog box text
52
+
53
+ # `settingsPanelDisabled` (boolean)
54
+
55
+ Indicates if the settings panel is not available
56
+
57
+ # `showExcludeZero` (object)
58
+
59
+ Properties of the `showExcludeZero` object:
60
+
61
+ ## `settings` (boolean)
62
+
63
+ Indicates if the item has to be displayed in the Settings Panel
64
+
65
+ ## `label` (string)
66
+
67
+ Indicates the label for the item that has to be displayed in the Settings Panel
68
+
69
+ # `showScorePointLabels` (object)
70
+
71
+ Properties of the `showScorePointLabels` object:
72
+
73
+ ## `settings` (boolean)
74
+
75
+ Indicates if the item has to be displayed in the Settings Panel
76
+
77
+ ## `label` (string)
78
+
79
+ Indicates the label for the item that has to be displayed in the Settings Panel
80
+
81
+ # `showDescription` (object)
82
+
83
+ Properties of the `showDescription` object:
84
+
85
+ ## `settings` (boolean)
86
+
87
+ Indicates if the item has to be displayed in the Settings Panel
88
+
89
+ ## `label` (string)
90
+
91
+ Indicates the label for the item that has to be displayed in the Settings Panel
92
+
93
+ # `showVisibleToStudent` (object)
94
+
95
+ Properties of the `showVisibleToStudent` object:
96
+
97
+ ## `settings` (boolean)
98
+
99
+ Indicates if the item has to be displayed in the Settings Panel
100
+
101
+ ## `label` (string)
102
+
103
+ Indicates the label for the item that has to be displayed in the Settings Panel
104
+
105
+ # `showHalfScoring` (object)
106
+
107
+ Properties of the `showHalfScoring` object:
108
+
109
+ ## `settings` (boolean)
110
+
111
+ Indicates if the item has to be displayed in the Settings Panel
112
+
113
+ ## `label` (string)
114
+
115
+ Indicates the label for the item that has to be displayed in the Settings Panel
116
+
117
+ # `spellCheck` (object)
118
+
119
+ Properties of the `spellCheck` object:
120
+
121
+ ## `settings` (boolean)
122
+
123
+ Indicates if the item has to be displayed in the Settings Panel
124
+
125
+ ## `label` (string)
126
+
127
+ Indicates the label for the item that has to be displayed in the Settings Panel
128
+
129
+ # `width` (string, required)
130
+
131
+ How large (in px) should multi-trait-rubric be
132
+
133
+ # `minNoOfTraits` (number)
134
+
135
+ Minimum number of traits
136
+
137
+ # `maxNoOfTraits` (number)
138
+
139
+ Maximum number of traits
140
+
141
+ # `minNoOfScales` (number)
142
+
143
+ Minimum number of scales
144
+
145
+ # `maxNoOfScales` (number)
146
+
147
+ Maximum number of scales
148
+
149
+ # `defaultTraitLabel` (string)
150
+
151
+ The default trait label for new created scales.
152
+ If it's not defined, it will default to the label of the first trait.
153
+
154
+ # `mathMlOptions` (object)
155
+
156
+ Properties of the `mathMlOptions` object:
157
+
158
+ ## `mmlOutput` (number)
159
+
160
+ Indicates if model should have mathML output instead of latex
161
+
162
+ ## `mmlEditing` (number)
163
+
164
+ Indicates if mathML that's already in model should be editable
165
+
166
+ ---
167
+
168
+ # Sub Schemas
169
+
170
+ The schema defines the following additional types:
171
+
172
+ ## `DialogContent` (object)
173
+
174
+ Properties of the `DialogContent` object:
175
+
176
+ ### `title` (string)
177
+
178
+ Dialog box title
179
+
180
+ ### `text` (string)
181
+
182
+ Dialog box text
183
+
184
+ ## `ConfigureProp` (object)
185
+
186
+ Properties of the `ConfigureProp` object:
187
+
188
+ ### `settings` (boolean)
189
+
190
+ Indicates if the item has to be displayed in the Settings Panel
191
+
192
+ ### `label` (string)
193
+
194
+ Indicates the label for the item that has to be displayed in the Settings Panel
195
+
196
+ ## `ConfigureMathMLProp` (object)
197
+
198
+ Properties of the `ConfigureMathMLProp` object:
199
+
200
+ ### `mmlOutput` (number)
201
+
202
+ Indicates if model should have mathML output instead of latex
203
+
204
+ ### `mmlEditing` (number)
205
+
206
+ Indicates if mathML that's already in model should be editable
@@ -0,0 +1,8 @@
1
+ const { model } = require('./generate');
2
+
3
+ module.exports = {
4
+ elements: {
5
+ 'multi-trait-rubric': '../..',
6
+ },
7
+ models: [model('1', 'multi-trait-rubric')],
8
+ };