@pie-element/matrix 4.1.2-next.5 → 4.1.3
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.json +1 -0
- package/CHANGELOG.md +1421 -0
- package/LICENSE.md +5 -0
- package/README.md +59 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +1347 -0
- package/configure/lib/HeaderCommon.js +28 -0
- package/configure/lib/HeaderCommon.js.map +1 -0
- package/configure/lib/Main.js +179 -0
- package/configure/lib/Main.js.map +1 -0
- package/configure/lib/MatrixColumnsSizeHeaderInput.js +56 -0
- package/configure/lib/MatrixColumnsSizeHeaderInput.js.map +1 -0
- package/configure/lib/MatrixLabelEditableButton.js +224 -0
- package/configure/lib/MatrixLabelEditableButton.js.map +1 -0
- package/configure/lib/MatrixLabelTypeHeaderInput.js +98 -0
- package/configure/lib/MatrixLabelTypeHeaderInput.js.map +1 -0
- package/configure/lib/MatrixRowsSizeHeaderInput.js +56 -0
- package/configure/lib/MatrixRowsSizeHeaderInput.js.map +1 -0
- package/configure/lib/MatrixValues.js +217 -0
- package/configure/lib/MatrixValues.js.map +1 -0
- package/configure/lib/NumberInput.js +77 -0
- package/configure/lib/NumberInput.js.map +1 -0
- package/configure/lib/columnLabelsGenerator.js +49 -0
- package/configure/lib/columnLabelsGenerator.js.map +1 -0
- package/configure/lib/defaults.js +86 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +98 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/isNumeric.js +11 -0
- package/configure/lib/isNumeric.js.map +1 -0
- package/configure/lib/matrixEntities.js +16 -0
- package/configure/lib/matrixEntities.js.map +1 -0
- package/configure/package.json +28 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +88 -0
- package/controller/lib/defaults.js +17 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +96 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +17 -0
- package/docs/config-schema.json +1475 -0
- package/docs/config-schema.json.md +1093 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +9 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +1 -0
- package/docs/pie-schema.json.md +1 -0
- package/lib/ChoiceInput.js +59 -0
- package/lib/ChoiceInput.js.map +1 -0
- package/lib/Main.js +42 -0
- package/lib/Main.js.map +1 -0
- package/lib/Matrix.js +104 -0
- package/lib/Matrix.js.map +1 -0
- package/lib/index.js +80 -0
- package/lib/index.js.map +1 -0
- package/lib/session-updater.js +10 -0
- package/lib/session-updater.js.map +1 -0
- package/package.json +19 -83
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/HeaderCommon.d.ts +0 -12
- package/dist/author/HeaderCommon.js +0 -20
- package/dist/author/Main.d.ts +0 -27
- package/dist/author/Main.js +0 -134
- package/dist/author/MatrixColumnsSizeHeaderInput.d.ts +0 -21
- package/dist/author/MatrixColumnsSizeHeaderInput.js +0 -39
- package/dist/author/MatrixLabelEditableButton.d.ts +0 -27
- package/dist/author/MatrixLabelEditableButton.js +0 -191
- package/dist/author/MatrixLabelTypeHeaderInput.d.ts +0 -21
- package/dist/author/MatrixLabelTypeHeaderInput.js +0 -96
- package/dist/author/MatrixRowsSizeHeaderInput.d.ts +0 -21
- package/dist/author/MatrixRowsSizeHeaderInput.js +0 -39
- package/dist/author/MatrixValues.d.ts +0 -29
- package/dist/author/MatrixValues.js +0 -156
- package/dist/author/NumberInput.d.ts +0 -20
- package/dist/author/NumberInput.js +0 -61
- package/dist/author/columnLabelsGenerator.d.ts +0 -11
- package/dist/author/columnLabelsGenerator.js +0 -101
- package/dist/author/defaults.d.ts +0 -88
- package/dist/author/defaults.js +0 -56
- package/dist/author/index.d.ts +0 -31
- package/dist/author/index.js +0 -66
- package/dist/author/isNumeric.d.ts +0 -10
- package/dist/author/isNumeric.js +0 -4
- package/dist/author/matrixEntities.d.ts +0 -17
- package/dist/author/matrixEntities.js +0 -12
- package/dist/browser/Radio-1GgjpmF9.js +0 -10145
- package/dist/browser/Radio-1GgjpmF9.js.map +0 -1
- package/dist/browser/author/index.js +0 -45674
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -60
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -205
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-BjoC1dWE.js +0 -96
- package/dist/browser/dist-BjoC1dWE.js.map +0 -1
- package/dist/browser/matrix.css +0 -2
- package/dist/controller/defaults.d.ts +0 -19
- package/dist/controller/defaults.js +0 -17
- package/dist/controller/index.d.ts +0 -19
- package/dist/controller/index.js +0 -46
- package/dist/delivery/ChoiceInput.d.ts +0 -25
- package/dist/delivery/ChoiceInput.js +0 -36
- package/dist/delivery/Main.d.ts +0 -23
- package/dist/delivery/Main.js +0 -37
- package/dist/delivery/Matrix.d.ts +0 -29
- package/dist/delivery/Matrix.js +0 -81
- package/dist/delivery/index.d.ts +0 -22
- package/dist/delivery/index.js +0 -45
- package/dist/delivery/session-updater.d.ts +0 -9
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -164
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
|
|
8
|
+
* functionalities are not defined yet - the value for those can belong to
|
|
9
|
+
* model or to configure
|
|
10
|
+
*/
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
model: {
|
|
13
|
+
columnLabels: ['COLUMN 1', 'COLUMN 2', 'COLUMN 3'],
|
|
14
|
+
labelType: 'agreement',
|
|
15
|
+
matrixValues: {},
|
|
16
|
+
prompt: '',
|
|
17
|
+
promptEnabled: true,
|
|
18
|
+
rowLabels: ['STATEMENT 1', 'STATEMENT 2'],
|
|
19
|
+
teacherInstructions: '',
|
|
20
|
+
teacherInstructionsEnabled: true
|
|
21
|
+
},
|
|
22
|
+
configuration: {
|
|
23
|
+
baseInputConfiguration: {
|
|
24
|
+
h3: {
|
|
25
|
+
disabled: true
|
|
26
|
+
},
|
|
27
|
+
audio: {
|
|
28
|
+
disabled: false
|
|
29
|
+
},
|
|
30
|
+
video: {
|
|
31
|
+
disabled: false
|
|
32
|
+
},
|
|
33
|
+
image: {
|
|
34
|
+
disabled: false
|
|
35
|
+
},
|
|
36
|
+
textAlign: {
|
|
37
|
+
disabled: true
|
|
38
|
+
},
|
|
39
|
+
showParagraphs: {
|
|
40
|
+
disabled: false
|
|
41
|
+
},
|
|
42
|
+
separateParagraphs: {
|
|
43
|
+
disabled: true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
prompt: {
|
|
47
|
+
settings: true,
|
|
48
|
+
label: 'Prompt',
|
|
49
|
+
inputConfiguration: {
|
|
50
|
+
audio: {
|
|
51
|
+
disabled: false
|
|
52
|
+
},
|
|
53
|
+
video: {
|
|
54
|
+
disabled: false
|
|
55
|
+
},
|
|
56
|
+
image: {
|
|
57
|
+
disabled: false
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: false
|
|
61
|
+
},
|
|
62
|
+
settingsPanelDisabled: false,
|
|
63
|
+
spellCheck: {
|
|
64
|
+
label: 'Spellcheck',
|
|
65
|
+
settings: false,
|
|
66
|
+
enabled: true
|
|
67
|
+
},
|
|
68
|
+
teacherInstructions: {
|
|
69
|
+
settings: true,
|
|
70
|
+
label: 'Teacher Instructions',
|
|
71
|
+
inputConfiguration: {
|
|
72
|
+
audio: {
|
|
73
|
+
disabled: false
|
|
74
|
+
},
|
|
75
|
+
video: {
|
|
76
|
+
disabled: false
|
|
77
|
+
},
|
|
78
|
+
image: {
|
|
79
|
+
disabled: false
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["_default","exports","default","model","columnLabels","labelType","matrixValues","prompt","promptEnabled","rowLabels","teacherInstructions","teacherInstructionsEnabled","configuration","baseInputConfiguration","h3","disabled","audio","video","image","textAlign","showParagraphs","separateParagraphs","settings","label","inputConfiguration","required","settingsPanelDisabled","spellCheck","enabled"],"sources":["../src/defaults.js"],"sourcesContent":["/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType\n * functionalities are not defined yet - the value for those can belong to\n * model or to configure\n */\nexport default {\n model: {\n columnLabels: ['COLUMN 1', 'COLUMN 2', 'COLUMN 3'],\n labelType: 'agreement',\n matrixValues: {},\n prompt: '',\n promptEnabled: true,\n rowLabels: ['STATEMENT 1', 'STATEMENT 2'],\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n settingsPanelDisabled: false,\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n },\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAHA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAIe;EACbC,KAAK,EAAE;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,EAAE;QAAM,CAAC;QAC1BE,KAAK,EAAE;UAAEF,QAAQ,EAAE;QAAM,CAAC;QAC1BG,KAAK,EAAE;UAAEH,QAAQ,EAAE;QAAM;MAC3B,CAAC;MACDU,QAAQ,EAAE;IACZ;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 _debug = _interopRequireDefault(require("debug"));
|
|
12
|
+
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
13
|
+
var _Main = _interopRequireDefault(require("./Main"));
|
|
14
|
+
var _lodashEs = require("lodash-es");
|
|
15
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
16
|
+
const log = (0, _debug.default)('matrix:configure');
|
|
17
|
+
const prepareCustomizationObject = (config, model) => {
|
|
18
|
+
const configuration = (0, _lodashEs.defaults)(config, _defaults.default.configuration);
|
|
19
|
+
return {
|
|
20
|
+
configuration,
|
|
21
|
+
model
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
class Matrix extends HTMLElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this._root = null;
|
|
28
|
+
this._model = Matrix.createDefaultModel();
|
|
29
|
+
this._configuration = _defaults.default.configuration;
|
|
30
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
31
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
32
|
+
}
|
|
33
|
+
set model(s) {
|
|
34
|
+
this._model = Matrix.createDefaultModel(s);
|
|
35
|
+
this._render();
|
|
36
|
+
}
|
|
37
|
+
set configuration(c) {
|
|
38
|
+
const info = prepareCustomizationObject(c, this._model);
|
|
39
|
+
this.onModelChanged(info.model);
|
|
40
|
+
this._configuration = info.configuration;
|
|
41
|
+
this._render();
|
|
42
|
+
}
|
|
43
|
+
set disableSidePanel(s) {
|
|
44
|
+
this._disableSidePanel = s;
|
|
45
|
+
this._render();
|
|
46
|
+
}
|
|
47
|
+
dispatchModelUpdated(reset) {
|
|
48
|
+
const resetValue = !!reset;
|
|
49
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, resetValue));
|
|
50
|
+
}
|
|
51
|
+
onModelChanged(m, reset) {
|
|
52
|
+
this._model = m;
|
|
53
|
+
this._render();
|
|
54
|
+
this.dispatchModelUpdated(reset);
|
|
55
|
+
}
|
|
56
|
+
onConfigurationChanged(c) {
|
|
57
|
+
this._configuration = prepareCustomizationObject(c, this._model).configuration;
|
|
58
|
+
if (this._model) {
|
|
59
|
+
this.onModelChanged(this._model);
|
|
60
|
+
}
|
|
61
|
+
this._render();
|
|
62
|
+
}
|
|
63
|
+
insertSound(handler) {
|
|
64
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
65
|
+
}
|
|
66
|
+
onDeleteSound(src, done) {
|
|
67
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
68
|
+
}
|
|
69
|
+
_render() {
|
|
70
|
+
log('_render');
|
|
71
|
+
let element = /*#__PURE__*/_react.default.createElement(_Main.default, {
|
|
72
|
+
model: this._model,
|
|
73
|
+
configuration: this._configuration,
|
|
74
|
+
onModelChanged: this.onModelChanged,
|
|
75
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
76
|
+
disableSidePanel: this._disableSidePanel,
|
|
77
|
+
uploadSoundSupport: {
|
|
78
|
+
add: this.insertSound.bind(this),
|
|
79
|
+
delete: this.onDeleteSound.bind(this)
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (!this._root) {
|
|
83
|
+
this._root = (0, _client.createRoot)(this);
|
|
84
|
+
}
|
|
85
|
+
this._root.render(element);
|
|
86
|
+
}
|
|
87
|
+
disconnectedCallback() {
|
|
88
|
+
if (this._root) {
|
|
89
|
+
this._root.unmount();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = Matrix;
|
|
94
|
+
(0, _defineProperty2.default)(Matrix, "createDefaultModel", (model = {}) => ({
|
|
95
|
+
..._defaults.default.model,
|
|
96
|
+
...model
|
|
97
|
+
}));
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_Main","_lodashEs","_defaults","log","debug","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","Matrix","HTMLElement","constructor","_root","_model","createDefaultModel","_configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","info","disableSidePanel","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","insertSound","handler","InsertSoundEvent","onDeleteSound","src","done","DeleteSoundEvent","element","React","createElement","Main","uploadSoundSupport","add","delete","createRoot","render","disconnectedCallback","unmount","exports","default","_defineProperty2"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';\n\nimport Main from './Main';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\n\nconst log = debug('matrix:configure');\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model,\n };\n};\n\nexport default class Matrix extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...sensibleDefaults.model,\n ...model,\n });\n\n constructor() {\n super();\n this._root = null;\n this._model = Matrix.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(s) {\n this._model = Matrix.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n this._configuration = info.configuration;\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = m;\n this._render();\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OA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B,EAAE;QAClBC,GAAG,EAAE,IAAI,CAACZ,WAAW,CAACd,IAAI,CAAC,IAAI,CAAC;QAChC2B,MAAM,EAAE,IAAI,CAACV,aAAa,CAACjB,IAAI,CAAC,IAAI;MACtC;IACF,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAACL,KAAK,EAAE;MACf,IAAI,CAACA,KAAK,GAAG,IAAAiC,kBAAU,EAAC,IAAI,CAAC;IAC/B;IACA,IAAI,CAACjC,KAAK,CAACkC,MAAM,CAACR,OAAO,CAAC;EAC5B;EAEAS,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACnC,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACoC,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAzC,MAAA;AAAA,IAAA0C,gBAAA,CAAAD,OAAA,EAvFoBzC,MAAM,wBACG,CAACJ,KAAK,GAAG,CAAC,CAAC,MAAM;EAC3C,GAAGG,iBAAgB,CAACH,KAAK;EACzB,GAAGA;AACL,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumeric.js","names":["value","test","exports","default","_default"],"sources":["../src/isNumeric.js"],"sourcesContent":["export default (value) => {\n return /^-?\\d+$/.test(value);\n};\n"],"mappings":";;;;;;eAAgBA,KAAK,IAAK;EACxB,OAAO,SAAS,CAACC,IAAI,CAACD,KAAK,CAAC;AAC9B,CAAC;AAAAE,OAAA,CAAAC,OAAA,GAAAC,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MATRIX_LABEL_TYPE = void 0;
|
|
7
|
+
const MATRIX_LABEL_TYPE = exports.MATRIX_LABEL_TYPE = {
|
|
8
|
+
agreement: 'agreement',
|
|
9
|
+
frequency: 'frequency',
|
|
10
|
+
yesNo: 'yesNo',
|
|
11
|
+
importance: 'importance',
|
|
12
|
+
likelihood: 'likelihood',
|
|
13
|
+
like: 'like',
|
|
14
|
+
custom: 'custom'
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=matrixEntities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrixEntities.js","names":["MATRIX_LABEL_TYPE","exports","agreement","frequency","yesNo","importance","likelihood","like","custom"],"sources":["../src/matrixEntities.js"],"sourcesContent":["export const MATRIX_LABEL_TYPE = {\n agreement: 'agreement',\n frequency: 'frequency',\n yesNo: 'yesNo',\n importance: 'importance',\n likelihood: 'likelihood',\n like: 'like',\n custom: 'custom',\n};\n"],"mappings":";;;;;;AAAO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAC/BE,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,OAAO;EACdC,UAAU,EAAE,YAAY;EACxBC,UAAU,EAAE,YAAY;EACxBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACV,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/matrix-configure",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "3.1.3",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
8
|
+
"author": "",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@emotion/react": "^11.14.0",
|
|
11
|
+
"@emotion/style": "^0.8.0",
|
|
12
|
+
"@mui/icons-material": "^7.3.4",
|
|
13
|
+
"@mui/material": "^7.3.4",
|
|
14
|
+
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
+
"@pie-lib/config-ui": "13.0.7",
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "2.1.5",
|
|
17
|
+
"@pie-lib/render-ui": "6.1.2",
|
|
18
|
+
"debug": "^4.1.1",
|
|
19
|
+
"prop-types": "^15.8.1",
|
|
20
|
+
"react": "18.3.1",
|
|
21
|
+
"react-dom": "18.3.1",
|
|
22
|
+
"styled-components": "^5.2.1"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "./node_modules/.bin/jest"
|
|
26
|
+
},
|
|
27
|
+
"license": "ISC"
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.0.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@3.0.2...@pie-element/matrix-controller@3.0.3) (2026-05-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
9
|
+
|
|
10
|
+
## [3.0.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@3.0.2-next.0...@pie-element/matrix-controller@3.0.2) (2026-05-21)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
13
|
+
|
|
14
|
+
## [3.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@3.0.0...@pie-element/matrix-controller@3.0.1) (2026-04-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
17
|
+
|
|
18
|
+
## [1.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@1.1.1...@pie-element/matrix-controller@1.2.1) (2025-10-16)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
21
|
+
|
|
22
|
+
# [1.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@1.1.1...@pie-element/matrix-controller@1.2.0) (2025-10-15)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
25
|
+
|
|
26
|
+
## [1.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@1.0.1...@pie-element/matrix-controller@1.1.1) (2025-10-10)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
29
|
+
|
|
30
|
+
# [1.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@1.0.0...@pie-element/matrix-controller@1.1.0) (2025-10-07)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
33
|
+
|
|
34
|
+
## [1.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.1.2...@pie-element/matrix-controller@1.0.1) (2025-10-02)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
37
|
+
|
|
38
|
+
# [1.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.1.2...@pie-element/matrix-controller@1.0.0) (2025-10-01)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
41
|
+
|
|
42
|
+
## [0.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.1.1...@pie-element/matrix-controller@0.1.2) (2025-06-05)
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
- add validation for audio content PD-4123 ([f0ce3f1](https://github.com/pie-framework/pie-elements/commit/f0ce3f19a12fd4cfe2d2159ca4af801d866dc8a9))
|
|
47
|
+
|
|
48
|
+
## [0.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.1.0...@pie-element/matrix-controller@0.1.1) (2024-10-22)
|
|
49
|
+
|
|
50
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
51
|
+
|
|
52
|
+
# [0.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.14...@pie-element/matrix-controller@0.1.0) (2024-03-28)
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
- **matrix:** add required fields functionality PD-3596 ([356233e](https://github.com/pie-framework/pie-elements/commit/356233ea58c9bc1366b706fa6a86305e5d48bb8f))
|
|
57
|
+
|
|
58
|
+
## [0.0.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.13...@pie-element/matrix-controller@0.0.14) (2023-05-02)
|
|
59
|
+
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
|
|
62
|
+
- **pie-elements:** avoid logs pbs and add fragments as containers ([b4bd2b7](https://github.com/pie-framework/pie-elements/commit/b4bd2b7f994d7affdac443bd486047e5a629b763))
|
|
63
|
+
|
|
64
|
+
## [0.0.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.12...@pie-element/matrix-controller@0.0.13) (2022-12-07)
|
|
65
|
+
|
|
66
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
67
|
+
|
|
68
|
+
## [0.0.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.7...@pie-element/matrix-controller@0.0.9) (2021-11-11)
|
|
69
|
+
|
|
70
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
71
|
+
|
|
72
|
+
## [0.0.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.7...@pie-element/matrix-controller@0.0.8) (2021-11-11)
|
|
73
|
+
|
|
74
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
75
|
+
|
|
76
|
+
## [0.0.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.5...@pie-element/matrix-controller@0.0.7) (2021-08-05)
|
|
77
|
+
|
|
78
|
+
### Bug Fixes
|
|
79
|
+
|
|
80
|
+
- force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
81
|
+
|
|
82
|
+
## [0.0.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/matrix-controller@0.0.2...@pie-element/matrix-controller@0.0.5) (2021-03-03)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
85
|
+
|
|
86
|
+
## 0.0.2 (2021-02-02)
|
|
87
|
+
|
|
88
|
+
**Note:** Version bump only for package @pie-element/matrix-controller
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
columnLabels: ['COLUMN 1', 'COLUMN 2', 'COLUMN 3'],
|
|
9
|
+
labelType: 'agreement',
|
|
10
|
+
matrixValues: {},
|
|
11
|
+
prompt: '',
|
|
12
|
+
promptEnabled: true,
|
|
13
|
+
rowLabels: ['STATEMENT 1', 'STATEMENT 2'],
|
|
14
|
+
teacherInstructions: '',
|
|
15
|
+
teacherInstructionsEnabled: true
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["columnLabels","labelType","matrixValues","prompt","promptEnabled","rowLabels","teacherInstructions","teacherInstructionsEnabled"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n columnLabels: ['COLUMN 1', 'COLUMN 2', 'COLUMN 3'],\n labelType: 'agreement',\n matrixValues: {},\n prompt: '',\n promptEnabled: true,\n rowLabels: ['STATEMENT 1', 'STATEMENT 2'],\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n};\n"],"mappings":";;;;;;iCAAe;EACbA,YAAY,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC;EAClDC,SAAS,EAAE,WAAW;EACtBC,YAAY,EAAE,CAAC,CAAC;EAChBC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC;EACzCC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -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.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
8
|
+
exports.model = model;
|
|
9
|
+
exports.outcome = outcome;
|
|
10
|
+
exports.validate = void 0;
|
|
11
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
12
|
+
var _lodashEs = require("lodash-es");
|
|
13
|
+
const createDefaultModel = (model = {}) => new Promise(resolve => resolve({
|
|
14
|
+
..._defaults.default,
|
|
15
|
+
...model
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {*} question
|
|
21
|
+
* @param {*} session
|
|
22
|
+
* @param {*} env
|
|
23
|
+
*/
|
|
24
|
+
exports.createDefaultModel = createDefaultModel;
|
|
25
|
+
async function model(question, session, env) {
|
|
26
|
+
const normalizedQuestion = {
|
|
27
|
+
..._defaults.default,
|
|
28
|
+
...question
|
|
29
|
+
};
|
|
30
|
+
const out = {
|
|
31
|
+
...normalizedQuestion,
|
|
32
|
+
disabled: env.mode !== 'gather',
|
|
33
|
+
mode: env.mode
|
|
34
|
+
};
|
|
35
|
+
const {
|
|
36
|
+
role,
|
|
37
|
+
mode
|
|
38
|
+
} = env || {};
|
|
39
|
+
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
40
|
+
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
41
|
+
} else {
|
|
42
|
+
out.teacherInstructions = null;
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
function outcome(model, session) {
|
|
47
|
+
return new Promise(resolve => {
|
|
48
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
49
|
+
return resolve({
|
|
50
|
+
score: 0,
|
|
51
|
+
empty: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const score = Object.keys(session.value).reduce((acc, key) => {
|
|
55
|
+
const matrixValue = model.matrixValues[key];
|
|
56
|
+
return acc + (matrixValue || 0);
|
|
57
|
+
}, 0);
|
|
58
|
+
resolve({
|
|
59
|
+
score,
|
|
60
|
+
empty: false
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const createCorrectResponseSession = (question, env) => {
|
|
65
|
+
return new Promise(resolve => {
|
|
66
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
67
|
+
const {
|
|
68
|
+
matrixValues
|
|
69
|
+
} = question || [];
|
|
70
|
+
resolve({
|
|
71
|
+
id: '1',
|
|
72
|
+
value: matrixValues
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
resolve(null);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// remove all html tags
|
|
81
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
82
|
+
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
83
|
+
|
|
84
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
85
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
86
|
+
const validate = (model = {}, config = {}) => {
|
|
87
|
+
const errors = {};
|
|
88
|
+
['teacherInstructions', 'prompt'].forEach(field => {
|
|
89
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
90
|
+
errors[field] = 'This field is required.';
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return errors;
|
|
94
|
+
};
|
|
95
|
+
exports.validate = validate;
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","_lodashEs","createDefaultModel","model","Promise","resolve","defaults","exports","question","session","env","normalizedQuestion","out","disabled","mode","role","teacherInstructions","teacherInstructionsEnabled","outcome","isEmpty","score","empty","Object","keys","value","reduce","acc","key","matrixValue","matrixValues","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","config","errors","forEach","field","required"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\nimport { isEmpty } from 'lodash-es';\n\nexport const createDefaultModel = (model = {}) => new Promise((resolve) => resolve({ ...defaults, ...model }));\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = { ...defaults, ...question };\n\n const out = {\n ...normalizedQuestion,\n disabled: env.mode !== 'gather',\n mode: env.mode,\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport function outcome(model, session) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n return resolve({ score: 0, empty: true });\n }\n\n const score = Object.keys(session.value).reduce((acc, key) => {\n const matrixValue = model.matrixValues[key];\n return acc + (matrixValue || 0);\n }, 0);\n\n resolve({ score, empty: false });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { matrixValues } = question || [];\n\n resolve({\n id: '1',\n value: matrixValues,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n\n ['teacherInstructions', 'prompt'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,GAAGA,CAACC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAIC,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAAC;EAAE,GAAGC,iBAAQ;EAAE,GAAGH;AAAM,CAAC,CAAC,CAAC;;AAE9G;AACA;AACA;AACA;AACA;AACA;AALAI,OAAA,CAAAL,kBAAA,GAAAA,kBAAA;AAMO,eAAeC,KAAKA,CAACK,QAAQ,EAAEC,OAAO,EAAEC,GAAG,EAAE;EAClD,MAAMC,kBAAkB,GAAG;IAAE,GAAGL,iBAAQ;IAAE,GAAGE;EAAS,CAAC;EAEvD,MAAMI,GAAG,GAAG;IACV,GAAGD,kBAAkB;IACrBE,QAAQ,EAAEH,GAAG,CAACI,IAAI,KAAK,QAAQ;IAC/BA,IAAI,EAAEJ,GAAG,CAACI;EACZ,CAAC;EAED,MAAM;IAAEC,IAAI;IAAED;EAAK,CAAC,GAAGJ,GAAG,IAAI,CAAC,CAAC;EAEhC,IAAIK,IAAI,KAAK,YAAY,KAAKD,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,UAAU,CAAC,EAAE;IACrEF,GAAG,CAACI,mBAAmB,GAAGL,kBAAkB,CAACM,0BAA0B,GACnEN,kBAAkB,CAACK,mBAAmB,GACtC,IAAI;EACV,CAAC,MAAM;IACLJ,GAAG,CAACI,mBAAmB,GAAG,IAAI;EAChC;EAEA,OAAOJ,GAAG;AACZ;A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F,IAAI,IAAK,CAACA,IAAI,IAAI,EAAE,EAAEG,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC;AAEpF,MAAMC,QAAQ,GAAGA,CAAClC,KAAK,GAAG,CAAC,CAAC,EAAEmC,MAAM,GAAG,CAAC,CAAC,KAAK;EACnD,MAAMC,MAAM,GAAG,CAAC,CAAC;EAEjB,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAACC,OAAO,CAAEC,KAAK,IAAK;IACnD,IAAIH,MAAM,CAACG,KAAK,CAAC,EAAEC,QAAQ,IAAI,CAACP,UAAU,CAAChC,KAAK,CAACsC,KAAK,CAAC,CAAC,EAAE;MACxDF,MAAM,CAACE,KAAK,CAAC,GAAG,yBAAyB;IAC3C;EACF,CAAC,CAAC;EAEF,OAAOF,MAAM;AACf,CAAC;AAAChC,OAAA,CAAA8B,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/matrix-controller",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "3.0.3",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "./node_modules/.bin/jest"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"debug": "^4.1.1",
|
|
13
|
+
"lodash-es": "^4.17.23"
|
|
14
|
+
},
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC"
|
|
17
|
+
}
|