diff --git a/src/app/components/fragments/content-choice-participant/content-choice-participant.component.html b/src/app/components/fragments/content-choice-participant/content-choice-participant.component.html index b731b9397f64528f72a58473ea31e5af0fd77e0c..39a8ceee99a87d6141ce160cf4c1fe34e45aae34 100644 --- a/src/app/components/fragments/content-choice-participant/content-choice-participant.component.html +++ b/src/app/components/fragments/content-choice-participant/content-choice-participant.component.html @@ -4,8 +4,13 @@ <mat-divider></mat-divider> <mat-list> <mat-list-item *ngFor="let answer of checkedAnswers"> - <mat-checkbox color="primary" [(ngModel)]="answer.checked" name="answer">{{ answer.answerOption.label }}</mat-checkbox> + <mat-checkbox color="primary" [(ngModel)]="answer.checked" name="answer">{{ answer.answerOption.label }} + </mat-checkbox> </mat-list-item> </mat-list> + <mat-chip-list *ngIf="isAnswerSent"> + <mat-chip color="primary" selected="true">Answer sent</mat-chip> + </mat-chip-list> + <mat-divider></mat-divider> <button mat-raised-button color="primary">Send answer</button> </form> diff --git a/src/app/components/fragments/content-choice-participant/content-choice-participant.component.ts b/src/app/components/fragments/content-choice-participant/content-choice-participant.component.ts index b7890316fe41031743a7c8d9841cbe32e8af235c..3ee2b27f43d4920628cecf189490fc53303fac92 100644 --- a/src/app/components/fragments/content-choice-participant/content-choice-participant.component.ts +++ b/src/app/components/fragments/content-choice-participant/content-choice-participant.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { ContentChoice } from '../../../models/content-choice'; import { AnswerOption } from '../../../models/answer-option'; import { ContentAnswerService } from '../../../services/http/content-answer.service'; +import { NotificationService } from '../../../services/util/notification.service'; class CheckedAnswer { answerOption: AnswerOption; @@ -32,10 +33,12 @@ export class ContentChoiceParticipantComponent implements OnInit { new AnswerOption('Option 4', '30') ], [2, 3, 4], - true); + false); checkedAnswers: CheckedAnswer[] = []; + isAnswerSent = false; - constructor(private answerService: ContentAnswerService) { + constructor(private answerService: ContentAnswerService, + private notificationService: NotificationService) { } ngOnInit() { @@ -55,6 +58,13 @@ export class ContentChoiceParticipantComponent implements OnInit { selectedAnswers.push(i); } } + if (!this.content.multiple && selectedAnswers.length !== 1) { + this.notificationService.show('In single choice mode is only 1 selection allowed'); + this.isAnswerSent = false; + return; + } + this.isAnswerSent = true; + this.notificationService.show('Answer successfully sent.'); // ToDo: Implement function in service // this.answerService.addChoiceAnswer(selectedAnswers); }