@media-quest/builder 0.0.24 → 0.0.25
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/package.json +2 -2
- package/src/Builder-option.ts +64 -66
- package/src/Builder-page.spec.ts +320 -320
- package/src/Builder-page.ts +259 -257
- package/src/Builder-question.spec.ts +68 -68
- package/src/Builder-question.ts +102 -101
- package/src/Builder-schema.spec.ts +17 -17
- package/src/Builder-schema.ts +14 -8
- package/src/Builder-text.spec.ts +24 -24
- package/src/Builder-text.ts +57 -57
- package/src/BuilderObject.ts +29 -61
- package/src/BuilderTag.ts +96 -97
- package/src/codebook.ts +72 -72
- package/src/primitives/ID.spec.ts +39 -0
- package/src/primitives/ID.ts +119 -0
- package/src/primitives/page-prefix.ts +59 -58
- package/src/primitives/varID.ts +12 -11
- package/src/public-api.ts +3 -1
- package/src/rulebuilder/Builder-rule.spec.ts +323 -322
- package/src/rulebuilder/Builder-rule.ts +191 -190
- package/src/rulebuilder/RuleBuilder-test-utils.ts +320 -316
- package/src/rulebuilder/RuleVariable.ts +48 -49
- package/src/rulebuilder/page-action-manager.ts +33 -31
- package/src/rulebuilder/rule2/Rule2.ts +215 -211
- package/src/schema-config.ts +25 -25
- package/src/variable/{mq-variable.ts → b-variable.ts} +5 -5
- package/src/variable/mq-variable.spec.ts +6 -5
- package/src/variable/sum-score-variable.ts +50 -0
- package/src/variable/sum-score.ts +6 -14
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface BVariable {
|
|
2
2
|
readonly kind: "numeric-variable" | "numeric-range-variable" | "string-variable";
|
|
3
|
-
|
|
4
3
|
label: string;
|
|
5
4
|
varId: string;
|
|
6
5
|
description?: string;
|
|
@@ -28,6 +27,7 @@ export interface MqVariable {
|
|
|
28
27
|
pageId?: string;
|
|
29
28
|
eventSource?: string;
|
|
30
29
|
pagePrefix?: string;
|
|
30
|
+
questionPrefix?: string;
|
|
31
31
|
modulePrefix?: string;
|
|
32
32
|
moduleID?: string;
|
|
33
33
|
pageNumber?: number;
|
|
@@ -47,11 +47,11 @@ export interface MqVariable {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const MISSING = 999;
|
|
50
|
-
export const
|
|
50
|
+
export const BVariable = {
|
|
51
51
|
MISSING,
|
|
52
52
|
} as const;
|
|
53
53
|
|
|
54
|
-
export interface PageVariable extends
|
|
54
|
+
export interface PageVariable extends BVariable {
|
|
55
55
|
readonly pageId: string;
|
|
56
56
|
readonly pagePrefix: string;
|
|
57
57
|
readonly pagePosition: number;
|
|
@@ -59,7 +59,7 @@ export interface PageVariable extends MqVariable {
|
|
|
59
59
|
readonly origin: "question" | "form-field";
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export interface PredefinedVariable extends
|
|
62
|
+
export interface PredefinedVariable extends BVariable {
|
|
63
63
|
readonly origin: "predefined";
|
|
64
64
|
readonly modulePrefix: string;
|
|
65
65
|
readonly moduleID: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { BVariable } from "./b-variable";
|
|
2
|
+
import { SumScore } from "./sum-score";
|
|
3
|
+
import { SumScoreVariableDto } from "./sum-score-variable";
|
|
4
|
+
const createVariable = (value: number): BVariable => {
|
|
4
5
|
return {
|
|
5
6
|
varId: "v" + value,
|
|
6
7
|
label: "label for v" + value,
|
|
@@ -10,8 +11,8 @@ const createVariable = (value: number): MqVariable => {
|
|
|
10
11
|
};
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
const createSumScore = (basedOn: Array<{ variable:
|
|
14
|
-
const sumVar1:
|
|
14
|
+
const createSumScore = (basedOn: Array<{ variable: BVariable; weight?: number }>) => {
|
|
15
|
+
const sumVar1: SumScoreVariableDto = {
|
|
15
16
|
kind: "numeric-variable",
|
|
16
17
|
initialValue: 0,
|
|
17
18
|
min: 0,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BVariable } from "./b-variable";
|
|
2
|
+
import { BuilderObjectId } from "../BuilderObject";
|
|
3
|
+
// import { PageID } from "@media-quest/engine";
|
|
4
|
+
// import { BuilderObject, BuilderObjectId } from "../BuilderObject";
|
|
5
|
+
//
|
|
6
|
+
// export class SumScoreVariable {}
|
|
7
|
+
export interface SumScoreVariableDto extends BVariable {
|
|
8
|
+
readonly origin: "sum-score";
|
|
9
|
+
useAvg?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* All variables that the sum-score should be based on.
|
|
12
|
+
*/
|
|
13
|
+
basedOn: Array<{ varId: string; weight?: number }>;
|
|
14
|
+
}
|
|
15
|
+
export interface SumScoreEntry {
|
|
16
|
+
sumScoreId: BuilderObjectId.SumScoreVariableId;
|
|
17
|
+
// pageId: PageID;
|
|
18
|
+
}
|
|
19
|
+
// export class SumScoreVariable extends BuilderObject<
|
|
20
|
+
// "builder-sum-score-variable",
|
|
21
|
+
// SumScoreVariableDto
|
|
22
|
+
// > {
|
|
23
|
+
// readonly useAvg = false;
|
|
24
|
+
// readonly basedOn: Array<{ varId: string; weight?: number }>;
|
|
25
|
+
// readonly id: BuilderObjectId.SumScoreVariableId;
|
|
26
|
+
// label = ""
|
|
27
|
+
// description = ""
|
|
28
|
+
// toJson(): SumScoreVariableDto {
|
|
29
|
+
// const basedOn = [...this.basedOn]
|
|
30
|
+
// const varId = this.id
|
|
31
|
+
// const label = this.label;
|
|
32
|
+
//
|
|
33
|
+
// return {
|
|
34
|
+
// origin: "sum-score",
|
|
35
|
+
// varId,
|
|
36
|
+
// label,
|
|
37
|
+
// useAvg: this.useAvg,
|
|
38
|
+
// basedOn,
|
|
39
|
+
// };
|
|
40
|
+
// }
|
|
41
|
+
// clone(): SumScoreVariableDto {
|
|
42
|
+
// throw new Error("Method not implemented.");
|
|
43
|
+
// }
|
|
44
|
+
// readonly objectType = "builder-sum-score-variable";
|
|
45
|
+
// constructor(dto: SumScoreVariableDto) {
|
|
46
|
+
// super(dto);
|
|
47
|
+
// this.useAvg = dto.useAvg;
|
|
48
|
+
// this.basedOn = dto.basedOn;
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface SumScoreVariable extends MqVariable {
|
|
4
|
-
readonly origin: "sum-score";
|
|
5
|
-
useAvg?: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* All variables that the sum-score should be based on.
|
|
8
|
-
*/
|
|
9
|
-
basedOn: Array<{ varId: string; weight?: number }>;
|
|
10
|
-
}
|
|
1
|
+
import { BVariable } from "./b-variable";
|
|
2
|
+
import { SumScoreVariableDto } from "./sum-score-variable";
|
|
11
3
|
|
|
12
4
|
/**
|
|
13
5
|
*
|
|
@@ -37,8 +29,8 @@ export interface SumScore {
|
|
|
37
29
|
}
|
|
38
30
|
|
|
39
31
|
const calculate = (
|
|
40
|
-
sumScoreVariable:
|
|
41
|
-
allVariables: Array<Pick<
|
|
32
|
+
sumScoreVariable: SumScoreVariableDto,
|
|
33
|
+
allVariables: Array<Pick<BVariable, "varId" | "numericValue" | "kind" | "label">>,
|
|
42
34
|
): SumScore => {
|
|
43
35
|
const legalValues: Array<number> = [...ALLOWED_VALUES];
|
|
44
36
|
|
|
@@ -66,7 +58,7 @@ const calculate = (
|
|
|
66
58
|
};
|
|
67
59
|
return result;
|
|
68
60
|
}
|
|
69
|
-
const value = maybeVariable.numericValue ??
|
|
61
|
+
const value = maybeVariable.numericValue ?? BVariable.MISSING;
|
|
70
62
|
const varLabel = maybeVariable.label;
|
|
71
63
|
const weight = scv.weight ?? 1;
|
|
72
64
|
const varId = maybeVariable.varId;
|
|
@@ -119,7 +111,7 @@ const calculate = (
|
|
|
119
111
|
|
|
120
112
|
return result;
|
|
121
113
|
};
|
|
122
|
-
const createVariable = (varId: string):
|
|
114
|
+
const createVariable = (varId: string): SumScoreVariableDto => {
|
|
123
115
|
return {
|
|
124
116
|
origin: "sum-score",
|
|
125
117
|
kind: "numeric-variable",
|