@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.
@@ -1,6 +1,5 @@
1
- export interface MqVariable {
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 MqVariable = {
50
+ export const BVariable = {
51
51
  MISSING,
52
52
  } as const;
53
53
 
54
- export interface PageVariable extends MqVariable {
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 MqVariable {
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 { MqVariable } from "./mq-variable";
2
- import { SumScoreVariable, SumScore } from "./sum-score";
3
- const createVariable = (value: number): MqVariable => {
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: MqVariable; weight?: number }>) => {
14
- const sumVar1: SumScoreVariable = {
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 { MqVariable } from "./mq-variable";
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: SumScoreVariable,
41
- allVariables: Array<Pick<MqVariable, "varId" | "numericValue" | "kind" | "label">>,
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 ?? MqVariable.MISSING;
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): SumScoreVariable => {
114
+ const createVariable = (varId: string): SumScoreVariableDto => {
123
115
  return {
124
116
  origin: "sum-score",
125
117
  kind: "numeric-variable",