@pie-element/rubric 3.1.8-next.0 → 3.1.8-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/controller/lib/index.js
CHANGED
|
@@ -19,10 +19,16 @@ function markupToText(s) {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
function validate(model, config) {
|
|
22
|
-
var points = model.points
|
|
22
|
+
var points = model.points,
|
|
23
|
+
excludeZero = model.excludeZero;
|
|
23
24
|
var errors = {};
|
|
24
25
|
var pointsDescriptorsErrors = {};
|
|
25
26
|
(points || []).forEach(function (point, index) {
|
|
27
|
+
if (index === 0 && excludeZero) {
|
|
28
|
+
// if excludeZero is true, the 0 point is not displayed, so it should not be validated
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
if (!point || point === '<div></div>') {
|
|
27
33
|
pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
|
|
28
34
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["model","session","env","Promise","resolve","modelResult","role","markupToText","s","replace","validate","config","points","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length"],"mappings":";;;;;;;;AAAO,SAASA,KAAT,CAAeA,KAAf,EAAsBC,OAAtB,EAA+BC,GAA/B,EAAoC;AACzC,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,QAAMC,WAAW,GAAG,CAACL,KAAD,GAAS,EAAT,GAAcA,KAAlC;AACAI,IAAAA,OAAO,CAACF,GAAG,IAAIA,GAAG,CAACI,IAAX,IAAmBJ,GAAG,CAACI,IAAJ,KAAa,YAAhC,GAA+CD,WAA/C,GAA6D,EAA9D,CAAP;AACD,GAHM,CAAP;AAID;;AAGD,SAASE,YAAT,CAAsBC,CAAtB,EAAyB;AACvB,SAAO,CAACA,CAAC,IAAI,EAAN,EAAUC,OAAV,CAAkB,eAAlB,EAAmC,EAAnC,CAAP;AACD,C,CAGD;;;AACO,SAASC,QAAT,
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["model","session","env","Promise","resolve","modelResult","role","markupToText","s","replace","validate","config","points","excludeZero","errors","pointsDescriptorsErrors","forEach","point","index","identicalPointDescr","slice","some","p","Object","keys","length"],"mappings":";;;;;;;;AAAO,SAASA,KAAT,CAAeA,KAAf,EAAsBC,OAAtB,EAA+BC,GAA/B,EAAoC;AACzC,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,QAAMC,WAAW,GAAG,CAACL,KAAD,GAAS,EAAT,GAAcA,KAAlC;AACAI,IAAAA,OAAO,CAACF,GAAG,IAAIA,GAAG,CAACI,IAAX,IAAmBJ,GAAG,CAACI,IAAJ,KAAa,YAAhC,GAA+CD,WAA/C,GAA6D,EAA9D,CAAP;AACD,GAHM,CAAP;AAID;;AAGD,SAASE,YAAT,CAAsBC,CAAtB,EAAyB;AACvB,SAAO,CAACA,CAAC,IAAI,EAAN,EAAUC,OAAV,CAAkB,eAAlB,EAAmC,EAAnC,CAAP;AACD,C,CAGD;;;AACO,SAASC,QAAT,CAAkBV,KAAlB,EAAyBW,MAAzB,EAAiC;AACtC,MAAQC,MAAR,GAAgCZ,KAAhC,CAAQY,MAAR;AAAA,MAAgBC,WAAhB,GAAgCb,KAAhC,CAAgBa,WAAhB;AACA,MAAMC,MAAM,GAAG,EAAf;AACA,MAAMC,uBAAuB,GAAG,EAAhC;AAEA,GAACH,MAAM,IAAI,EAAX,EAAeI,OAAf,CAAuB,UAACC,KAAD,EAAQC,KAAR,EAAkB;AACvC,QAAIA,KAAK,KAAK,CAAV,IAAeL,WAAnB,EAAgC;AAC9B;AACA;AACD;;AAED,QAAI,CAACI,KAAD,IAAUA,KAAK,KAAK,aAAxB,EAAuC;AACrCF,MAAAA,uBAAuB,CAACG,KAAD,CAAvB,GAAiC,qCAAjC;AACD,KAFD,MAEO;AACL,UAAMC,mBAAmB,GAAGP,MAAM,CAACQ,KAAP,CAAaF,KAAK,GAAG,CAArB,EAAwBG,IAAxB,CAA6B,UAAAC,CAAC;AAAA,eAAIf,YAAY,CAACe,CAAD,CAAZ,KAAoBf,YAAY,CAACU,KAAD,CAApC;AAAA,OAA9B,CAA5B;;AAEA,UAAIE,mBAAJ,EAAyB;AACvBJ,QAAAA,uBAAuB,CAACG,KAAD,CAAvB,GAAiC,sCAAjC;AACD;AACF;AACF,GAfD;;AAiBA,MAAIK,MAAM,CAACC,IAAP,CAAYT,uBAAZ,EAAqCU,MAArC,GAA8C,CAAlD,EAAqD;AACnDX,IAAAA,MAAM,CAACC,uBAAP,GAAiCA,uBAAjC;AACD;;AAED,SAAOD,MAAP;AACD","sourcesContent":["export function model(model, session, env) {\n return new Promise((resolve) => {\n const modelResult = !model ? {} : model;\n resolve(env && env.role && env.role === 'instructor' ? modelResult : {});\n });\n}\n\n\nfunction markupToText(s) {\n return (s || '').replace(/(<([^>]+)>)/ig, '');\n}\n\n\n// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.\nexport function validate(model, config) {\n const { points, excludeZero } = model;\n const errors = {};\n const pointsDescriptorsErrors = {};\n\n (points || []).forEach((point, index) => {\n if (index === 0 && excludeZero) {\n // if excludeZero is true, the 0 point is not displayed, so it should not be validated\n return;\n }\n\n if (!point || point === '<div></div>') {\n pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';\n } else {\n const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));\n\n if (identicalPointDescr) {\n pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';\n }\n }\n });\n\n if (Object.keys(pointsDescriptorsErrors).length > 0) {\n errors.pointsDescriptorsErrors = pointsDescriptorsErrors;\n }\n\n return errors;\n}\n"],"file":"index.js"}
|
package/controller/src/index.js
CHANGED
|
@@ -12,16 +12,20 @@ function markupToText(s) {
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
// IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.
|
|
15
|
-
export function validate
|
|
16
|
-
const { points } = model;
|
|
15
|
+
export function validate(model, config) {
|
|
16
|
+
const { points, excludeZero } = model;
|
|
17
17
|
const errors = {};
|
|
18
18
|
const pointsDescriptorsErrors = {};
|
|
19
19
|
|
|
20
20
|
(points || []).forEach((point, index) => {
|
|
21
|
-
if(
|
|
22
|
-
|
|
21
|
+
if (index === 0 && excludeZero) {
|
|
22
|
+
// if excludeZero is true, the 0 point is not displayed, so it should not be validated
|
|
23
|
+
return;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
if (!point || point === '<div></div>') {
|
|
27
|
+
pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
|
|
28
|
+
} else {
|
|
25
29
|
const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
|
|
26
30
|
|
|
27
31
|
if (identicalPointDescr) {
|
|
@@ -30,7 +34,7 @@ export function validate (model, config) {
|
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
36
|
|
|
33
|
-
if(Object.keys(pointsDescriptorsErrors).length > 0){
|
|
37
|
+
if (Object.keys(pointsDescriptorsErrors).length > 0) {
|
|
34
38
|
errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
|
|
35
39
|
}
|
|
36
40
|
|
package/module/controller.js
CHANGED
|
@@ -19,10 +19,16 @@ function markupToText(s) {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
function validate(model, config) {
|
|
22
|
-
var points = model.points
|
|
22
|
+
var points = model.points,
|
|
23
|
+
excludeZero = model.excludeZero;
|
|
23
24
|
var errors = {};
|
|
24
25
|
var pointsDescriptorsErrors = {};
|
|
25
26
|
(points || []).forEach(function (point, index) {
|
|
27
|
+
if (index === 0 && excludeZero) {
|
|
28
|
+
// if excludeZero is true, the 0 point is not displayed, so it should not be validated
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
if (!point || point === '<div></div>') {
|
|
27
33
|
pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
|
|
28
34
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/rubric",
|
|
3
|
-
"version": "3.1.8-next.
|
|
3
|
+
"version": "3.1.8-next.2+7521f7fde",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"description": "Rubric Scoring Interaction",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "pie framework developers",
|
|
17
17
|
"license": "ISC",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "7521f7fdef22c6f5918d299a7f323a4f54976023",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postpublish": "../../scripts/postpublish"
|
|
21
21
|
},
|