@wg-npm/survey-core 0.3.22760 → 0.3.22809

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.
@@ -13,6 +13,9 @@ class QuestionFactory {
13
13
  this.registerQuestion("MATRIX", (locale) => {
14
14
  return new QuestionMatrixModel("MATRIX", locale);
15
15
  });
16
+ this.registerQuestion("SCORING", (locale) => {
17
+ return new QuestionScoringModel("SCORING", locale);
18
+ });
16
19
  this.registerQuestion("TEXT_TITLE", (locale) => {
17
20
  return new QuestionTextTitleModel("TEXT_TITLE", locale);
18
21
  });
@@ -156,6 +159,14 @@ class BaseQuestionModel {
156
159
  }
157
160
  return 0;
158
161
  }
162
+ static getScoreRange(question) {
163
+ if (question.type == "SCORING") {
164
+ const minRange = question.options.minRange;
165
+ const maxRange = question.options.maxRange;
166
+ return minRange + " - " + maxRange;
167
+ }
168
+ return "";
169
+ }
159
170
  static createQuestionId() {
160
171
  return `Q-${_.now()}-${_.random(0, 9999999)}`;
161
172
  }
@@ -274,6 +285,12 @@ class QuestionMatrixModel extends BaseQuestionModel {
274
285
  return number;
275
286
  }
276
287
  }
288
+ class QuestionScoringModel extends BaseQuestionModel {
289
+ constructor(type, locale) {
290
+ super(type, locale);
291
+ this.subQuestions = [];
292
+ }
293
+ }
277
294
  class ResponseModel {
278
295
  }
279
296
  class PlanModel {
@@ -312,4 +329,4 @@ function move(array, fromIndex, toIndex) {
312
329
  array[toIndex] = moveValue;
313
330
  }
314
331
 
315
- export { BaseQuestionModel, ChoiceModel, EvaluationItemModel, ExprConditionModel, ExprEvaluationItemModel, PlanModel, PlanStatisticsModel, QuestionCheckBoxModel, QuestionEvaluationModel, QuestionFactory, QuestionFillBlankModel, QuestionHeaderModel, QuestionMatrixModel, QuestionMulitSelectionModel, QuestionOptionsModel, QuestionShortAnswerModel, QuestionSingleSelectionModel, QuestionTextTitleModel, ResponseModel, ResponseStatisticsModel, StarEvaluationItemModel, SubQuestionModel, move, translate };
332
+ export { BaseQuestionModel, ChoiceModel, EvaluationItemModel, ExprConditionModel, ExprEvaluationItemModel, PlanModel, PlanStatisticsModel, QuestionCheckBoxModel, QuestionEvaluationModel, QuestionFactory, QuestionFillBlankModel, QuestionHeaderModel, QuestionMatrixModel, QuestionMulitSelectionModel, QuestionOptionsModel, QuestionScoringModel, QuestionShortAnswerModel, QuestionSingleSelectionModel, QuestionTextTitleModel, ResponseModel, ResponseStatisticsModel, StarEvaluationItemModel, SubQuestionModel, move, translate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-core",
3
- "version": "0.3.22760",
3
+ "version": "0.3.22809",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  QuestionCheckBoxModel,
11
11
  QuestionTextTitleModel,
12
12
  QuestionMatrixModel,
13
+ QuestionScoringModel,
13
14
  QuestionFillBlankModel,
14
15
  QuestionMulitSelectionModel,
15
16
  QuestionShortAnswerModel,
package/src/models.ts CHANGED
@@ -24,6 +24,7 @@ export const enum QuestionType {
24
24
  MATRIX = "MATRIX",
25
25
  TEXT_TITLE = "TEXT_TITLE",
26
26
  EVALUATION = "EVALUATION",
27
+ SCORING = "SCORING",
27
28
  }
28
29
 
29
30
  export const enum EvaluationType {
@@ -214,6 +215,15 @@ export class BaseQuestionModel {
214
215
  return 0;
215
216
  }
216
217
 
218
+ static getScoreRange(question): string {
219
+ if (question.type == QuestionType.SCORING) {
220
+ const minRange = question.options.minRange;
221
+ const maxRange = question.options.maxRange;
222
+ return minRange + " - " + maxRange;
223
+ }
224
+ return "";
225
+ }
226
+
217
227
  static createQuestionId(): string {
218
228
  return `Q-${_.now()}-${_.random(0, 9999999)}`;
219
229
  }
@@ -374,6 +384,15 @@ export class QuestionMatrixModel extends BaseQuestionModel {
374
384
  }
375
385
  }
376
386
 
387
+ export class QuestionScoringModel extends BaseQuestionModel {
388
+ subQuestions: Array<SubQuestionModel>;
389
+
390
+ constructor(type: QuestionType, locale: string) {
391
+ super(type, locale);
392
+ this.subQuestions = [];
393
+ }
394
+ }
395
+
377
396
  export interface SurveyOptionsModel {
378
397
  primaryLanguage: SurveyLocales;
379
398
  languages: SurveyLocales[];
@@ -9,6 +9,7 @@ import {
9
9
  QuestionEvaluationModel,
10
10
  StarEvaluationItemModel,
11
11
  ExclusiveChoiceModel,
12
+ QuestionScoringModel,
12
13
  } from "./models";
13
14
  import _ from "lodash";
14
15
 
@@ -39,6 +40,9 @@ export class QuestionFactory {
39
40
  this.registerQuestion(QuestionType.MATRIX, (locale: string) => {
40
41
  return new QuestionMatrixModel(QuestionType.MATRIX, locale);
41
42
  });
43
+ this.registerQuestion(QuestionType.SCORING, (locale: string) => {
44
+ return new QuestionScoringModel(QuestionType.SCORING, locale);
45
+ });
42
46
  this.registerQuestion(QuestionType.TEXT_TITLE, (locale: string) => {
43
47
  return new QuestionTextTitleModel(QuestionType.TEXT_TITLE, locale);
44
48
  });