Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@
</button>
</ng-container>

<!-- apply equal condition weights -->
<mat-card>
<mat-card-content>
<section>
<mat-checkbox
class="ft-14-700"
color="primary"
(change)="applyEqualWeight($event)">
{{ 'home.new-experiment.design.equal-assignment-weights.text' | translate }}
</mat-checkbox>
</section>
</mat-card-content>
</mat-card>

<!-- Partition Table -->
<ng-container>
<mat-table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
color: var(--blue);
}

mat-checkbox {
&.mat-checkbox-checked {
color: var(--blue);
}
}

.partition-table {
margin-top: 30px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy {
partitionErrorMessages = [];
partitionErrorMessagesSub: Subscription;

previousAssignmentWeightValues = [];

conditionDisplayedColumns = [ 'conditionNumber', 'conditionCode', 'assignmentWeight', 'description', 'removeCondition'];
partitionDisplayedColumns = ['partitionNumber', 'expPoint', 'expId', 'removePartition'];
constructor(
Expand Down Expand Up @@ -244,6 +246,24 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy {
return partition;
}

applyEqualWeight(event) {
const conditions = this.experimentDesignForm.get('conditions') as FormArray;

if(event.checked) {
const len = conditions.controls.length;
conditions.controls.forEach( control => {
this.previousAssignmentWeightValues.push(control.get('assignmentWeight').value);
control.get('assignmentWeight').setValue((100.0/len).toFixed(2));
});
}
else {
conditions.controls.forEach( (control, index) => {
control.get('assignmentWeight').setValue(this.previousAssignmentWeightValues[index]);
});
this.previousAssignmentWeightValues = [];
}
}

get condition(): FormArray {
return this.experimentDesignForm.get('conditions') as FormArray;
}
Expand All @@ -265,9 +285,8 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy {
return false;
}


ngOnDestroy() {
this.allPartitionsSub.unsubscribe();
this.partitionErrorMessagesSub.unsubscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export class ExperimentFormValidators {
if (conditions.length < 2) {
return { conditionCountError: true };
} else if (conditions.length >= 2) {
let sumOfAssignmentWeights = 0;
conditions.forEach(condition => (sumOfAssignmentWeights += parseInt(condition.assignmentWeight, 10)));
return sumOfAssignmentWeights !== 100 ? { assignmentWightsSumError: true } : null;
// handling sum of decimal values for assignment weights:
let sumOfAssignmentWeights = 0.0;
conditions.forEach(condition => (sumOfAssignmentWeights += parseFloat(condition.assignmentWeight)));
return Math.ceil(sumOfAssignmentWeights) !== 100.0 ? { assignmentWightsSumError: true } : null;
}
if (partitions.length < 1) {
return { partitionCountError: true };
Expand Down
1 change: 1 addition & 0 deletions projects/abtesting/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"home.new-experiment.design.partition-id.placeholder.text": "ID",
"home.new-experiment.design.add-experiment-partition.text": "Add Experiment Site",
"home.new-experiment.design.assignment-weight-validation.text": "Assignment weights' sum must be 100",
"home.new-experiment.design.equal-assignment-weights.text": "Equal Weight Assignment",
"home.new-experiment.design.assignment-partition-error-1.text": " partition data is already exist",
"home.new-experiment.design.assignment-partition-error-2.text": " partition data are already exist",
"home.new-experiment.design.assignment-partition-error-3.text": " partition data is duplicate",
Expand Down