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 25e324e3be02ff74960b4beb2fcfb87a3d14bab2..9be304daa1d8d62045c93fd18c8cd3752d538afc 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.html +++ b/src/app/components/shared/list-statistic/list-statistic.component.html @@ -9,28 +9,28 @@ <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <ng-container matColumnDef="content"> - <mat-header-cell *matHeaderCellDef> Content </mat-header-cell> + <mat-header-cell *matHeaderCellDef> {{'content.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 }">{{cp.content.subject}}</mat-cell> </ng-container> <ng-container matColumnDef="percentage"> - <mat-header-cell *matHeaderCellDef> Percentage </mat-header-cell> + <mat-header-cell *matHeaderCellDef> {{'statistic.percentage' | 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, 'emptyC' : cp.percent < status.zero }">{{cp.percent.toFixed() + ' %'}}</mat-cell> </ng-container> <ng-container matColumnDef="counts"> - <mat-header-cell *matHeaderCellDef> Total </mat-header-cell> + <mat-header-cell *matHeaderCellDef> {{'statistic.total' | 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, 'emptyC' : cp.percent < status.zero }">{{cp.counts}}</mat-cell> </ng-container> <ng-container matColumnDef="abstentions"> - <mat-header-cell *matHeaderCellDef> Abstentions </mat-header-cell> + <mat-header-cell *matHeaderCellDef> {{'statistic.abstentions' | 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, 'emptyC' : cp.percent < status.zero }">{{cp.abstentions}}</mat-cell> 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 9cec4ae322d3b2e704426e38f8bfcef4c97c8473..69a2c2f051f7e26725253f2bf99c14975f569151 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.ts +++ b/src/app/components/shared/list-statistic/list-statistic.component.ts @@ -6,8 +6,10 @@ import { ContentType } from '../../../models/content-type.enum'; import { AnswerOption } from '../../../models/answer-option'; import { ContentChoice } from '../../../models/content-choice'; import { Combination } from '../../../models/round-statistics'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../../services/util/language.service'; -export class ContentPercents { +export class ContentStatistic { content: Content; percent: number; counts: number; @@ -37,15 +39,19 @@ export class ListStatisticComponent implements OnInit { empty: -1, zero: 0 }; - dataSource: ContentPercents[]; + dataSource: ContentStatistic[]; total = 0; totalP = 0; contentCounter = 0; - constructor(private contentService: ContentService) { + constructor(private contentService: ContentService, + private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit() { + this.translateService.use(localStorage.getItem('currentLang')); this.contentService.getContentChoiceByIds(this.contentGroup.contentIds).subscribe(contents => { this.getData(contents); }); @@ -55,9 +61,9 @@ export class ListStatisticComponent implements OnInit { this.contents = contents; const length = contents.length; let percent; - this.dataSource = new Array<ContentPercents>(length); + this.dataSource = new Array<ContentStatistic>(length); for (let i = 0; i < length; i++) { - this.dataSource[i] = new ContentPercents(null, 0, 0, 0 ); + this.dataSource[i] = new ContentStatistic(null, 0, 0, 0 ); this.dataSource[i].content = this.contents[i]; if (contents[i].format === ContentType.CHOICE) { this.contentService.getAnswer(contents[i].id).subscribe(answer => { diff --git a/src/app/components/shared/statistics/statistics.component.html b/src/app/components/shared/statistics/statistics.component.html index 77a64c31e3279090ef3fbe6247fe8daa4991a37a..6bc2ef84ae25f91e008e4d1f6f830511443cbc21 100644 --- a/src/app/components/shared/statistics/statistics.component.html +++ b/src/app/components/shared/statistics/statistics.component.html @@ -1,7 +1,7 @@ <div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center"> <mat-card> <mat-card-header> - <h2>Learning status</h2> + <h2>{{'statistic.learning-status' | translate}}</h2> </mat-card-header> <mat-divider></mat-divider> <mat-tab-group> diff --git a/src/app/components/shared/statistics/statistics.component.ts b/src/app/components/shared/statistics/statistics.component.ts index cef4ce9794f8cf832eee2be05f7b6199482e1097..757ebe017fc3b9d3e4d1cdcb1820031250908463 100644 --- a/src/app/components/shared/statistics/statistics.component.ts +++ b/src/app/components/shared/statistics/statistics.component.ts @@ -3,6 +3,8 @@ import { ActivatedRoute } from '@angular/router'; import { RoomService } from '../../../services/http/room.service'; import { ContentGroup } from '../../../models/content-group'; import { Room } from '../../../models/room'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../../services/util/language.service'; /* TODO: Use TranslateService */ @@ -19,7 +21,10 @@ export class StatisticsComponent implements OnInit { constructor( private route: ActivatedRoute, - private roomService: RoomService) { + private roomService: RoomService, + private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit(): void { @@ -27,6 +32,7 @@ export class StatisticsComponent implements OnInit { } getRoom(id: string): void { + this.translateService.use(localStorage.getItem('currentLang')); this.roomService.getRoom(id).subscribe(room => { this.contentGroups = room.contentGroups; }); diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index b5645bf47ce8d86881ff765d98836164ecf294bb..6d3d17fedca05ae23f28639bd0e31e340082d868 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -21,6 +21,7 @@ "default-content-group": "Standard" }, "content": { + "content": "Frage", "create": "Erstellen", "collection": "Sammlung", "body": "Inhalt", @@ -54,5 +55,11 @@ "description": "Beschreibung", "max-ls": "Max. Zeichen:", "create-session": "Session erstellen" + }, + "statistic": { + "learning-status": "Lernstand", + "total": "Total", + "percentage": "Prozent", + "abstentions": "Enthaltungen" } } diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index 2da377443761a625568b626002c483308c28c6e5..95f47fa0a7288f901f4a50a395277455d5732ac1 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -20,6 +20,7 @@ "default-content-group": "Default" }, "content": { + "content": "Content", "create": "Create", "collection": "Collection", "body": "Body", @@ -53,5 +54,11 @@ "description": "Description", "max-ls": "Max. letters / signs:", "create-session": "Create session" + }, + "statistic": { + "learning-status": "Learning status", + "total": "Total", + "percentage": "Percentage", + "abstentions": "Abstentions" } }