@pie-element/passage 5.0.1 → 11.0.3-esm.0
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/configure/package.json +3 -3
- package/controller/package.json +1 -1
- package/esm/configure.css +847 -0
- package/esm/configure.js +343 -12152
- package/esm/configure.js.map +1 -1
- package/esm/controller.css +847 -0
- package/esm/controller.js +37 -85
- package/esm/controller.js.map +1 -1
- package/esm/element.css +847 -0
- package/esm/element.js +84 -12427
- package/esm/element.js.map +1 -1
- package/esm/print.css +847 -0
- package/esm/print.js +85 -12443
- package/esm/print.js.map +1 -1
- package/lib/stimulus-tabs.js +2 -2
- package/lib/stimulus-tabs.js.map +1 -1
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +1 -1
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +4 -4
package/esm/controller.js
CHANGED
|
@@ -1,54 +1,21 @@
|
|
|
1
1
|
import isEmpty from 'lodash/isEmpty';
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (info.done) {
|
|
13
|
-
resolve(value);
|
|
14
|
-
} else {
|
|
15
|
-
Promise.resolve(value).then(_next, _throw);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _asyncToGenerator(fn) {
|
|
20
|
-
return function () {
|
|
21
|
-
var self = this,
|
|
22
|
-
args = arguments;
|
|
23
|
-
return new Promise(function (resolve, reject) {
|
|
24
|
-
var gen = fn.apply(self, args);
|
|
25
|
-
|
|
26
|
-
function _next(value) {
|
|
27
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _throw(err) {
|
|
31
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3
|
+
function _extends() {
|
|
4
|
+
_extends = Object.assign || function (target) {
|
|
5
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
+
var source = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var key in source) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
10
|
+
target[key] = source[key];
|
|
11
|
+
}
|
|
32
12
|
}
|
|
13
|
+
}
|
|
33
14
|
|
|
34
|
-
|
|
35
|
-
});
|
|
15
|
+
return target;
|
|
36
16
|
};
|
|
37
|
-
}
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
if (key in obj) {
|
|
41
|
-
Object.defineProperty(obj, key, {
|
|
42
|
-
value: value,
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
obj[key] = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return obj;
|
|
18
|
+
return _extends.apply(this, arguments);
|
|
52
19
|
}
|
|
53
20
|
|
|
54
21
|
// TODO: also update '../../configure/src/defaults.js' and '../../src/print.js' when updating defaults
|
|
@@ -68,26 +35,21 @@ var defaults = {
|
|
|
68
35
|
titleEnabled: true
|
|
69
36
|
};
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
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) { _defineProperty(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; }
|
|
38
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
74
39
|
|
|
75
|
-
|
|
40
|
+
const checkNullish = value => value !== null && value !== undefined;
|
|
76
41
|
|
|
77
|
-
|
|
42
|
+
const isEnabled = (value, defaultValue) => checkNullish(value) ? value : defaultValue;
|
|
78
43
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function createDefaultModel() {
|
|
82
|
-
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
44
|
+
function createDefaultModel(model = {}) {
|
|
83
45
|
return new Promise(resolve => {
|
|
84
|
-
resolve(
|
|
46
|
+
resolve(_extends({}, defaults, model));
|
|
85
47
|
});
|
|
86
48
|
}
|
|
87
|
-
|
|
49
|
+
const normalize = question => _extends({}, defaults, question);
|
|
88
50
|
|
|
89
|
-
|
|
90
|
-
|
|
51
|
+
const normalizeTeacherInstructions = (instructions, env) => {
|
|
52
|
+
const {
|
|
91
53
|
role,
|
|
92
54
|
mode
|
|
93
55
|
} = env;
|
|
@@ -106,39 +68,29 @@ var normalizeTeacherInstructions = (instructions, env) => {
|
|
|
106
68
|
*/
|
|
107
69
|
|
|
108
70
|
|
|
109
|
-
function model(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',
|
|
122
|
-
text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : ''
|
|
123
|
-
}));
|
|
124
|
-
return _objectSpread(_objectSpread({}, normalizedQuestion), {}, {
|
|
125
|
-
passages: normalizedPassages
|
|
126
|
-
});
|
|
71
|
+
async function model(question, session, env) {
|
|
72
|
+
const normalizedQuestion = normalize(question);
|
|
73
|
+
const normalizedPassages = normalizedQuestion.passages.map((passage, index) => ({
|
|
74
|
+
teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, normalizedQuestion.teacherInstructionsEnabled) ? normalizeTeacherInstructions(passage.teacherInstructions, env) : '',
|
|
75
|
+
label: getContent(passage.title) ? passage.title : `Passage ${index + 1}`,
|
|
76
|
+
title: isEnabled(passage.titleEnabled, normalizedQuestion.titleEnabled) ? passage.title || '' : '',
|
|
77
|
+
subtitle: isEnabled(passage.subtitleEnabled, normalizedQuestion.subtitleEnabled) ? passage.subtitle || '' : '',
|
|
78
|
+
author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',
|
|
79
|
+
text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : ''
|
|
80
|
+
}));
|
|
81
|
+
return _extends({}, normalizedQuestion, {
|
|
82
|
+
passages: normalizedPassages
|
|
127
83
|
});
|
|
128
|
-
return _model.apply(this, arguments);
|
|
129
84
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
134
|
-
var errors = {};
|
|
135
|
-
var passagesErrors = {};
|
|
85
|
+
const validate = (model = {}, config = {}) => {
|
|
86
|
+
const errors = {};
|
|
87
|
+
const passagesErrors = {};
|
|
136
88
|
(model.passages || []).forEach((passage, index) => {
|
|
137
|
-
|
|
89
|
+
const err = {};
|
|
138
90
|
['teacherInstructions', 'title', 'subtitle', 'author', 'text'].forEach(field => {
|
|
139
91
|
var _config$field;
|
|
140
92
|
|
|
141
|
-
if ((_config$field = config[field])
|
|
93
|
+
if ((_config$field = config[field]) != null && _config$field.required && !getContent(passage[field])) {
|
|
142
94
|
err[field] = 'This field is required.';
|
|
143
95
|
}
|
|
144
96
|
});
|
package/esm/controller.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sources":["
|
|
1
|
+
{"version":3,"file":"controller.js","sources":["../controller/src/defaults.js","../controller/src/index.js"],"sourcesContent":["// TODO: also update '../../configure/src/defaults.js' and '../../src/print.js' when updating defaults\nexport default {\n authorEnabled: false, // TODO: should be set to true when all Studio content is updated\n passages: [\n {\n teacherInstructions: '',\n title: '',\n subtitle: '',\n author: '',\n text: '',\n },\n ],\n subtitleEnabled: true,\n teacherInstructionsEnabled: true,\n textEnabled: true,\n titleEnabled: true,\n};\n","import isEmpty from 'lodash/isEmpty';\n\nimport defaults from './defaults';\n\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nconst checkNullish = (value) => value !== null && value !== undefined;\n\nconst isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nconst normalizeTeacherInstructions = (instructions, env) => {\n const { role, mode } = env;\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n return instructions || '';\n }\n\n return '';\n};\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 const normalizedPassages = normalizedQuestion.passages.map((passage, index) => ({\n teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, normalizedQuestion.teacherInstructionsEnabled)\n ? normalizeTeacherInstructions(passage.teacherInstructions, env)\n : '',\n label: getContent(passage.title) ? passage.title : `Passage ${index + 1}`,\n title: isEnabled(passage.titleEnabled, normalizedQuestion.titleEnabled) ? passage.title || '' : '',\n subtitle: isEnabled(passage.subtitleEnabled, normalizedQuestion.subtitleEnabled) ? passage.subtitle || '' : '',\n author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',\n text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : '',\n }));\n\n return {\n ...normalizedQuestion,\n passages: normalizedPassages,\n };\n}\n\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n const passagesErrors = {};\n\n (model.passages || []).forEach((passage, index) => {\n const err = {};\n\n ['teacherInstructions', 'title', 'subtitle', 'author', 'text'].forEach((field) => {\n if (config[field]?.required && !getContent(passage[field])) {\n err[field] = 'This field is required.';\n }\n });\n\n if (!isEmpty(err)) {\n passagesErrors[index] = err;\n }\n });\n\n if (!isEmpty(passagesErrors)) {\n errors.passages = passagesErrors;\n }\n\n return errors;\n};\n"],"names":["authorEnabled","passages","teacherInstructions","title","subtitle","author","text","subtitleEnabled","teacherInstructionsEnabled","textEnabled","titleEnabled","getContent","html","replace","checkNullish","value","undefined","isEnabled","defaultValue","createDefaultModel","model","Promise","resolve","defaults","normalize","question","normalizeTeacherInstructions","instructions","env","role","mode","session","normalizedQuestion","normalizedPassages","map","passage","index","label","validate","config","errors","passagesErrors","forEach","err","field","required","isEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA,eAAe;AACbA,EAAAA,aAAa,EAAE,KADF;AACS;AACtBC,EAAAA,QAAQ,EAAE,CACR;AACEC,IAAAA,mBAAmB,EAAE,EADvB;AAEEC,IAAAA,KAAK,EAAE,EAFT;AAGEC,IAAAA,QAAQ,EAAE,EAHZ;AAIEC,IAAAA,MAAM,EAAE,EAJV;AAKEC,IAAAA,IAAI,EAAE,EAAA;AALR,GADQ,CAFG;AAWbC,EAAAA,eAAe,EAAE,IAXJ;AAYbC,EAAAA,0BAA0B,EAAE,IAZf;AAabC,EAAAA,WAAW,EAAE,IAbA;AAcbC,EAAAA,YAAY,EAAE,IAAA;AAdD,CAAf;;ACGA,MAAMC,UAAU,GAAIC,IAAD,IAAU,CAACA,IAAI,IAAI,EAAT,EAAaC,OAAb,CAAqB,oCAArB,EAA2D,EAA3D,CAA7B,CAAA;;AAEA,MAAMC,YAAY,GAAIC,KAAD,IAAWA,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAKC,SAA5D,CAAA;;AAEA,MAAMC,SAAS,GAAG,CAACF,KAAD,EAAQG,YAAR,KAA0BJ,YAAY,CAACC,KAAD,CAAZ,GAAsBA,KAAtB,GAA8BG,YAA1E,CAAA;;AAEO,SAASC,kBAAT,CAA4BC,KAAK,GAAG,EAApC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