diff --git a/src/app/answer-statistics/answer-statistics.component.html b/src/app/answer-statistics/answer-statistics.component.html index 2b66b71d02397edfdddde76524cbc259040f4ca9..5da2ec7b4f89fc10f43b6bc9efa001b81d935f13 100644 --- a/src/app/answer-statistics/answer-statistics.component.html +++ b/src/app/answer-statistics/answer-statistics.component.html @@ -8,14 +8,16 @@ </mat-option> </mat-select> <div *ngIf="selected == 1"> - <!-- Add list of Question statistic --> - <mat-progress-bar [value]="50"> - </mat-progress-bar> + <div *ngFor="let statistic of statistics"> + {{ statistic.name }} + <mat-progress-bar [value]="statistic.percent"> + </mat-progress-bar> + <div align="right"> Votes: {{ statistic.votes }} </div> + </div> </div> <div *ngIf="selected == 2"> <!-- Add list of Question statistic --> - <mat-progress-bar [value]="50" color="warn"> - </mat-progress-bar> + <!-- Need number of participants in room --> </div> </mat-tab> <!-- Add second tab with true false answers --> diff --git a/src/app/answer-statistics/answer-statistics.component.scss b/src/app/answer-statistics/answer-statistics.component.scss index f0a767c2e0a748dfdafd59899bc77022270576e4..281a08f7ed2f2ca486f880e657d7b1c0d01deae9 100644 --- a/src/app/answer-statistics/answer-statistics.component.scss +++ b/src/app/answer-statistics/answer-statistics.component.scss @@ -10,5 +10,5 @@ mat-select { } mat-progress-bar { - margin-top: 20px; + height: 50px; } diff --git a/src/app/answer-statistics/answer-statistics.component.ts b/src/app/answer-statistics/answer-statistics.component.ts index e52b560ac887f58a2889eab6a73e39df4056faa4..e916c0fe4f149b7b3c10fad738281a456e568df9 100644 --- a/src/app/answer-statistics/answer-statistics.component.ts +++ b/src/app/answer-statistics/answer-statistics.component.ts @@ -1,4 +1,10 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; +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'; @Component({ selector: 'app-answer-statistics', @@ -6,18 +12,37 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./answer-statistics.component.scss'] }) export class AnswerStatisticsComponent implements OnInit { + @Input() content: Content[]; + statistics: any = null; states = [ { value: '1', viewValue: 'Responded' }, { value: '2', viewValue: 'Not responded' }, ]; selected: number = null; - constructor() { } + constructor( + private route: ActivatedRoute, + private roomService: RoomService, + private contentService: ContentService, + private contentAnswer: ContentAnswerService ) { } - ngOnInit() { + ngOnInit(): void { + this.route.params.subscribe(params => { + this.getContent(params['roomId']); + }); + } + + getContent(roomId: string): void { + this.contentService.getContents(roomId).subscribe(content => this.content = content); } showStatistic(value) { + this.statistics = []; + for (const question of this.content) { + this.statistics.push( { + name: question.subject, votes: '10', percent: '10', + }); + } this.selected = value; } } diff --git a/src/app/in-memory-data.service.ts b/src/app/in-memory-data.service.ts index 30b63b24bcfadbc08770d00e0054e30f03ac6c8f..855b34a534d5a0209d3023135deee31243bb8850 100644 --- a/src/app/in-memory-data.service.ts +++ b/src/app/in-memory-data.service.ts @@ -98,8 +98,35 @@ export class InMemoryDataService implements InMemoryDbService { { contentId: '2', revision: '2', - roomId: '3', + roomId: '1', subject: 'Text Content 2', + body: 'testcontent alpha beta', + round: 1, + format: ContentType.TEXT + }, + { + contentId: '3', + revision: '3', + roomId: '1', + subject: 'Text Content 3', + body: 'testcontent alpha beta', + round: 1, + format: ContentType.TEXT + }, + { + contentId: '4', + revision: '4', + roomId: '1', + subject: 'Text Content 4', + body: 'testcontent alpha beta', + round: 1, + format: ContentType.TEXT + }, + { + contentId: '5', + revision: '2', + roomId: '3', + subject: 'Text Content 1', body: 'This is yet another body of a text content.', round: 2, format: ContentType.TEXT