diff --git a/src/app/creator-choice-content/creator-choice-content.component.html b/src/app/creator-choice-content/creator-choice-content.component.html index b7554136c8617e2f717411103e45f6790daef4fd..f68229833627d09c1935c7ffc4b7b6a94f9c6bef 100644 --- a/src/app/creator-choice-content/creator-choice-content.component.html +++ b/src/app/creator-choice-content/creator-choice-content.component.html @@ -13,7 +13,7 @@ <mat-header-cell *matHeaderCellDef>Answer</mat-header-cell> <mat-cell *matCellDef="let answer"> <!-- ToDo: Check ngModel --> - <mat-checkbox color="primary" [(ngModel)]="answer.correct" name="answer">{{ answer.answerOption.label }} is {{ answer.correct }}</mat-checkbox> + <mat-checkbox color="primary" [checked]="answer.correct" [(ngModel)]="answer.correct" name="answer">{{ answer.answerOption.label }} is {{ answer.correct }}</mat-checkbox> </mat-cell> </ng-container> @@ -40,7 +40,7 @@ </mat-form-field> <div fxLayout="column" fxLayoutAlign="center"> <button mat-button type="button" - (click)="addAnswer(answerIsCorrect.value, answerLabel.value, answerPoints.value)"> + (click)="addAnswer(answerIsCorrect.checked, answerLabel.value, answerPoints.value)"> Add Answer </button> </div> diff --git a/src/app/creator-choice-content/creator-choice-content.component.ts b/src/app/creator-choice-content/creator-choice-content.component.ts index 50ddc36b14d51b308707e5628c47d7e9bdba141e..25ddb4f6c63bfc1300bcd306fc37bc63f9379641 100644 --- a/src/app/creator-choice-content/creator-choice-content.component.ts +++ b/src/app/creator-choice-content/creator-choice-content.component.ts @@ -32,7 +32,7 @@ export class CreatorChoiceContentComponent implements OnInit { new AnswerOption('Option 3', '20'), new AnswerOption('Option 4', '30') ], - [0, 1, 3], + [0, 2, 3], true); displayedColumns = ['label', 'points']; @@ -43,10 +43,13 @@ export class CreatorChoiceContentComponent implements OnInit { } ngOnInit() { + this.fillCorrectAnswers(); + } + + fillCorrectAnswers() { for (let i = 0; i < this.content.options.length; i++) { this.correctAnswers.push(new CorrectAnswer(this.content.options[i], this.content.correctOptionIndexes.includes(i))); } - console.log(this.correctAnswers); } submitContent() { @@ -63,6 +66,7 @@ export class CreatorChoiceContentComponent implements OnInit { if (isCorrect) { this.content.correctOptionIndexes.push(this.content.options.length); } + this.fillCorrectAnswers(); this.submitContent(); } }