@media-quest/builder 0.0.38 → 0.0.40
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/public-api.d.ts +82 -99
- package/dist/public-api.js +36 -101
- package/dist/public-api.js.map +1 -1
- package/package.json +29 -29
- package/src/{theme → ARKIV}/button-bar/button-text-utils.ts +233 -233
- package/src/{theme → ARKIV}/button-bar/text-utils.spec.ts +105 -105
- package/src/Builder-option.ts +78 -62
- package/src/Builder-question.ts +98 -98
- package/src/Builder-schema.spec.ts +348 -348
- package/src/Builder-schema.ts +308 -306
- package/src/builder-compiler.ts +14 -20
- package/src/code-book/codebook-variable.ts +27 -27
- package/src/code-book/codebook.ts +89 -89
- package/src/media-files.ts +28 -32
- package/src/page/Builder-page-collection.spec.ts +219 -219
- package/src/page/Builder-page-collection.ts +129 -129
- package/src/page/Builder-page.spec.ts +177 -177
- package/src/page/Builder-page.ts +250 -250
- package/src/primitives/ID.ts +135 -135
- package/src/public-api.ts +29 -30
- package/src/rulebuilder/RuleAction.ts +105 -105
- package/src/schema-config.ts +25 -26
- package/src/sum-score/sum-score-variable-collection.spec.ts +68 -68
- package/src/sum-score/sum-score-variable-collection.ts +101 -101
- package/src/sum-score/sum-score-variable.ts +0 -1
- package/src/sum-score/sum-score.ts +166 -167
- package/src/tag/BuilderTag.ts +45 -45
- package/src/tag/Tag-Collection.ts +53 -53
- package/src/theme/Default-theme.ts +173 -188
- package/src/theme/IDefault-theme.ts +125 -125
- package/src/theme/ThemeCompiler.ts +10 -11
- package/src/theme/default-theme-compiler.spec.ts +31 -31
- package/src/theme/default-theme-compiler.ts +655 -652
- package/src/theme/icon-urls.ts +29 -29
- package/src/theme/icons.ts +117 -117
- package/src/theme/theme-utils.spec.ts +52 -52
- package/src/theme/theme-utils.ts +56 -56
- package/src/theme/theme2.ts +388 -386
- package/tsconfig.json +19 -19
- package/src/Builder-schema-dto.spec.ts +0 -155
- package/src/Builder-schema-dto.ts +0 -86
package/src/Builder-schema.ts
CHANGED
|
@@ -1,306 +1,308 @@
|
|
|
1
|
-
import type { BuilderPageType } from "./page/Builder-page";
|
|
2
|
-
import { BuilderPage } from "./page/Builder-page";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
const U = DUtil;
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
readonly
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
predefinedVariables
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this._rules =
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.
|
|
303
|
-
this.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
1
|
+
import type { BuilderPageDto, BuilderPageType } from "./page/Builder-page";
|
|
2
|
+
import { BuilderPage } from "./page/Builder-page";
|
|
3
|
+
import type {
|
|
4
|
+
BuilderRuleDto,
|
|
5
|
+
ExcludeByPageAction,
|
|
6
|
+
ExcludeByTagAction,
|
|
7
|
+
JumpToPageAction,
|
|
8
|
+
RuleCustomVariable,
|
|
9
|
+
} from "./rulebuilder";
|
|
10
|
+
import { BuilderRule, RuleInput } from "./rulebuilder";
|
|
11
|
+
import type { RuleQuestionVariable } from "./rulebuilder/RuleVariable";
|
|
12
|
+
import type { BuilderTagDto } from "./tag/BuilderTag";
|
|
13
|
+
import { BuilderTag } from "./tag/BuilderTag";
|
|
14
|
+
import { DefaultThemeCompiler } from "./theme/default-theme-compiler";
|
|
15
|
+
import { ImageFile } from "./media-files";
|
|
16
|
+
import { DUtil } from "@media-quest/engine";
|
|
17
|
+
import { PagePrefix } from "./primitives/page-prefix";
|
|
18
|
+
import { SchemaPrefix, SchemaPrefixValue } from "./primitives/schema-prefix";
|
|
19
|
+
import { CodeBook } from "./code-book/codebook";
|
|
20
|
+
import { CodebookPredefinedVariable } from "./code-book/codebook-variable";
|
|
21
|
+
import { SchemaConfig } from "./schema-config";
|
|
22
|
+
import { CompilerOption, CompilerOutput } from "./builder-compiler";
|
|
23
|
+
|
|
24
|
+
import { SumScoreVariable, SumScoreVariableDto } from "./sum-score/sum-score-variable";
|
|
25
|
+
import { PageID, SchemaID, SumScoreVariableID } from "./primitives/ID";
|
|
26
|
+
import { SumScoreVariableCollection } from "./sum-score/sum-score-variable-collection";
|
|
27
|
+
import { TagCollection } from "./tag/Tag-Collection";
|
|
28
|
+
import { BuilderPageCollection } from "./page/Builder-page-collection";
|
|
29
|
+
|
|
30
|
+
const U = DUtil;
|
|
31
|
+
|
|
32
|
+
export interface BuilderSchemaDto {
|
|
33
|
+
readonly id: SchemaID;
|
|
34
|
+
readonly prefix: SchemaPrefixValue;
|
|
35
|
+
readonly mainImage: ImageFile | false;
|
|
36
|
+
readonly backgroundColor: string;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly pages: ReadonlyArray<BuilderPageDto>;
|
|
39
|
+
readonly baseHeight: number;
|
|
40
|
+
readonly baseWidth: number;
|
|
41
|
+
readonly predefinedVariables?: Array<CodebookPredefinedVariable>;
|
|
42
|
+
readonly sumScoreVariables?: ReadonlyArray<SumScoreVariableDto>;
|
|
43
|
+
readonly rules: ReadonlyArray<BuilderRuleDto>;
|
|
44
|
+
readonly tags: ReadonlyArray<BuilderTagDto>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class BuilderSchema {
|
|
48
|
+
readonly prefix: SchemaPrefix;
|
|
49
|
+
public readonly compiler = new DefaultThemeCompiler();
|
|
50
|
+
|
|
51
|
+
baseHeight = 1300;
|
|
52
|
+
baseWidth = 1024;
|
|
53
|
+
backgroundColor = "#000000";
|
|
54
|
+
private readonly _pageCollection: BuilderPageCollection;
|
|
55
|
+
mainImage: ImageFile | false = false;
|
|
56
|
+
predefinedVariables: CodebookPredefinedVariable[] = [];
|
|
57
|
+
private _rules: BuilderRule[] = [];
|
|
58
|
+
private readonly _sumScoreCollection;
|
|
59
|
+
get rules(): ReadonlyArray<BuilderRule> {
|
|
60
|
+
return [...this._rules];
|
|
61
|
+
}
|
|
62
|
+
get pages(): ReadonlyArray<BuilderPage> {
|
|
63
|
+
return [...this._pageCollection];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get sumScoreVariables(): ReadonlyArray<SumScoreVariable> {
|
|
67
|
+
return [...this._sumScoreCollection];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// get prefix(): SchemaPrefixValue {
|
|
71
|
+
// return this._prefix.value;
|
|
72
|
+
// }
|
|
73
|
+
|
|
74
|
+
private readonly _tagCollection: TagCollection = TagCollection.create();
|
|
75
|
+
get tags(): ReadonlyArray<BuilderTag> {
|
|
76
|
+
return [...this._tagCollection];
|
|
77
|
+
}
|
|
78
|
+
public static create(id: SchemaID, name: string, prefix: SchemaPrefixValue) {
|
|
79
|
+
const schemaPrefix = SchemaPrefix.castOrCreateRandom(prefix);
|
|
80
|
+
return new BuilderSchema(id, name, schemaPrefix);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public static fromJson(dto: BuilderSchemaDto): BuilderSchema {
|
|
84
|
+
const schemaPrefix = SchemaPrefix.castOrCreateRandom(dto.prefix);
|
|
85
|
+
const schema = new BuilderSchema(dto.id, dto.name, schemaPrefix);
|
|
86
|
+
const sumScoreVariables = dto.sumScoreVariables ? [...dto.sumScoreVariables] : [];
|
|
87
|
+
const pagesDto = Array.isArray(dto.pages) ? dto.pages : [];
|
|
88
|
+
|
|
89
|
+
// Init collections.
|
|
90
|
+
schema._tagCollection.init(dto.tags);
|
|
91
|
+
schema._sumScoreCollection.init(sumScoreVariables);
|
|
92
|
+
|
|
93
|
+
schema.backgroundColor = dto.backgroundColor;
|
|
94
|
+
schema.baseHeight = dto.baseHeight;
|
|
95
|
+
schema.baseWidth = dto.baseWidth;
|
|
96
|
+
schema._pageCollection._init(pagesDto);
|
|
97
|
+
schema.predefinedVariables = dto.predefinedVariables ?? [];
|
|
98
|
+
schema.backgroundColor = dto.backgroundColor;
|
|
99
|
+
schema.mainImage = dto.mainImage ?? false;
|
|
100
|
+
const rulesDto = dto.rules ?? [];
|
|
101
|
+
const ruleInput = schema.getRuleInput();
|
|
102
|
+
schema._rules = rulesDto.map((r) => BuilderRule.fromDto(r, ruleInput));
|
|
103
|
+
|
|
104
|
+
schema.updateSumScoreRelations();
|
|
105
|
+
return schema;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
toJson(): BuilderSchemaDto {
|
|
109
|
+
const pages = this._pageCollection.toJson();
|
|
110
|
+
const tags = this._tagCollection.toJson();
|
|
111
|
+
const rules = this._rules.map((rule) => rule.toJson());
|
|
112
|
+
const sumScoreVariables = this._sumScoreCollection.toJson();
|
|
113
|
+
const dto: BuilderSchemaDto = {
|
|
114
|
+
backgroundColor: this.backgroundColor,
|
|
115
|
+
baseHeight: this.baseHeight,
|
|
116
|
+
baseWidth: this.baseWidth,
|
|
117
|
+
id: this.id,
|
|
118
|
+
name: this.name,
|
|
119
|
+
pages,
|
|
120
|
+
rules,
|
|
121
|
+
tags,
|
|
122
|
+
predefinedVariables: this.predefinedVariables,
|
|
123
|
+
sumScoreVariables,
|
|
124
|
+
mainImage: this.mainImage,
|
|
125
|
+
prefix: this.prefix.value,
|
|
126
|
+
};
|
|
127
|
+
return dto;
|
|
128
|
+
}
|
|
129
|
+
private constructor(
|
|
130
|
+
public readonly id: SchemaID,
|
|
131
|
+
public name: string,
|
|
132
|
+
prefix: SchemaPrefix,
|
|
133
|
+
) {
|
|
134
|
+
this.prefix = prefix;
|
|
135
|
+
this._sumScoreCollection = SumScoreVariableCollection.create([]);
|
|
136
|
+
this._pageCollection = BuilderPageCollection.create([]);
|
|
137
|
+
// this
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
addPage(type: BuilderPageType, atIndex = -1): BuilderPage {
|
|
141
|
+
return this._pageCollection.add(type, atIndex);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
sumScoreVariableCreate(options: { name: string; description: string; useAvg: boolean }) {
|
|
145
|
+
// TODO VALIDATE.
|
|
146
|
+
// this._sumVariables.push({ ...variable });
|
|
147
|
+
const variable = this._sumScoreCollection.addNew(options);
|
|
148
|
+
|
|
149
|
+
return variable;
|
|
150
|
+
}
|
|
151
|
+
sumScoreVariableAddToPage(sumScoreVariable: SumScoreVariable, page: BuilderPage, weight: number) {
|
|
152
|
+
const added = this._pageCollection.addSumScoreVariable(sumScoreVariable, page.id, weight);
|
|
153
|
+
this.updateSumScoreRelations();
|
|
154
|
+
return added;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private updateSumScoreRelations() {
|
|
158
|
+
const sumScoreVariables = this._sumScoreCollection.asArray();
|
|
159
|
+
this._pageCollection.updateRelationShips({ sumScoreVariables });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
sumScoreVariableUpdate(id: SumScoreVariableID, data: Partial<SumScoreVariableDto>) {
|
|
163
|
+
const didUpdate = this._sumScoreCollection._updateOne(id, data);
|
|
164
|
+
this.updateSumScoreRelations();
|
|
165
|
+
return didUpdate;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
sumScoreVariableDeleteFromPage(pageId: PageID, sumScoreVariableId: SumScoreVariableID) {
|
|
169
|
+
this._pageCollection.sumScoreVariableDeleteFromPage(pageId, sumScoreVariableId);
|
|
170
|
+
this.updateSumScoreRelations();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
insertPage(page: BuilderPage, atIndex: number): boolean {
|
|
174
|
+
return this.insertPageAtIndex(page, atIndex);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private insertPageAtIndex(page: BuilderPage, atIndex: number) {
|
|
178
|
+
return this._pageCollection.insertPage(page, atIndex);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
addRule() {
|
|
182
|
+
const input = this.getRuleInput();
|
|
183
|
+
const count = this._rules.length + 1;
|
|
184
|
+
const name = "Rule-number: " + count;
|
|
185
|
+
const rule = BuilderRule.fromDto(
|
|
186
|
+
{
|
|
187
|
+
conditions: [],
|
|
188
|
+
type: "all",
|
|
189
|
+
name,
|
|
190
|
+
excludeTags: [],
|
|
191
|
+
jumpToPage: false,
|
|
192
|
+
excludePages: [],
|
|
193
|
+
},
|
|
194
|
+
input,
|
|
195
|
+
);
|
|
196
|
+
this._rules.push(rule);
|
|
197
|
+
return rule;
|
|
198
|
+
}
|
|
199
|
+
deleteRule(rule: BuilderRule) {
|
|
200
|
+
this._rules = this._rules.filter((r) => r !== rule);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
movePage(page: BuilderPage, toIndex: number): boolean {
|
|
204
|
+
return this._pageCollection.movePage(page, toIndex);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
deletePage(page: BuilderPage): boolean {
|
|
208
|
+
return this._pageCollection.deleteById(page.id);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
reevaluateRules() {
|
|
212
|
+
console.log("Reevaluationg rulesInput");
|
|
213
|
+
const input = this.getRuleInput();
|
|
214
|
+
const rulesDto = this._rules.map((r) => r.toJson());
|
|
215
|
+
this._rules = rulesDto.map((dto) => BuilderRule.fromDto(dto, input));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
getRuleInput(): RuleInput {
|
|
219
|
+
const qVars: RuleQuestionVariable[] = [];
|
|
220
|
+
const cVars: RuleCustomVariable[] = [];
|
|
221
|
+
const pageIdActions: ExcludeByPageAction[] = [];
|
|
222
|
+
const tagActions: ExcludeByTagAction[] = this.tags.map((t) => {
|
|
223
|
+
const tag = t.tagText;
|
|
224
|
+
const pageCount = this._pageCollection.pages.reduce((count, curr) => {
|
|
225
|
+
return curr.tags.includes(tag) ? count + 1 : count;
|
|
226
|
+
}, 0);
|
|
227
|
+
const excludeByTagDto: ExcludeByTagAction = {
|
|
228
|
+
kind: "exclude-by-tag",
|
|
229
|
+
pageCount,
|
|
230
|
+
tag,
|
|
231
|
+
description: t.tagDescription,
|
|
232
|
+
};
|
|
233
|
+
return excludeByTagDto;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const jumpActions: JumpToPageAction[] = [];
|
|
237
|
+
|
|
238
|
+
this._pageCollection.pages.forEach((page, index) => {
|
|
239
|
+
const pageVariables = page.getQuestionVariables(this.prefix, index);
|
|
240
|
+
qVars.push(...pageVariables);
|
|
241
|
+
const mainText = page.mainText.text;
|
|
242
|
+
const pagePrefix = page.prefix;
|
|
243
|
+
const jumpAction: JumpToPageAction = {
|
|
244
|
+
kind: "jump-to-page",
|
|
245
|
+
pageId: page.id,
|
|
246
|
+
pagePrefix,
|
|
247
|
+
pageNumber: index,
|
|
248
|
+
mainText: page.mainText.text,
|
|
249
|
+
};
|
|
250
|
+
const excludePageAction: ExcludeByPageAction = {
|
|
251
|
+
kind: "exclude-by-pageId",
|
|
252
|
+
pageId: page.id,
|
|
253
|
+
pagePrefix,
|
|
254
|
+
pageNumber: index,
|
|
255
|
+
mainText,
|
|
256
|
+
};
|
|
257
|
+
jumpActions.push(jumpAction);
|
|
258
|
+
pageIdActions.push(excludePageAction);
|
|
259
|
+
});
|
|
260
|
+
const ruleInput = new RuleInput(qVars, cVars, pageIdActions, tagActions, jumpActions);
|
|
261
|
+
|
|
262
|
+
return ruleInput;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
deleteTags(tags: ReadonlyArray<BuilderTag>) {
|
|
266
|
+
this._tagCollection.deleteAll(tags);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
addTag(builderTag: BuilderTag) {
|
|
270
|
+
this._tagCollection.add(builderTag);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
compile(
|
|
274
|
+
options: CompilerOption = { blockAutoplayQuestion: false, blockAutoplayVideo: false },
|
|
275
|
+
): CompilerOutput {
|
|
276
|
+
// const moduleDto = this.toJson();
|
|
277
|
+
const builderSchema = BuilderSchema.fromJson(this.toJson());
|
|
278
|
+
|
|
279
|
+
// Overriding the
|
|
280
|
+
builderSchema._pageCollection.pages.forEach((p) => {
|
|
281
|
+
if (options.blockAutoplayQuestion) {
|
|
282
|
+
p.mainText.autoplay = false;
|
|
283
|
+
}
|
|
284
|
+
if (options.blockAutoplayVideo && p.mainMedia) {
|
|
285
|
+
if (p.mainMedia.kind === "main-video") {
|
|
286
|
+
// TODO autoplay as boolean, so that we know if video is optional or required when override.
|
|
287
|
+
p.mainMedia.mode = "optional";
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
const moduleDto = builderSchema.toJson();
|
|
292
|
+
// const imp = new DefaultThemeCompiler();
|
|
293
|
+
|
|
294
|
+
const codebook = CodeBook.fromSchema(moduleDto);
|
|
295
|
+
const schema = this.compiler.compile(moduleDto);
|
|
296
|
+
const schemaConfig = SchemaConfig.fromSchema(moduleDto);
|
|
297
|
+
const output: CompilerOutput = { codebook, schema, schemaConfig };
|
|
298
|
+
return output;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
sumScoreVariableDelete(id: SumScoreVariableID) {
|
|
302
|
+
const didDelete = this._sumScoreCollection._deleteVariable(id);
|
|
303
|
+
const sumScoreVariables = [...this._sumScoreCollection];
|
|
304
|
+
this._pageCollection.updateRelationShips({ sumScoreVariables });
|
|
305
|
+
this._pageCollection.sumScoreVariableDelete(id);
|
|
306
|
+
return didDelete;
|
|
307
|
+
}
|
|
308
|
+
}
|