Skip to content
Snippets Groups Projects
Verified Commit 428822b9 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Add function that will prepare options data for rendering

parent 763eb79b
Branches
Tags
1 merge request!92Resolve "content types (logic)"
......@@ -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>
......
......@@ -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();
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment