Skip to content
Snippets Groups Projects
Commit 165a8dfb authored by Thomas Lenz's avatar Thomas Lenz
Browse files

Add 'answer sent' chip to participant's choice-content and implement logic to...

Add 'answer sent' chip to participant's choice-content and implement logic to check for only 1 selected answer in single-choice mode
parent 463d23a1
Branches
Tags
No related merge requests found
......@@ -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>
......@@ -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);
}
......
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