@pie-element/multi-trait-rubric 8.2.2-beta.6 → 8.2.2-beta.8

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.
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filteredDefaultPlugins = exports.addOrRemoveScaleColumn = void 0;
7
+ var _editableHtmlTipTap = require("@pie-lib/editable-html-tip-tap");
8
+ var _modals = require("./modals");
9
+ const filteredDefaultPlugins = exports.filteredDefaultPlugins = (_editableHtmlTipTap.DEFAULT_PLUGINS || []).filter(p => p !== 'table' && p !== 'bulleted-list' && p !== 'numbered-list');
10
+ const addOrRemoveScaleColumn = (scales, excludeZeroType) => {
11
+ if (!scales || !scales.length) {
12
+ return [];
13
+ }
14
+ return scales.reduce((acc, scale) => {
15
+ let {
16
+ scorePointsLabels,
17
+ traits
18
+ } = scale || {};
19
+ if (scorePointsLabels.length < 1) {
20
+ return acc;
21
+ }
22
+ switch (excludeZeroType) {
23
+ case _modals.excludeZeroTypes.remove0:
24
+ {
25
+ // removes column 0
26
+ scorePointsLabels = scorePointsLabels.slice(1);
27
+ traits = traits.map(({
28
+ scorePointsDescriptors,
29
+ ...trait
30
+ }) => ({
31
+ ...trait,
32
+ scorePointsDescriptors: scorePointsDescriptors.slice(1)
33
+ }));
34
+ break;
35
+ }
36
+ case _modals.excludeZeroTypes.add0:
37
+ {
38
+ // adds empty column at start
39
+ scorePointsLabels = ['', ...scorePointsLabels];
40
+ traits = traits.map(({
41
+ scorePointsDescriptors,
42
+ ...trait
43
+ }) => ({
44
+ ...trait,
45
+ scorePointsDescriptors: ['', ...scorePointsDescriptors]
46
+ }));
47
+ break;
48
+ }
49
+ case _modals.excludeZeroTypes.shiftLeft:
50
+ {
51
+ // removes last column
52
+ scorePointsLabels = scorePointsLabels.slice(0, -1);
53
+ traits = traits.map(({
54
+ scorePointsDescriptors,
55
+ ...trait
56
+ }) => ({
57
+ ...trait,
58
+ scorePointsDescriptors: scorePointsDescriptors.slice(0, -1)
59
+ }));
60
+ break;
61
+ }
62
+ case _modals.excludeZeroTypes.shiftRight:
63
+ {
64
+ // adds empty column at end
65
+ scorePointsLabels = [...scorePointsLabels, ''];
66
+ traits = traits.map(({
67
+ scorePointsDescriptors,
68
+ ...trait
69
+ }) => ({
70
+ ...trait,
71
+ scorePointsDescriptors: [...scorePointsDescriptors, '']
72
+ }));
73
+ break;
74
+ }
75
+ default:
76
+ break;
77
+ }
78
+ acc.push({
79
+ ...scale,
80
+ scorePointsLabels,
81
+ traits
82
+ });
83
+ return acc;
84
+ }, []);
85
+ };
86
+ exports.addOrRemoveScaleColumn = addOrRemoveScaleColumn;
87
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["_editableHtmlTipTap","require","_modals","filteredDefaultPlugins","exports","DEFAULT_PLUGINS","filter","p","addOrRemoveScaleColumn","scales","excludeZeroType","length","reduce","acc","scale","scorePointsLabels","traits","excludeZeroTypes","remove0","slice","map","scorePointsDescriptors","trait","add0","shiftLeft","shiftRight","push"],"sources":["../src/utils.js"],"sourcesContent":["import { DEFAULT_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { excludeZeroTypes } from './modals';\n\nexport const filteredDefaultPlugins = (DEFAULT_PLUGINS || []).filter(\n (p) => p !== 'table' && p !== 'bulleted-list' && p !== 'numbered-list',\n);\n\nexport const addOrRemoveScaleColumn = (scales, excludeZeroType) => {\n if (!scales || !scales.length) {\n return [];\n }\n\n return scales.reduce((acc, scale) => {\n let { scorePointsLabels, traits } = scale || {};\n\n if (scorePointsLabels.length < 1) {\n return acc;\n }\n\n switch (excludeZeroType) {\n case excludeZeroTypes.remove0: {\n // removes column 0\n scorePointsLabels = scorePointsLabels.slice(1);\n traits = traits.map(({ scorePointsDescriptors, ...trait }) => ({\n ...trait,\n scorePointsDescriptors: scorePointsDescriptors.slice(1),\n }));\n\n break;\n }\n\n case excludeZeroTypes.add0: {\n // adds empty column at start\n scorePointsLabels = ['', ...scorePointsLabels];\n traits = traits.map(({ scorePointsDescriptors, ...trait }) => ({\n ...trait,\n scorePointsDescriptors: ['', ...scorePointsDescriptors],\n }));\n\n break;\n }\n\n case excludeZeroTypes.shiftLeft: {\n // removes last column\n scorePointsLabels = scorePointsLabels.slice(0, -1);\n traits = traits.map(({ scorePointsDescriptors, ...trait }) => ({\n ...trait,\n scorePointsDescriptors: scorePointsDescriptors.slice(0, -1),\n }));\n\n break;\n }\n\n case excludeZeroTypes.shiftRight: {\n // adds empty column at end\n scorePointsLabels = [...scorePointsLabels, ''];\n traits = traits.map(({ scorePointsDescriptors, ...trait }) => ({\n ...trait,\n scorePointsDescriptors: [...scorePointsDescriptors, ''],\n }));\n\n break;\n }\n\n default:\n break;\n }\n\n acc.push({ ...scale, scorePointsLabels, traits });\n\n return acc;\n }, []);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEO,MAAME,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAACE,mCAAe,IAAI,EAAE,EAAEC,MAAM,CACjEC,CAAC,IAAKA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,eAAe,IAAIA,CAAC,KAAK,eACzD,CAAC;AAEM,MAAMC,sBAAsB,GAAGA,CAACC,MAAM,EAAEC,eAAe,KAAK;EACjE,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,MAAM,EAAE;IAC7B,OAAO,EAAE;EACX;EAEA,OAAOF,MAAM,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;IACnC,IAAI;MAAEC,iBAAiB;MAAEC;IAAO,CAAC,GAAGF,KAAK,IAAI,CAAC,CAAC;IAE/C,IAAIC,iBAAiB,CAACJ,MAAM,GAAG,CAAC,EAAE;MAChC,OAAOE,GAAG;IACZ;IAEA,QAA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,EAAE,CAAC,GAAGA,sBAAsB,EAAE,EAAE;UACxD,CAAC,CAAC,CAAC;UAEH;QACF;MAEA;QACE;IACJ;IAEAR,GAAG,CAACa,IAAI,CAAC;MAAE,GAAGZ,KAAK;MAAEC,iBAAiB;MAAEC;IAAO,CAAC,CAAC;IAEjD,OAAOH,GAAG;EACZ,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAACT,OAAA,CAAAI,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multi-trait-rubric-configure",
3
- "version": "7.4.0-beta.12",
3
+ "version": "7.4.0-beta.14",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -11,9 +11,9 @@
11
11
  "@mui/icons-material": "^7.3.4",
12
12
  "@mui/material": "^7.3.4",
13
13
  "@pie-framework/pie-configure-events": "^1.3.0",
14
- "@pie-lib/config-ui": "13.0.22-beta.1",
14
+ "@pie-lib/config-ui": "13.0.22-beta.3",
15
15
  "@pie-lib/drag": "4.0.6",
16
- "@pie-lib/editable-html-tip-tap": "2.1.20-beta.1",
16
+ "@pie-lib/editable-html-tip-tap": "2.1.20-beta.3",
17
17
  "@pie-lib/render-ui": "6.1.3",
18
18
  "debug": "^4.1.1",
19
19
  "lodash-es": "^4.17.23",
@@ -3,6 +3,14 @@
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
+ # [6.3.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/multi-trait-rubric-controller@6.3.0-beta.13...@pie-element/multi-trait-rubric-controller@6.3.0-beta.14) (2026-09-29)
7
+
8
+ **Note:** Version bump only for package @pie-element/multi-trait-rubric-controller
9
+
10
+ # [6.3.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/multi-trait-rubric-controller@6.3.0-beta.12...@pie-element/multi-trait-rubric-controller@6.3.0-beta.13) (2026-09-24)
11
+
12
+ **Note:** Version bump only for package @pie-element/multi-trait-rubric-controller
13
+
6
14
  # [6.3.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/multi-trait-rubric-controller@6.3.0-beta.11...@pie-element/multi-trait-rubric-controller@6.3.0-beta.12) (2026-09-24)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/multi-trait-rubric-controller
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = {
8
+ addScaleEnabled: true,
9
+ description: false,
10
+ excludeZero: false,
11
+ halfScoring: false,
12
+ maxPointsEnabled: true,
13
+ pointLabels: true,
14
+ scales: [],
15
+ standards: false,
16
+ visibleToStudent: true
17
+ };
18
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":["addScaleEnabled","description","excludeZero","halfScoring","maxPointsEnabled","pointLabels","scales","standards","visibleToStudent"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n addScaleEnabled: true,\n description: false,\n excludeZero: false,\n halfScoring: false,\n maxPointsEnabled: true,\n pointLabels: true,\n scales: [],\n standards: false,\n visibleToStudent: true,\n};\n"],"mappings":";;;;;;iCAAe;EACbA,eAAe,EAAE,IAAI;EACrBC,WAAW,EAAE,KAAK;EAClBC,WAAW,EAAE,KAAK;EAClBC,WAAW,EAAE,KAAK;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE,EAAE;EACVC,SAAS,EAAE,KAAK;EAChBC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createCorrectResponseSession = void 0;
8
+ exports.createDefaultModel = createDefaultModel;
9
+ exports.getScore = void 0;
10
+ exports.model = model;
11
+ exports.normalize = void 0;
12
+ exports.outcome = outcome;
13
+ exports.validate = void 0;
14
+ var _defaults = _interopRequireDefault(require("./defaults"));
15
+ var _utils = require("./utils");
16
+ function createDefaultModel(model = {}) {
17
+ return new Promise(resolve => resolve({
18
+ ..._defaults.default,
19
+ ...model
20
+ }));
21
+ }
22
+ const normalize = question => ({
23
+ ..._defaults.default,
24
+ ...question
25
+ });
26
+
27
+ /**
28
+ *
29
+ * @param {*} question
30
+ * @param {*} session
31
+ * @param {*} env
32
+ */
33
+ exports.normalize = normalize;
34
+ async function model(question, session, env) {
35
+ const normalizedQuestion = normalize(question);
36
+ if (!env.role || env.role === 'student') {
37
+ normalizedQuestion.visible = normalizedQuestion.visibleToStudent;
38
+ } else {
39
+ normalizedQuestion.visible = true;
40
+ }
41
+
42
+ // todo update pie-ui instead of parsing this here:
43
+ const {
44
+ scales,
45
+ excludeZero
46
+ } = normalizedQuestion || {};
47
+ const parsedScales = (scales || []).map(scale => ({
48
+ ...scale,
49
+ excludeZero
50
+ }));
51
+ return {
52
+ ...normalizedQuestion,
53
+ scales: parsedScales
54
+ };
55
+ }
56
+ const getScore = () => 0;
57
+
58
+ /**
59
+ * @param {Object} model - the main model
60
+ * @param {*} session
61
+ * @param {Object} env
62
+ */
63
+ exports.getScore = getScore;
64
+ function outcome() {
65
+ return new Promise(resolve => resolve({
66
+ score: 0,
67
+ empty: true
68
+ }));
69
+ }
70
+ const createCorrectResponseSession = (question, env) => {
71
+ return new Promise(resolve => {
72
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
73
+ resolve({
74
+ id: '1'
75
+ });
76
+ } else {
77
+ resolve(null);
78
+ }
79
+ });
80
+ };
81
+
82
+ // IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateMultiTraitRubric function!“.
83
+ exports.createCorrectResponseSession = createCorrectResponseSession;
84
+ const validate = (model, config) => {
85
+ const {
86
+ scales,
87
+ description = false,
88
+ pointLabels = false
89
+ } = model;
90
+ const errors = {};
91
+ const traitsErrors = {};
92
+ const scorePointsErrors = {};
93
+ (scales || []).forEach((scale, scaleIndex) => {
94
+ const {
95
+ traits = []
96
+ } = scale;
97
+ const {
98
+ scorePointsLabels = []
99
+ } = scale;
100
+ const scaleErrors = {};
101
+ const scorePointsLabelsErrors = {};
102
+ if (pointLabels) {
103
+ scorePointsLabels.forEach((scorePointLabel, scoreIndex) => {
104
+ if (!scorePointLabel || scorePointLabel === '<div></div>') {
105
+ scorePointsLabelsErrors[scoreIndex] = 'Points labels should not be empty.';
106
+ } else {
107
+ const identicalScorePointLabel = scorePointsLabels.slice(scoreIndex + 1).some(s => (0, _utils.markupToText)(s) === (0, _utils.markupToText)(scorePointLabel));
108
+ if (identicalScorePointLabel) {
109
+ scorePointsLabelsErrors[scoreIndex] = 'Points labels should be unique.';
110
+ }
111
+ }
112
+ });
113
+ }
114
+ if (Object.keys(scorePointsLabelsErrors).length > 0) {
115
+ scorePointsErrors[scaleIndex] = scorePointsLabelsErrors;
116
+ }
117
+ traits.forEach((trait, traitIndex) => {
118
+ if (!trait.name || trait.name === '<div></div>') {
119
+ scaleErrors[traitIndex] = {
120
+ name: 'Trait names should not be empty.'
121
+ };
122
+ } else {
123
+ const identicalTraitName = traits.slice(traitIndex + 1).some(t => (0, _utils.markupToText)(t.name) === (0, _utils.markupToText)(trait.name));
124
+ if (identicalTraitName) {
125
+ scaleErrors[traitIndex] = {
126
+ name: 'Trait names should be unique.'
127
+ };
128
+ }
129
+ }
130
+ if (description && (!trait.description || trait.description === '<div></div>')) {
131
+ scaleErrors[traitIndex] = {
132
+ ...scaleErrors[traitIndex],
133
+ description: 'Trait description should not be empty'
134
+ };
135
+ } else {
136
+ const identicalTraitDescr = traits.slice(traitIndex + 1).some(t => (0, _utils.markupToText)(t.description) === (0, _utils.markupToText)(trait.description));
137
+ if (description && identicalTraitDescr) {
138
+ scaleErrors[traitIndex] = {
139
+ ...scaleErrors[traitIndex],
140
+ description: 'Trait descriptions should be unique.'
141
+ };
142
+ }
143
+ }
144
+ });
145
+ if (Object.keys(scaleErrors).length > 0) {
146
+ traitsErrors[scaleIndex] = scaleErrors;
147
+ }
148
+ });
149
+ if (Object.keys(traitsErrors).length > 0) {
150
+ errors.traitsErrors = traitsErrors;
151
+ }
152
+ if (Object.keys(scorePointsErrors).length > 0) {
153
+ errors.scorePointsErrors = scorePointsErrors;
154
+ }
155
+ return errors;
156
+ };
157
+ exports.validate = validate;
158
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","_utils","createDefaultModel","model","Promise","resolve","defaults","normalize","question","exports","session","env","normalizedQuestion","role","visible","visibleToStudent","scales","excludeZero","parsedScales","map","scale","getScore","outcome","score","empty","createCorrectResponseSession","mode","id","validate","config","description","pointLabels","errors","traitsErrors","scorePointsErrors","forEach","scaleIndex","traits","scorePointsLabels","scaleErrors","scorePointsLabelsErrors","scorePointLabel","scoreIndex","identicalScorePointLabel","slice","some","s","markupToText","Object","keys","length","trait","traitIndex","name","identicalTraitName","t","identicalTraitDescr"],"sources":["../src/index.js"],"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// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateMultiTraitRubric function!“.\nexport const validate = (model, config) => {\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\n .slice(scoreIndex + 1)\n .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 } else {\n const identicalTraitName = traits\n .slice(traitIndex + 1)\n .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 } else {\n const identicalTraitDescr = traits\n .slice(traitIndex + 1)\n .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 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"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,kBAAkBA,CAACC,KAAK,GAAG,CAAC,CAAC,EAAE;EAC7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAAC;IAAE,GAAGC,iBAAQ;IAAE,GAAGH;EAAM,CAAC,CAAC,CAAC;AACrE;AAEO,MAAMI,SAAS,GAAIC,QAAQ,KAAM;EAAE,GAAGF,iBAAQ;EAAE,GAAGE;AAAS,CAAC,CAAC;;AAErE;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAF,SAAA,GAAAA,SAAA;AAMO,eAAeJ,KAAKA,CAACK,QAAQ,EAAEE,OAAO,EAAEC,GAAG,EAAE;EAClD,MAAMC,kBAAkB,GAAGL,SAAS,CAACC,QAAQ,CAAC;EAE9C,IAAI,CAACG,GAAG,CAACE,IAAI,IAAIF,GAAG,CAACE,IAAI,KAAK,SAAS,EAAE;IACvCD,kBAAkB,CAACE,OAAO,GAAGF,kBAAkB,CAACG,gBAAgB;EAClE,CAAC,MAAM;IACLH,kBAAkB,CAACE,OAAO,GAAG,IAAI;EACnC;;EAEA;EACA,MAAM;IAAEE,MAAM;IAAEC;EAAY,CAAC,GAAGL,kBAAkB,IAAI,CAAC,CAAC;EACxD,MAAMM,YAAY,GAAG,CAACF,MAAM,IAAI,EAAE,EAAEG,GAAG,CAAEC,KAAK,KAA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11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.markupToText = void 0;
7
+ const markupToText = s => {
8
+ return (s || '').replace(/(<([^>]+)>)/ig, '');
9
+ };
10
+ exports.markupToText = markupToText;
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["markupToText","s","replace","exports"],"sources":["../src/utils.js"],"sourcesContent":["export const markupToText = (s) => {\n return (s || '').replace(/(<([^>]+)>)/ig, '');\n};\n"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAIC,CAAC,IAAK;EAC/B,OAAO,CAACA,CAAC,IAAI,EAAE,EAAEC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;AACjD,CAAC;AAACC,OAAA,CAAAH,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/multi-trait-rubric-controller",
3
3
  "private": true,
4
- "version": "6.3.0-beta.12",
4
+ "version": "6.3.0-beta.14",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
package/lib/index.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _client = require("react-dom/client");
11
+ var _piePlayerEvents = require("@pie-framework/pie-player-events");
12
+ var _main = _interopRequireDefault(require("./main"));
13
+ var _mathRendering = require("@pie-lib/math-rendering");
14
+ class MultiTraitRubric extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+ // React commits asynchronously, so a queueMicrotask(renderMath) can run before
18
+ // the LaTeX spans are in the DOM and leave raw LaTeX on first render — this is
19
+ // especially visible when this element is mounted inside complex-rubric, which
20
+ // swaps its innerHTML and re-defines the inner element. Observing the DOM and
21
+ // typesetting after each commit keeps math in sync regardless of timing.
22
+ (0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
23
+ if (this._mathRenderPending) return;
24
+ this._mathRenderPending = true;
25
+ requestAnimationFrame(() => {
26
+ if (this._mathObserver) {
27
+ this._mathObserver.disconnect();
28
+ }
29
+ (0, _mathRendering.renderMath)(this);
30
+ this._mathRenderPending = false;
31
+ setTimeout(() => {
32
+ if (this._mathObserver) {
33
+ this._mathObserver.observe(this, {
34
+ childList: true,
35
+ subtree: true
36
+ });
37
+ }
38
+ }, 50);
39
+ });
40
+ });
41
+ this._model = {};
42
+ this._session = null;
43
+ this._root = null;
44
+ this._mathObserver = null;
45
+ this._mathRenderPending = false;
46
+ }
47
+ _initMathObserver() {
48
+ if (this._mathObserver) return;
49
+ this._mathObserver = new MutationObserver(this._scheduleMathRender);
50
+ this._mathObserver.observe(this, {
51
+ childList: true,
52
+ subtree: true
53
+ });
54
+ }
55
+ _disconnectMathObserver() {
56
+ if (this._mathObserver) {
57
+ this._mathObserver.disconnect();
58
+ this._mathObserver = null;
59
+ }
60
+ }
61
+ set model(s) {
62
+ this._model = s;
63
+ this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this._session, !!this._model));
64
+ this._render();
65
+ }
66
+ set session(s) {
67
+ this._session = s;
68
+ }
69
+ get session() {
70
+ return this._session;
71
+ }
72
+ connectedCallback() {
73
+ this._initMathObserver();
74
+ this._render();
75
+ }
76
+ _render() {
77
+ this._initMathObserver();
78
+ const el = /*#__PURE__*/_react.default.createElement(_main.default, {
79
+ model: this._model,
80
+ session: this._session
81
+ });
82
+ if (!this._root) {
83
+ this._root = (0, _client.createRoot)(this);
84
+ }
85
+ this._root.render(el);
86
+ }
87
+ disconnectedCallback() {
88
+ this._disconnectMathObserver();
89
+ if (this._root) {
90
+ this._root.unmount();
91
+ this._root = null;
92
+ }
93
+ }
94
+ }
95
+ exports.default = MultiTraitRubric;
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_piePlayerEvents","_main","_mathRendering","MultiTraitRubric","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","_model","_session","_root","_initMathObserver","MutationObserver","_scheduleMathRender","_disconnectMathObserver","model","s","dispatchEvent","ModelSetEvent","tagName","toLowerCase","_render","session","connectedCallback","el","React","createElement","Main","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ModelSetEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nexport default class MultiTraitRubric extends HTMLElement {\n constructor() {\n super();\n this._model = {};\n this._session = null;\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n }\n\n // React commits asynchronously, so a queueMicrotask(renderMath) can run before\n // the LaTeX spans are in the DOM and leave raw LaTeX on first render — this is\n // especially visible when this element is mounted inside complex-rubric, which\n // swaps its innerHTML and re-defines the inner element. Observing the DOM and\n // typesetting after each commit keeps math in sync regardless of timing.\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n set model(s) {\n this._model = s;\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this._session, !!this._model));\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n }\n\n get session() {\n return this._session;\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._render();\n }\n\n _render() {\n this._initMathObserver();\n\n const el = React.createElement(Main, { model: this._model, session: this._session });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEe,MAAMK,gBAAgB,SAASC,WAAW,CAAC;EACxDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAQT;IACA;IACA;IACA;IACA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,+BACsB,MAAM;MAC1B,IAAI,IAAI,CAACC,kBAAkB,EAAE;MAC7B,IAAI,CAACA,kBAAkB,GAAG,IAAI;MAE9BC,qBAAqB,CAAC,MAAM;QAC1B,IAAI,IAAI,CAACC,aAAa,EAAE;UACtB,IAAI,CAACA,aAAa,CAACC,UAAU,CAAC,CAAC;QACjC;QACA,IAAAC,yBAAU,EAAC,IAAI,CAAC;QAChB,IAAI,CAACJ,kBAAkB,GAAG,KAAK;QAC/BK,UAAU,CAAC,MAAM;UACf,IAAI,IAAI,CAACH,aAAa,EAAE;YACtB,IAAI,CAACA,aAAa,CAACI,OAAO,CAAC,IAAI,EAAE;cAAEC,SAAS,EAAE,IAAI;cAAEC,OAAO,EAAE;YAAK,CAAC,CAAC;UACtE;QACF,CAAC,EAAE,EAAE,CAAC;MACR,CAAC,CAAC;IACJ,CAAC;IA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AC;IAExB,MAAMa,EAAE,gBAAGC,cAAK,CAACC,aAAa,CAACC,aAAI,EAAE;MAAEZ,KAAK,EAAE,IAAI,CAACP,MAAM;MAAEc,OAAO,EAAE,IAAI,CAACb;IAAS,CAAC,CAAC;IAEpF,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;MACf,IAAI,CAACA,KAAK,GAAG,IAAAkB,kBAAU,EAAC,IAAI,CAAC;IAC/B;IACA,IAAI,CAAClB,KAAK,CAACmB,MAAM,CAACL,EAAE,CAAC;EACvB;EAEAM,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAAChB,uBAAuB,CAAC,CAAC;IAC9B,IAAI,IAAI,CAACJ,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACqB,OAAO,CAAC,CAAC;MACpB,IAAI,CAACrB,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAACsB,OAAA,CAAAlC,OAAA,GAAAJ,gBAAA","ignoreList":[]}
package/lib/main.js ADDED
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _scale = _interopRequireDefault(require("./scale"));
11
+ var _Link = _interopRequireDefault(require("@mui/material/Link"));
12
+ var _Collapse = _interopRequireDefault(require("@mui/material/Collapse"));
13
+ var _renderUi = require("@pie-lib/render-ui");
14
+ class Main extends _react.default.Component {
15
+ constructor(props) {
16
+ super(props);
17
+ this.state = {
18
+ rubricOpen: false,
19
+ linkPrefix: 'Show'
20
+ };
21
+ this.toggleRubric = this.toggleRubric.bind(this);
22
+ }
23
+ toggleRubric() {
24
+ this.setState({
25
+ rubricOpen: !this.state.rubricOpen
26
+ });
27
+ this.setState({
28
+ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide'
29
+ });
30
+ }
31
+ render() {
32
+ const {
33
+ model
34
+ } = this.props;
35
+ let {
36
+ animationsDisabled
37
+ } = this.props;
38
+ const {
39
+ extraCSSRules,
40
+ halfScoring,
41
+ scales,
42
+ visible,
43
+ pointLabels,
44
+ description,
45
+ standards,
46
+ arrowsDisabled
47
+ } = model || {};
48
+ animationsDisabled = animationsDisabled || model.animationsDisabled;
49
+ if (!scales || !visible) {
50
+ return null;
51
+ }
52
+ const rubricItem = /*#__PURE__*/_react.default.createElement(_renderUi.UiLayout, {
53
+ extraCSSRules: extraCSSRules,
54
+ style: {
55
+ fontFamily: 'Cerebri Sans',
56
+ color: _renderUi.color.text(),
57
+ backgroundColor: _renderUi.color.background()
58
+ }
59
+ }, halfScoring ? /*#__PURE__*/_react.default.createElement("div", {
60
+ style: {
61
+ marginBottom: '16px'
62
+ }
63
+ }, "* Half-point or in-between scores are permitted under this rubric.") : null, scales.map((scale, scaleIndex) => /*#__PURE__*/_react.default.createElement(_scale.default, {
64
+ key: `scale_${scaleIndex}`,
65
+ scale: scale,
66
+ scaleIndex: scaleIndex,
67
+ showPointsLabels: pointLabels,
68
+ showDescription: description,
69
+ showStandards: standards,
70
+ arrowsDisabled: arrowsDisabled
71
+ })));
72
+ if (animationsDisabled) {
73
+ return rubricItem;
74
+ }
75
+ return /*#__PURE__*/_react.default.createElement(_renderUi.UiLayout, {
76
+ extraCSSRules: extraCSSRules,
77
+ style: {
78
+ color: _renderUi.color.text(),
79
+ backgroundColor: _renderUi.color.background()
80
+ }
81
+ }, /*#__PURE__*/_react.default.createElement(_Link.default, {
82
+ style: {
83
+ backgroundColor: _renderUi.color.background()
84
+ },
85
+ href: this.dudUrl,
86
+ onClick: this.toggleRubric
87
+ }, this.state.linkPrefix, " Rubric"), /*#__PURE__*/_react.default.createElement(_Collapse.default, {
88
+ style: {
89
+ marginTop: '16px'
90
+ },
91
+ in: this.state.rubricOpen,
92
+ timeout: {
93
+ enter: 225,
94
+ exit: 195
95
+ }
96
+ }, rubricItem));
97
+ }
98
+ }
99
+ Main.propTypes = {
100
+ model: _propTypes.default.shape({
101
+ halfScoring: _propTypes.default.bool,
102
+ scales: _propTypes.default.arrayOf(_propTypes.default.shape({
103
+ excludeZero: _propTypes.default.bool,
104
+ maxPoints: _propTypes.default.number,
105
+ scorePointsLabels: _propTypes.default.arrayOf(_propTypes.default.string),
106
+ traitLabel: _propTypes.default.string,
107
+ traits: _propTypes.default.arrayOf(_propTypes.default.shape({
108
+ name: _propTypes.default.string,
109
+ description: _propTypes.default.string,
110
+ scorePointsDescriptors: _propTypes.default.arrayOf(_propTypes.default.string),
111
+ standards: _propTypes.default.arrayOf(_propTypes.default.string)
112
+ }))
113
+ })),
114
+ visible: _propTypes.default.bool,
115
+ pointLabels: _propTypes.default.bool,
116
+ description: _propTypes.default.bool,
117
+ standards: _propTypes.default.bool,
118
+ animationsDisabled: _propTypes.default.bool
119
+ }),
120
+ animationsDisabled: _propTypes.default.bool
121
+ };
122
+ var _default = exports.default = Main;
123
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_scale","_Link","_Collapse","_renderUi","Main","React","Component","constructor","props","state","rubricOpen","linkPrefix","toggleRubric","bind","setState","render","model","animationsDisabled","extraCSSRules","halfScoring","scales","visible","pointLabels","description","standards","arrowsDisabled","rubricItem","default","createElement","UiLayout","style","fontFamily","color","text","backgroundColor","background","marginBottom","map","scale","scaleIndex","key","showPointsLabels","showDescription","showStandards","href","dudUrl","onClick","marginTop","in","timeout","enter","exit","propTypes","PropTypes","shape","bool","arrayOf","excludeZero","maxPoints","number","scorePointsLabels","string","traitLabel","traits","name","scorePointsDescriptors","_default","exports"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport Scale from './scale';\nimport Link from '@mui/material/Link';\nimport Collapse from '@mui/material/Collapse';\nimport { color, UiLayout } from '@pie-lib/render-ui';\n\nclass Main extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n rubricOpen: false,\n linkPrefix: 'Show',\n };\n this.toggleRubric = this.toggleRubric.bind(this);\n }\n\n toggleRubric() {\n this.setState({ rubricOpen: !this.state.rubricOpen });\n this.setState({ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide' });\n }\n\n render() {\n const { model } = this.props;\n let { animationsDisabled } = this.props;\n const { extraCSSRules, halfScoring, scales, visible, pointLabels, description, standards, arrowsDisabled } =\n model || {};\n animationsDisabled = animationsDisabled || model.animationsDisabled;\n\n if (!scales || !visible) {\n return null;\n }\n\n const rubricItem = (\n <UiLayout\n extraCSSRules={extraCSSRules}\n style={{ fontFamily: 'Cerebri Sans', color: color.text(), backgroundColor: color.background() }}\n >\n {halfScoring ? (\n <div style={{ marginBottom: '16px' }}>* Half-point or in-between scores are permitted under this rubric.</div>\n ) : null}\n\n {scales.map((scale, scaleIndex) => (\n <Scale\n key={`scale_${scaleIndex}`}\n scale={scale}\n scaleIndex={scaleIndex}\n showPointsLabels={pointLabels}\n showDescription={description}\n showStandards={standards}\n arrowsDisabled={arrowsDisabled}\n />\n ))}\n </UiLayout>\n );\n\n if (animationsDisabled) {\n return rubricItem;\n }\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} style={{ color: color.text(), backgroundColor: color.background() }}>\n <Link style={{ backgroundColor: color.background() }} href={this.dudUrl} onClick={this.toggleRubric}>\n {this.state.linkPrefix} Rubric\n </Link>\n <Collapse style={{ marginTop: '16px' }} in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>\n {rubricItem}\n </Collapse>\n </UiLayout>\n );\n }\n}\n\nMain.propTypes = {\n model: PropTypes.shape({\n halfScoring: PropTypes.bool,\n scales: PropTypes.arrayOf(\n PropTypes.shape({\n excludeZero: PropTypes.bool,\n maxPoints: PropTypes.number,\n scorePointsLabels: PropTypes.arrayOf(PropTypes.string),\n traitLabel: PropTypes.string,\n traits: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string,\n description: PropTypes.string,\n scorePointsDescriptors: PropTypes.arrayOf(PropTypes.string),\n standards: PropTypes.arrayOf(PropTypes.string),\n }),\n ),\n }),\n ),\n visible: PropTypes.bool,\n pointLabels: PropTypes.bool,\n description: PropTypes.bool,\n standards: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n }),\n animationsDisabled: PropTypes.bool,\n};\n\nexport default Main;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,MAAMM,IAAI,SAASC,cAAK,CAACC,SAAS,CAAC;EACjCC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MACXC,UAAU,EAAE,KAAK;MACjBC,UAAU,EAAE;IACd,CAAC;IACD,IAAI,CAACC,YAAY,GAAG,IAAI,CAACA,YAAY,CAACC,IAAI,CAAC,IAAI,CAAC;EAClD;EAEAD,YAAYA,CAAA,EAAG;IACb,IAAI,CAACE,QAAQ,CAAC;MAAEJ,UAAU,EAAE,CAAC,IAAI,CAACD,KAAK,CAACC;IAAW,CAAC,CAAC;IACrD,IAAI,CAACI,QAAQ,CAAC;MAAEH,UAAU,EAAE,IAAI,CAACF,KAAK,CAACC,UAAU,GAAG,MAAM,GAAG;IAAO,CAAC,CAAC;EACxE;EAEAK,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC;IAAM,CAAC,GAAG,IAAI,CAACR,KAAK;IAC5B,IAAI;MAAES;IAAmB,CAAC,GAAG,IAAI,CAACT,KAAK;IACvC,MAAM;MAAEU,aAAa;MAAEC,WAAW;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