From eab03b7283b6263e8ae23cea64e8e34580b95261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Tue, 11 Dec 2018 12:07:04 +0100 Subject: [PATCH] Make statistics available for participants --- .../participant/participant-routing.module.ts | 14 ++++++++++++++ .../room-participant-page.component.html | 12 +++++++----- .../shared/comment-list/comment-list.component.ts | 4 ++-- .../feedback-barometer-page.component.ts | 11 +++++------ .../list-statistic/list-statistic.component.html | 10 +++++----- .../list-statistic/list-statistic.component.ts | 11 ++++++++++- 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/app/components/participant/participant-routing.module.ts b/src/app/components/participant/participant-routing.module.ts index 764917b77..b4b33c4e5 100644 --- a/src/app/components/participant/participant-routing.module.ts +++ b/src/app/components/participant/participant-routing.module.ts @@ -7,6 +7,8 @@ import { RoomParticipantPageComponent } from './room-participant-page/room-parti import { CommentCreatePageComponent } from './comment-create-page/comment-create-page.component'; import { FeedbackBarometerPageComponent } from '../shared/feedback-barometer-page/feedback-barometer-page.component'; import { ParticipantContentCarouselPageComponent } from './participant-content-carousel-page/participant-content-carousel-page.component'; +import { StatisticsPageComponent } from '../shared/statistics-page/statistics-page.component'; +import { StatisticComponent } from '../shared/statistic/statistic.component'; const routes: Routes = [ { @@ -21,6 +23,18 @@ const routes: Routes = [ canActivate: [AuthenticationGuard], data: { roles: [UserRole.PARTICIPANT] } }, + { + path: 'room/:roomId/statistics', + component: StatisticsPageComponent, + canActivate: [AuthenticationGuard], + data: { roles: [UserRole.PARTICIPANT] } + }, + { + path: 'room/:roomId/statistics/:contentId', + component: StatisticComponent, + canActivate: [AuthenticationGuard], + data: { roles: [UserRole.PARTICIPANT] } + }, { path: 'room/:roomId/create-comment', component: CommentCreatePageComponent, diff --git a/src/app/components/participant/room-participant-page/room-participant-page.component.html b/src/app/components/participant/room-participant-page/room-participant-page.component.html index 582977b71..852645373 100644 --- a/src/app/components/participant/room-participant-page/room-participant-page.component.html +++ b/src/app/components/participant/room-participant-page/room-participant-page.component.html @@ -13,7 +13,7 @@ </p> </mat-card-content> <mat-divider></mat-divider> - <mat-grid-list cols="2" rowHeight="2:1"> + <mat-grid-list cols="3" rowHeight="2:1"> <mat-grid-tile> <button mat-icon-button color="accent" matTooltip="{{ 'room-page.create-comment' | translate}}" routerLink="/participant/room/{{ room.id }}/create-comment"> @@ -26,11 +26,13 @@ <mat-icon>thumbs_up_down</mat-icon> </button> </mat-grid-tile> + <mat-grid-tile> + <button mat-icon-button color="accent" matTooltip="Lernstand" + routerLink="/participant/room/{{ room.shortId }}/statistics"> + <mat-icon>insert_chart</mat-icon> + </button> + </mat-grid-tile> </mat-grid-list> - <mat-card-actions> - <button mat-button color="primary">{{ 'room-page.comments' | translate }}</button> - <button mat-button color="primary">{{ 'room-page.learn' | translate }}</button> - </mat-card-actions> <app-content-groups *ngIf="room && room.contentGroups" [contentGroups]="room.contentGroups"></app-content-groups> </mat-card> </div> diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 3f3af1599..f30897d85 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -8,8 +8,8 @@ import { NotificationService } from '../../../services/util/notification.service import { AuthenticationService } from '../../../services/http/authentication.service'; import { UserRole } from '../../../models/user-roles.enum'; import { User } from '../../../models/user'; -import {TranslateService} from "@ngx-translate/core"; -import {LanguageService} from "../../../services/util/language.service"; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../../services/util/language.service'; @Component({ selector: 'app-comment-list', diff --git a/src/app/components/shared/feedback-barometer-page/feedback-barometer-page.component.ts b/src/app/components/shared/feedback-barometer-page/feedback-barometer-page.component.ts index e025b0b60..55f0725ab 100644 --- a/src/app/components/shared/feedback-barometer-page/feedback-barometer-page.component.ts +++ b/src/app/components/shared/feedback-barometer-page/feedback-barometer-page.component.ts @@ -12,15 +12,14 @@ import { NotificationService } from '../../../services/util/notification.service }) export class FeedbackBarometerPageComponent implements OnInit { feedback: any = [ - { state: 0, name: 'sentiment_very_satisfied', message: 'I can follow you.', count: 0, }, - { state: 1, name: 'sentiment_satisfied', message: 'Faster, please!', count: 0, }, - { state: 2, name: 'sentiment_neutral', message: 'It\'s ok!', count: 0, }, - { state: 3, name: 'sentiment_dissatisfied', message: 'Slower, please!', count: 0, }, - { state: 4, name: 'sentiment_very_dissatisfied', message: 'You\'ve lost me.', count: 0, }, + { state: 0, name: 'sentiment_very_satisfied', message: 'Ich kann folgen.', count: 0, }, + { state: 1, name: 'sentiment_satisfied', message: 'Schneller, bitte!', count: 0, }, + { state: 2, name: 'sentiment_dissatisfied', message: 'Langsamer, bitte!', count: 0, }, + { state: 3, name: 'sentiment_very_dissatisfied', message: 'Abgehängt.', count: 0, } ]; userRole: UserRole; - dummy = [2, 3, 2, 0, 1]; // dummy data -> delete this with api implementation and add get-data + dummy = [2, 3, 2, 1]; // dummy data -> delete this with api implementation and add get-data constructor( private authenticationService: AuthenticationService, diff --git a/src/app/components/shared/list-statistic/list-statistic.component.html b/src/app/components/shared/list-statistic/list-statistic.component.html index b8e1367cf..6bc7bbb35 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.html +++ b/src/app/components/shared/list-statistic/list-statistic.component.html @@ -9,12 +9,12 @@ <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <ng-container matColumnDef="content"> - <mat-header-cell *matHeaderCellDef> {{'content.content' | translate}} </mat-header-cell> + <mat-header-cell *matHeaderCellDef> {{'statistic.content' | translate}} </mat-header-cell> <mat-cell *matCellDef="let cp" [ngClass]="{ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyCC' : cp.percent < status.zero }" routerLink="/creator/room/{{ roomId }}/statistics/{{cp.contentId}}">{{cp.content.subject}}</mat-cell> + 'emptyCC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.content.subject}}</mat-cell> </ng-container> <ng-container matColumnDef="percentage"> @@ -23,7 +23,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="/creator/room/{{ roomId }}/statistics/{{cp.contentId}}">{{cp.percent.toFixed() + ' %'}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.percent.toFixed() + ' %'}}</mat-cell> </ng-container> <ng-container matColumnDef="counts"> @@ -32,7 +32,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="/creator/room/{{ roomId }}/statistics/{{cp.contentId}}">{{cp.counts}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.counts}}</mat-cell> </ng-container> <ng-container matColumnDef="abstentions"> @@ -41,7 +41,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="/creator/room/{{ roomId }}/statistics/{{cp.contentId}}">{{cp.abstentions}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.abstentions}}</mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> diff --git a/src/app/components/shared/list-statistic/list-statistic.component.ts b/src/app/components/shared/list-statistic/list-statistic.component.ts index 89f17cacc..50b29f527 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.ts +++ b/src/app/components/shared/list-statistic/list-statistic.component.ts @@ -9,6 +9,8 @@ import { Combination } from '../../../models/round-statistics'; import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../services/util/language.service'; import { ActivatedRoute } from '@angular/router'; +import { AuthenticationService } from '../../../services/http/authentication.service'; +import { UserRole } from '../../../models/user-roles.enum'; export class ContentStatistic { content: Content; @@ -47,17 +49,24 @@ export class ListStatisticComponent implements OnInit { totalP = 0; contentCounter = 0; roomId: number; + nextLink: string; constructor(private contentService: ContentService, private translateService: TranslateService, protected langService: LanguageService, - protected route: ActivatedRoute) { + protected route: ActivatedRoute, + protected authService: AuthenticationService) { langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit() { this.route.params.subscribe(params => { this.roomId = params['roomId']; + if (this.authService.getRole() === UserRole.CREATOR) { + this.nextLink = `/creator/room/${ this.roomId }/statistics/`; + } else { + this.nextLink = `/participant/room/${ this.roomId }/statistics/`; + } }); this.translateService.use(localStorage.getItem('currentLang')); this.contentService.getContentChoiceByIds(this.contentGroup.contentIds).subscribe(contents => { -- GitLab