Skip to content
Snippets Groups Projects
Commit 760fc4bc authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Finish form control - check if it is a single-choice content

parent 1067952e
Branches
Tags
1 merge request!135Resolve "Refine content-list-view"
......@@ -16,6 +16,7 @@ export class ContentEditComponent implements OnInit {
content: ContentChoice;
displayAnswers: DisplayAnswer[] = [];
displayedColumns = ['label', 'checked'];
ansCounter = 1;
constructor(private translateService: TranslateService,
private notificationService: NotificationService,
......@@ -33,8 +34,20 @@ export class ContentEditComponent implements OnInit {
updateAnswer(index: number) {
if (this.displayAnswers[index].correct === true) {
this.ansCounter++;
console.log(this.ansCounter);
if ((!this.content.multiple) && this.ansCounter > 1) {
for (let i = 0; i < this.displayAnswers.length; i++) {
if (!(i === index)) {
this.displayAnswers[i].correct = false;
this.content.options[i].points = -10;
}
}
this.ansCounter = 1;
}
this.content.options[index].points = 10;
} else {
this.ansCounter--;
this.content.options[index].points = -10;
}
}
......
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