@media-quest/builder 0.0.27 → 0.0.29
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 +36 -32
- package/dist/public-api.js +53 -6
- package/dist/public-api.js.map +1 -1
- package/package.json +2 -2
- package/src/Builder-schema.ts +17 -4
- package/src/page/Builder-page-collection.spec.ts +10 -0
- package/src/page/Builder-page-collection.ts +18 -2
- package/src/page/Builder-page.spec.ts +15 -1
- package/src/page/Builder-page.ts +13 -1
- package/src/public-api.ts +1 -1
- package/src/sum-score/sum-score-variable.spec.ts +308 -253
- package/src/sum-score/sum-score-variable.ts +102 -98
- package/src/sum-score/sum-score.ts +6 -1
package/dist/public-api.d.ts
CHANGED
|
@@ -525,34 +525,6 @@ declare class TagActionManager {
|
|
|
525
525
|
getEngineActions(): ReadonlyArray<ExcludeByTagAction>;
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
interface SumScoreVariableDto {
|
|
529
|
-
id: SumScoreVariableID;
|
|
530
|
-
name: string;
|
|
531
|
-
description: string;
|
|
532
|
-
useAvg: boolean;
|
|
533
|
-
}
|
|
534
|
-
declare class SumScoreVariable extends BuilderObject<"builder-sum-score-variable", SumScoreVariableDto> {
|
|
535
|
-
readonly objectType = "builder-sum-score-variable";
|
|
536
|
-
readonly id: SumScoreVariableID;
|
|
537
|
-
private _useAvg;
|
|
538
|
-
private _name;
|
|
539
|
-
private _description;
|
|
540
|
-
private _error;
|
|
541
|
-
static readonly create: (data: {
|
|
542
|
-
name: string;
|
|
543
|
-
description: string;
|
|
544
|
-
useAvg: boolean;
|
|
545
|
-
}) => SumScoreVariable;
|
|
546
|
-
get hasErrors(): boolean;
|
|
547
|
-
static fromDto: (dto: SumScoreVariableDto) => SumScoreVariable;
|
|
548
|
-
private constructor();
|
|
549
|
-
toJson(): SumScoreVariableDto;
|
|
550
|
-
clone(): SumScoreVariableDto;
|
|
551
|
-
get name(): string;
|
|
552
|
-
get description(): string;
|
|
553
|
-
get useAvg(): boolean;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
528
|
type BuilderPageType = "info-page" | "question";
|
|
557
529
|
interface BuilderPageDto {
|
|
558
530
|
readonly id: PageID;
|
|
@@ -598,13 +570,10 @@ declare class BuilderPage extends BuilderObject<"builder-page", BuilderPageDto>
|
|
|
598
570
|
get pageType(): BuilderPageType;
|
|
599
571
|
get prefix(): PagePrefixValue;
|
|
600
572
|
set prefix(value: PagePrefixValue);
|
|
601
|
-
sumScoreVariableSet(sumScoreVariable: SumScoreVariable, weight: number): boolean;
|
|
602
|
-
sumScoreVariableUpdateData(variables: ReadonlyArray<SumScoreVariable>): void;
|
|
603
573
|
toJson(): BuilderPageDto;
|
|
604
574
|
clone(): BuilderPageDto;
|
|
605
575
|
get backgroundColor(): string;
|
|
606
576
|
set backgroundColor(color: string);
|
|
607
|
-
sumScoreVariableDelete(sumScoreVariableID: SumScoreVariableID): void;
|
|
608
577
|
}
|
|
609
578
|
|
|
610
579
|
interface BuilderTagDto {
|
|
@@ -626,6 +595,36 @@ declare class BuilderTag extends BuilderObject<"builder-tag", BuilderTagDto> {
|
|
|
626
595
|
toJson(): BuilderTagDto;
|
|
627
596
|
}
|
|
628
597
|
|
|
598
|
+
interface SumScoreVariableDto {
|
|
599
|
+
id: SumScoreVariableID;
|
|
600
|
+
name: string;
|
|
601
|
+
description: string;
|
|
602
|
+
useAvg: boolean;
|
|
603
|
+
}
|
|
604
|
+
declare class SumScoreVariable extends BuilderObject<"builder-sum-score-variable", SumScoreVariableDto> {
|
|
605
|
+
readonly objectType = "builder-sum-score-variable";
|
|
606
|
+
readonly id: SumScoreVariableID;
|
|
607
|
+
private _useAvg;
|
|
608
|
+
private _name;
|
|
609
|
+
private _description;
|
|
610
|
+
private _error;
|
|
611
|
+
private _usedIn;
|
|
612
|
+
get usedIn(): BuilderPage[];
|
|
613
|
+
static readonly create: (data: {
|
|
614
|
+
name: string;
|
|
615
|
+
description: string;
|
|
616
|
+
useAvg: boolean;
|
|
617
|
+
}) => SumScoreVariable;
|
|
618
|
+
get hasErrors(): boolean;
|
|
619
|
+
static fromDto: (dto: SumScoreVariableDto) => SumScoreVariable;
|
|
620
|
+
private constructor();
|
|
621
|
+
toJson(): SumScoreVariableDto;
|
|
622
|
+
clone(): SumScoreVariableDto;
|
|
623
|
+
get name(): string;
|
|
624
|
+
get description(): string;
|
|
625
|
+
get useAvg(): boolean;
|
|
626
|
+
}
|
|
627
|
+
|
|
629
628
|
/**
|
|
630
629
|
* Interface representing a code book question sum-score.
|
|
631
630
|
*
|
|
@@ -733,7 +732,9 @@ declare class BuilderSchema {
|
|
|
733
732
|
useAvg: boolean;
|
|
734
733
|
}): SumScoreVariable;
|
|
735
734
|
sumScoreVariableAddToPage(sumScoreVariable: SumScoreVariable, page: BuilderPage, weight: number): boolean;
|
|
735
|
+
private updateSumScoreRelations;
|
|
736
736
|
sumScoreVariableUpdate(id: SumScoreVariableID, data: Partial<SumScoreVariableDto>): boolean;
|
|
737
|
+
sumScoreVariableDeleteFromPage(pageId: PageID, sumScoreVariableId: SumScoreVariableID): void;
|
|
737
738
|
insertPage(page: BuilderPage, atIndex: number): boolean;
|
|
738
739
|
private insertPageAtIndex;
|
|
739
740
|
addRule(): BuilderRule;
|
|
@@ -775,6 +776,9 @@ interface SumScoreAnswer {
|
|
|
775
776
|
}
|
|
776
777
|
|
|
777
778
|
interface SumScore {
|
|
779
|
+
readonly sumScoreVariableId: SumScoreVariableID;
|
|
780
|
+
readonly name: string;
|
|
781
|
+
readonly description: string;
|
|
778
782
|
sumScore: number;
|
|
779
783
|
avg: number;
|
|
780
784
|
useAvg: boolean;
|
|
@@ -816,4 +820,4 @@ declare class TagCollection implements Iterable<BuilderTag> {
|
|
|
816
820
|
deleteAll(tags: Iterable<BuilderTag>): void;
|
|
817
821
|
}
|
|
818
822
|
|
|
819
|
-
export { type AudioFile, BuilderCondition, type BuilderConditionDto, BuilderConditionGroup, type BuilderConditionGroupDto, type BuilderMainImageDto, BuilderMainText, type BuilderMainTextDto, type BuilderMainVideoDto, BuilderOperator, BuilderOption, type BuilderOptionDto, BuilderPage, type BuilderPageDto, type BuilderPageType, BuilderQuestion, type BuilderQuestionDto, type BuilderQuestionType, BuilderRule, type BuilderRuleDto, BuilderSchema, type BuilderSchemaDto, BuilderTag, type BuilderTagDto, BuilderText, type BuilderTextDto, CodeBook, type CodeBookQuestionVariable, type Codebook, type CodebookPredefinedVariable, type CompilerOption, type CompilerOutput, ConditionGroupType, type ExcludeByPageAction, ExcludeByPageIdSelectItem, type ExcludeByTagAction, ExcludeByTagSelectItem, type ID, type ImageFile, JumpToActionManager, type JumpToPageAction, JumpToPageSelectItem, MultiSelectItem, OperatorSelectItem, OptionID, PageActionManager, PageID, PagePrefix, type PagePrefixValue, QuestionID, RuleCustomVariable, RuleInput, RuleOptionSelectItem, RuleQuestionVariable, type RuleVariable, RuleVariableOption, RuleVariableSelectItem, SchemaConfig, SchemaID, SchemaPrefix, type SchemaPrefixValue, SingleSelectItem, SumScore, type SumScoreAnswer, type SumScoreVariableDto, SumScoreVariableID, TagActionManager, TagCollection, TagID, TextID, VarID, type VideoFile, _CodeBook, createTypedIdSingleton };
|
|
823
|
+
export { type AudioFile, BuilderCondition, type BuilderConditionDto, BuilderConditionGroup, type BuilderConditionGroupDto, type BuilderMainImageDto, BuilderMainText, type BuilderMainTextDto, type BuilderMainVideoDto, BuilderOperator, BuilderOption, type BuilderOptionDto, BuilderPage, type BuilderPageDto, type BuilderPageType, BuilderQuestion, type BuilderQuestionDto, type BuilderQuestionType, BuilderRule, type BuilderRuleDto, BuilderSchema, type BuilderSchemaDto, BuilderTag, type BuilderTagDto, BuilderText, type BuilderTextDto, CodeBook, type CodeBookQuestionVariable, type Codebook, type CodebookPredefinedVariable, type CompilerOption, type CompilerOutput, ConditionGroupType, type ExcludeByPageAction, ExcludeByPageIdSelectItem, type ExcludeByTagAction, ExcludeByTagSelectItem, type ID, type ImageFile, JumpToActionManager, type JumpToPageAction, JumpToPageSelectItem, MultiSelectItem, OperatorSelectItem, OptionID, PageActionManager, PageID, PagePrefix, type PagePrefixValue, QuestionID, RuleCustomVariable, RuleInput, RuleOptionSelectItem, RuleQuestionVariable, type RuleVariable, RuleVariableOption, RuleVariableSelectItem, SchemaConfig, SchemaID, SchemaPrefix, type SchemaPrefixValue, SingleSelectItem, SumScore, type SumScoreAnswer, SumScoreVariable, type SumScoreVariableDto, SumScoreVariableID, TagActionManager, TagCollection, TagID, TextID, VarID, type VideoFile, _CodeBook, createTypedIdSingleton };
|
package/dist/public-api.js
CHANGED
|
@@ -54,6 +54,7 @@ __export(public_api_exports, {
|
|
|
54
54
|
SchemaPrefix: () => SchemaPrefix,
|
|
55
55
|
SingleSelectItem: () => SingleSelectItem,
|
|
56
56
|
SumScore: () => SumScore,
|
|
57
|
+
SumScoreVariable: () => SumScoreVariable,
|
|
57
58
|
SumScoreVariableID: () => SumScoreVariableID,
|
|
58
59
|
TagActionManager: () => TagActionManager,
|
|
59
60
|
TagCollection: () => TagCollection,
|
|
@@ -1309,6 +1310,7 @@ var BuilderPage = class _BuilderPage extends BuilderObject {
|
|
|
1309
1310
|
set prefix(value) {
|
|
1310
1311
|
this._prefix.value = value;
|
|
1311
1312
|
}
|
|
1313
|
+
/** @internal */
|
|
1312
1314
|
sumScoreVariableSet(sumScoreVariable, weight) {
|
|
1313
1315
|
const { id, name, description } = sumScoreVariable;
|
|
1314
1316
|
this._includedInSumScores.set(sumScoreVariable.id, {
|
|
@@ -1319,7 +1321,8 @@ var BuilderPage = class _BuilderPage extends BuilderObject {
|
|
|
1319
1321
|
});
|
|
1320
1322
|
return true;
|
|
1321
1323
|
}
|
|
1322
|
-
|
|
1324
|
+
/** @internal */
|
|
1325
|
+
updateRelationShips(variables) {
|
|
1323
1326
|
variables.forEach((v) => {
|
|
1324
1327
|
const sumScoreEntry = this._includedInSumScores.get(v.id);
|
|
1325
1328
|
if (sumScoreEntry) {
|
|
@@ -1372,6 +1375,15 @@ var BuilderPage = class _BuilderPage extends BuilderObject {
|
|
|
1372
1375
|
this._backgroundColor = color;
|
|
1373
1376
|
}
|
|
1374
1377
|
}
|
|
1378
|
+
/**
|
|
1379
|
+
* @internal
|
|
1380
|
+
*/
|
|
1381
|
+
_isIncludedInSumScore(sumScoreId) {
|
|
1382
|
+
return this._includedInSumScores.has(sumScoreId);
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* @internal
|
|
1386
|
+
*/
|
|
1375
1387
|
sumScoreVariableDelete(sumScoreVariableID) {
|
|
1376
1388
|
this._includedInSumScores.delete(sumScoreVariableID);
|
|
1377
1389
|
}
|
|
@@ -1958,7 +1970,11 @@ var SumScoreVariable = class _SumScoreVariable extends BuilderObject {
|
|
|
1958
1970
|
_name = "";
|
|
1959
1971
|
_description = "";
|
|
1960
1972
|
_error = "";
|
|
1973
|
+
_usedIn = [];
|
|
1961
1974
|
// private _basedOn = new Map<pageId: Page>()
|
|
1975
|
+
get usedIn() {
|
|
1976
|
+
return [...this._usedIn];
|
|
1977
|
+
}
|
|
1962
1978
|
// private _basedOn: Array<{ varId: string }> = [];
|
|
1963
1979
|
static create = (data) => {
|
|
1964
1980
|
const id = SumScoreVariableID.create();
|
|
@@ -2010,6 +2026,10 @@ var SumScoreVariable = class _SumScoreVariable extends BuilderObject {
|
|
|
2010
2026
|
_setError(error) {
|
|
2011
2027
|
this._error = error;
|
|
2012
2028
|
}
|
|
2029
|
+
/** @internal - used by sum-score-variable-collection */
|
|
2030
|
+
_setUsedInPages(pages) {
|
|
2031
|
+
this._usedIn = [...pages];
|
|
2032
|
+
}
|
|
2013
2033
|
get name() {
|
|
2014
2034
|
return this._name;
|
|
2015
2035
|
}
|
|
@@ -2269,9 +2289,14 @@ var BuilderPageCollection = class _BuilderPageCollection {
|
|
|
2269
2289
|
maybePage.sumScoreVariableSet(sumScoreVariable, weight);
|
|
2270
2290
|
return true;
|
|
2271
2291
|
}
|
|
2272
|
-
|
|
2292
|
+
updateRelationShips(context) {
|
|
2293
|
+
const { sumScoreVariables } = context;
|
|
2273
2294
|
this._all.forEach((p) => {
|
|
2274
|
-
p.
|
|
2295
|
+
p.updateRelationShips(context.sumScoreVariables);
|
|
2296
|
+
});
|
|
2297
|
+
sumScoreVariables.forEach((v) => {
|
|
2298
|
+
const usedInPages = this._all.filter((p) => p._isIncludedInSumScore(v.id));
|
|
2299
|
+
v._setUsedInPages(usedInPages);
|
|
2275
2300
|
});
|
|
2276
2301
|
}
|
|
2277
2302
|
sumScoreVariableDelete(sumScoreVariableID) {
|
|
@@ -2279,6 +2304,13 @@ var BuilderPageCollection = class _BuilderPageCollection {
|
|
|
2279
2304
|
p.sumScoreVariableDelete(sumScoreVariableID);
|
|
2280
2305
|
});
|
|
2281
2306
|
}
|
|
2307
|
+
sumScoreVariableDeleteFromPage(pageId, sumScoreVariableId) {
|
|
2308
|
+
const maybePage = this.getPageById(pageId);
|
|
2309
|
+
if (!maybePage)
|
|
2310
|
+
return false;
|
|
2311
|
+
maybePage.sumScoreVariableDelete(sumScoreVariableId);
|
|
2312
|
+
return true;
|
|
2313
|
+
}
|
|
2282
2314
|
};
|
|
2283
2315
|
|
|
2284
2316
|
// src/Builder-schema.ts
|
|
@@ -2336,6 +2368,7 @@ var BuilderSchema = class _BuilderSchema {
|
|
|
2336
2368
|
const rulesDto = dto.rules ?? [];
|
|
2337
2369
|
const ruleInput = schema.getRuleInput();
|
|
2338
2370
|
schema._rules = rulesDto.map((r) => BuilderRule.fromDto(r, ruleInput));
|
|
2371
|
+
schema.updateSumScoreRelations();
|
|
2339
2372
|
return schema;
|
|
2340
2373
|
}
|
|
2341
2374
|
toJson() {
|
|
@@ -2367,13 +2400,23 @@ var BuilderSchema = class _BuilderSchema {
|
|
|
2367
2400
|
return variable;
|
|
2368
2401
|
}
|
|
2369
2402
|
sumScoreVariableAddToPage(sumScoreVariable, page, weight) {
|
|
2370
|
-
|
|
2403
|
+
const added = this._pageCollection.addSumScoreVariable(sumScoreVariable, page.id, weight);
|
|
2404
|
+
this.updateSumScoreRelations();
|
|
2405
|
+
return added;
|
|
2406
|
+
}
|
|
2407
|
+
updateSumScoreRelations() {
|
|
2408
|
+
const sumScoreVariables = this._sumScoreCollection.asArray();
|
|
2409
|
+
this._pageCollection.updateRelationShips({ sumScoreVariables });
|
|
2371
2410
|
}
|
|
2372
2411
|
sumScoreVariableUpdate(id, data) {
|
|
2373
2412
|
const didUpdate = this._sumScoreCollection._updateOne(id, data);
|
|
2374
|
-
this.
|
|
2413
|
+
this.updateSumScoreRelations();
|
|
2375
2414
|
return didUpdate;
|
|
2376
2415
|
}
|
|
2416
|
+
sumScoreVariableDeleteFromPage(pageId, sumScoreVariableId) {
|
|
2417
|
+
this._pageCollection.sumScoreVariableDeleteFromPage(pageId, sumScoreVariableId);
|
|
2418
|
+
this.updateSumScoreRelations();
|
|
2419
|
+
}
|
|
2377
2420
|
insertPage(page, atIndex) {
|
|
2378
2421
|
return this.insertPageAtIndex(page, atIndex);
|
|
2379
2422
|
}
|
|
@@ -2485,7 +2528,7 @@ var BuilderSchema = class _BuilderSchema {
|
|
|
2485
2528
|
sumScoreVariableDelete(id) {
|
|
2486
2529
|
const didDelete = this._sumScoreCollection._deleteVariable(id);
|
|
2487
2530
|
const sumScoreVariables = [...this._sumScoreCollection];
|
|
2488
|
-
this._pageCollection.
|
|
2531
|
+
this._pageCollection.updateRelationShips({ sumScoreVariables });
|
|
2489
2532
|
this._pageCollection.sumScoreVariableDelete(id);
|
|
2490
2533
|
return didDelete;
|
|
2491
2534
|
}
|
|
@@ -2620,6 +2663,9 @@ var calculate = (sumScoreVariable, basedOnVariables, answers) => {
|
|
|
2620
2663
|
});
|
|
2621
2664
|
const avg = sumScore / includedAnswerCount;
|
|
2622
2665
|
const result = {
|
|
2666
|
+
sumScoreVariableId: sumScoreVariable.id,
|
|
2667
|
+
name: sumScoreVariable.name,
|
|
2668
|
+
description: sumScoreVariable.description,
|
|
2623
2669
|
avg,
|
|
2624
2670
|
useAvg,
|
|
2625
2671
|
includedAnswerCount,
|
|
@@ -2684,6 +2730,7 @@ var SumScore = {
|
|
|
2684
2730
|
SchemaPrefix,
|
|
2685
2731
|
SingleSelectItem,
|
|
2686
2732
|
SumScore,
|
|
2733
|
+
SumScoreVariable,
|
|
2687
2734
|
SumScoreVariableID,
|
|
2688
2735
|
TagActionManager,
|
|
2689
2736
|
TagCollection,
|