Skip to content
Snippets Groups Projects
Commit 105a16c9 authored by Hagen Dreßler's avatar Hagen Dreßler
Browse files

Edit component answer-statistic (get Answers)

parent 549aa1df
No related merge requests found
This commit is part of merge request !85. Comments created here will be created in the context of that merge request.
......@@ -3,8 +3,8 @@ import { ActivatedRoute } from '@angular/router';
import { RoomService } from '../room.service';
import { Content } from '../content';
import { ContentService } from '../content.service';
import { AnswerText } from '../answer-text';
import { ContentAnswerService } from '../content-answer.service';
import { AnswerText } from '../answer-text';
@Component({
selector: 'app-answer-statistics',
......@@ -13,6 +13,7 @@ import { ContentAnswerService } from '../content-answer.service';
})
export class AnswerStatisticsComponent implements OnInit {
@Input() content: Content[];
@Input() answers: AnswerText[] = [];
statistics: any = null;
states = [
{ value: '1', viewValue: 'Responded' },
......@@ -24,7 +25,7 @@ export class AnswerStatisticsComponent implements OnInit {
private route: ActivatedRoute,
private roomService: RoomService,
private contentService: ContentService,
private contentAnswer: ContentAnswerService ) { }
private contentAnswerService: ContentAnswerService ) { }
ngOnInit(): void {
this.route.params.subscribe(params => {
......@@ -33,10 +34,20 @@ export class AnswerStatisticsComponent implements OnInit {
}
getContent(roomId: string): void {
this.contentService.getContents(roomId).subscribe(content => this.content = content);
this.contentService.getContents(roomId).subscribe(content => {
this.content = content;
this.getAnswers();
});
}
getAnswers(): void {
for (const question of this.content) {
this.contentAnswerService.getAnswerTexts(question.id).subscribe( answer => [].push.apply(this.answers, answer));
}
}
showStatistic(value) {
console.log(this.answers);
this.statistics = [];
for (const question of this.content) {
this.statistics.push( {
......
......@@ -145,8 +145,8 @@ export class InMemoryDataService implements InMemoryDbService {
creationTimestamp: Date,
},
{
id: '1',
revision: '1',
id: '2',
revision: '2',
contentId: '1',
round: '1',
subject: 'Textaufgabe 1',
......@@ -155,8 +155,8 @@ export class InMemoryDataService implements InMemoryDbService {
creationTimestamp: Date,
},
{
id: '2',
revision: '2',
id: '3',
revision: '3',
contentId: '2',
round: '3',
subject: 'Textaufgabe 2',
......
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