@wg-npm/survey-core 1.78.511900 → 1.78.511938
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/dist/survey-core.esm.js +11 -3
- package/package.json +2 -2
- package/src/models.ts +24 -9
- package/src/quetion-factory.ts +1 -1
package/dist/survey-core.esm.js
CHANGED
|
@@ -48,7 +48,7 @@ class QuestionFactory {
|
|
|
48
48
|
return _.range(4).map(() => this.createDefault(locale));
|
|
49
49
|
}
|
|
50
50
|
static createMatrixQuestionChoices(locale) {
|
|
51
|
-
return _.range(
|
|
51
|
+
return _.range(4).map(() => this.createDefault(locale));
|
|
52
52
|
}
|
|
53
53
|
static createEvaluationItems(locale) {
|
|
54
54
|
return _.range(5).map(() => this.createEvaluationItem(locale));
|
|
@@ -158,8 +158,16 @@ class BaseQuestionModel {
|
|
|
158
158
|
return Math.round(result * 100) / 100;
|
|
159
159
|
}
|
|
160
160
|
else if (question.type == "MATRIX") {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
let total = 0;
|
|
162
|
+
if (question.options.titleScoringEnabled) {
|
|
163
|
+
const titleMax = _.get(question, "options.scoreMax", null) ?? _.get(question, "options.score", 0);
|
|
164
|
+
total += parseFloat(titleMax || 0);
|
|
165
|
+
}
|
|
166
|
+
if (question.options.scoringEnabled) {
|
|
167
|
+
const choiceMaxScore = _.max(_.map(question.choices, (choice) => parseFloat(_.get(choice, "options.score", 0) || 0))) || 0;
|
|
168
|
+
total += choiceMaxScore * question.subQuestions.length;
|
|
169
|
+
}
|
|
170
|
+
return total;
|
|
163
171
|
}
|
|
164
172
|
else if (question.type == "SCORING") {
|
|
165
173
|
const score = question.options.maxRange;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-core",
|
|
3
|
-
"version": "1.78.
|
|
3
|
+
"version": "1.78.511938",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ad10a00e012ea9db36e51202b7a24265681d8630",
|
|
51
51
|
"rollup": {
|
|
52
52
|
"external": [
|
|
53
53
|
"lodash"
|
package/src/models.ts
CHANGED
|
@@ -141,6 +141,11 @@ export class QuestionOptionsModel {
|
|
|
141
141
|
readonly?: Boolean;
|
|
142
142
|
sliderValue?: Number;
|
|
143
143
|
richTextEnabled?: Boolean;
|
|
144
|
+
titleScoringEnabled?: Boolean;
|
|
145
|
+
score?: any;
|
|
146
|
+
scoreMin?: any;
|
|
147
|
+
scoreMax?: any;
|
|
148
|
+
subRequired?: Boolean;
|
|
144
149
|
|
|
145
150
|
constructor(required: Boolean) {
|
|
146
151
|
this.required = required;
|
|
@@ -222,15 +227,25 @@ export class BaseQuestionModel {
|
|
|
222
227
|
);
|
|
223
228
|
return Math.round(result * 100) / 100;
|
|
224
229
|
} else if (question.type == QuestionType.MATRIX) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
let total = 0;
|
|
231
|
+
if (question.options.titleScoringEnabled) {
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
const titleMax = _.get(question, "options.scoreMax", null) ?? _.get(question, "options.score", 0);
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
total += parseFloat(titleMax || 0);
|
|
236
|
+
}
|
|
237
|
+
if (question.options.scoringEnabled) {
|
|
238
|
+
const choiceMaxScore =
|
|
239
|
+
_.max(
|
|
240
|
+
_.map(question.choices, (choice: any) =>
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
parseFloat(_.get(choice, "options.score", 0) || 0)
|
|
243
|
+
)
|
|
244
|
+
) || 0;
|
|
245
|
+
// @ts-ignore
|
|
246
|
+
total += choiceMaxScore * question.subQuestions.length;
|
|
247
|
+
}
|
|
248
|
+
return total;
|
|
234
249
|
} else if (question.type == QuestionType.SCORING) {
|
|
235
250
|
const score = question.options.maxRange;
|
|
236
251
|
return (
|
package/src/quetion-factory.ts
CHANGED
|
@@ -74,7 +74,7 @@ export class QuestionFactory {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
public static createMatrixQuestionChoices(locale: string) {
|
|
77
|
-
return _.range(
|
|
77
|
+
return _.range(4).map(() => this.createDefault(locale));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
public static createEvaluationItems(locale: string) {
|