Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Commit

Permalink
Merge branch 'fix/issue-170' into fix/issue-111
Browse files Browse the repository at this point in the history
  • Loading branch information
ppratikcr7 committed Mar 11, 2021
2 parents 733effc + 73125ba commit ad5e78d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
| translate
"
formControlName="assignmentWeight"

/>
</mat-form-field>
</mat-cell>
Expand Down Expand Up @@ -127,7 +128,18 @@
+ {{ 'home.new-experiment.design.add-condition.text' | translate }}
</button>
</ng-container>

<!-- applyEqualWeight -->
<mat-card class="result">
<mat-card-content>
<section class="example-section">
<mat-checkbox
class="example-margin"
(change)="applyEqualWeight($event)">
Equal Weight Assignment
</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 @@ -244,6 +244,24 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy {
return partition;
}

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

if(event.checked){
const len = conditions.controls.length;
conditions.controls.forEach( control => {
control.get('assignmentWeight').setValue((100.0/len).toFixed(2));
});
}
else {
conditions.controls.forEach( control => {
control.get('assignmentWeight').setValue(0);
});
}

}


get condition(): FormArray {
return this.experimentDesignForm.get('conditions') as FormArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ 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;
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
Binary file modified projects/abtesting/src/favicon.ico
Binary file not shown.

0 comments on commit ad5e78d

Please sign in to comment.