From 3caed5b5221ac5a1cf593c45ecdaad9421a409d4 Mon Sep 17 00:00:00 2001
From: mechtelm <nicht@mehr.fragen>
Date: Wed, 26 Aug 2020 18:53:26 +0200
Subject: [PATCH] menu: minor changes

---
 .../test-controller.service.ts                |  2 +-
 .../test-status/test-status.component.html    |  2 +-
 .../unit-menu/unit-menu.component.html        | 24 +++++++++++++++----
 .../unit-menu/unit-menu.component.ts          | 11 +++++++--
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/app/test-controller/test-controller.service.ts b/src/app/test-controller/test-controller.service.ts
index 3fec901e..5728304a 100644
--- a/src/app/test-controller/test-controller.service.ts
+++ b/src/app/test-controller/test-controller.service.ts
@@ -320,7 +320,7 @@ export class TestControllerService {
           this.router.navigate([`/t/${this.testId}/status`], {skipLocationChange: true});
           break;
         case UnitNavigationTarget.MENU:
-          this.router.navigate([`/t/${this.testId}/menu`], {skipLocationChange: true});
+          this.router.navigate([`/t/${this.testId}/menu`]);
           break;
         case UnitNavigationTarget.NEXT:
           let startWith = this.currentUnitSequenceId;
diff --git a/src/app/test-controller/test-status/test-status.component.html b/src/app/test-controller/test-status/test-status.component.html
index 88cb3414..ac2c8907 100644
--- a/src/app/test-controller/test-status/test-status.component.html
+++ b/src/app/test-controller/test-status/test-status.component.html
@@ -2,7 +2,7 @@
   <div fxLayout="row wrap" fxLayoutAlign="center stretch">
 
     <mat-card fxFlex="0 0 400px" fxLayout="column" class="mat-card-gray"
-              *ngIf="((tcs.testStatus$ | async) === tcs.testStatusEnum.ERROR) || ((tcs.testStatus$ | async) === tcs.testStatusEnum.PAUSED) || ((tcs.testStatus$ | async) === tcs.testStatusEnum.RUNNING)">
+              *ngIf="tcs.currentUnitSequenceId > 0 && ((tcs.testStatus$ | async) === tcs.testStatusEnum.ERROR) || ((tcs.testStatus$ | async) === tcs.testStatusEnum.PAUSED) || ((tcs.testStatus$ | async) === tcs.testStatusEnum.RUNNING)">
       <mat-card-title>{{ tcs.rootTestlet?.title }}</mat-card-title>
       <mat-card-content>
         <p><b>Angemeldet als "{{loginName}}"</b></p>
diff --git a/src/app/test-controller/unit-menu/unit-menu.component.html b/src/app/test-controller/unit-menu/unit-menu.component.html
index 98164cde..2674c6d1 100644
--- a/src/app/test-controller/unit-menu/unit-menu.component.html
+++ b/src/app/test-controller/unit-menu/unit-menu.component.html
@@ -1,6 +1,6 @@
 <div class="menu-body">
   <div fxLayout="row wrap" fxLayoutAlign="center stretch">
-    <mat-card fxFlex="0 0 400px" fxLayout="column" *ngIf="((tcs.testStatus$ | async) === tcs.testStatusEnum.RUNNING) && (tcs.unitListForNaviButtons.length > 0)">
+    <mat-card fxFlex="0 0 400px" fxLayout="column" *ngIf="unitMenuButtonList.length > 0">
       <mat-card-title>{{ 'Aufgaben' | customtext:'booklet_tasklisttitle':cts.updateCount }}</mat-card-title>
       <mat-card-content>
         <div fxLayout="column" fxLayoutAlign="center stretch">
@@ -17,17 +17,31 @@
         </div>
       </mat-card-content>
       <mat-card-actions>
-        <button mat-raised-button (click)="goBack()">Zurück</button>
+        <button mat-raised-button color="primary" (click)="terminateTest()">
+          {{ 'Test beenden'  | customtext:'login_testEndButtonLabel':cts.updateCount}}
+        </button>
       </mat-card-actions>
     </mat-card>
 
-    <mat-card fxFlex="0 0 400px" fxLayout="column" *ngIf="((tcs.testStatus$ | async) !== tcs.testStatusEnum.RUNNING) || (tcs.unitListForNaviButtons.length > 0)">
+    <mat-card fxFlex="0 0 400px" fxLayout="column" *ngIf="unitMenuButtonList.length === 0">
       <mat-card-title>{{ tcs.rootTestlet?.title }}</mat-card-title>
       <mat-card-content>
-        <p>Es wurde kein aktiver Test festgestellt</p>
+        <p><b>Angemeldet als "{{loginName}}"</b></p>
+        <p><b>{{tcs.testMode.modeLabel}}</b></p>
+        <p *ngIf="(tcs.testStatus$ | async) === tcs.testStatusEnum.ERROR" style="color: chocolate">
+          <b>{{ 'Es ist ein Fehler aufgetreten.' | customtext:'booklet_errormessage':cts.updateCount }} </b>
+        </p>
+        <p *ngIf="(tcs.testStatus$ | async) === tcs.testStatusEnum.PAUSED" style="color: chocolate">
+          <b>{{ 'Testpause' | customtext:'booklet_pausedmessage':cts.updateCount }} </b>
+        </p>
+        <p *ngIf="(tcs.testStatus$ | async) === tcs.testStatusEnum.RUNNING" style="color: chocolate">
+          <b>Der Test ist aktiv.</b>
+        </p>
       </mat-card-content>
       <mat-card-actions>
-        <button mat-raised-button (click)="goBack()">Zurück</button>
+        <button mat-raised-button color="primary" (click)="terminateTest()">
+          {{ 'Test beenden'  | customtext:'login_testEndButtonLabel':cts.updateCount}}
+        </button>
       </mat-card-actions>
     </mat-card>
   </div>
diff --git a/src/app/test-controller/unit-menu/unit-menu.component.ts b/src/app/test-controller/unit-menu/unit-menu.component.ts
index 84edbe59..42b81647 100644
--- a/src/app/test-controller/unit-menu/unit-menu.component.ts
+++ b/src/app/test-controller/unit-menu/unit-menu.component.ts
@@ -2,6 +2,7 @@ import {Component, OnInit} from '@angular/core';
 import {TestControllerService} from "../test-controller.service";
 import {UnitMenuButtonData} from "../test-controller.interfaces";
 import {CustomtextService} from "iqb-components";
+import {MainDataService} from "../../maindata.service";
 
 @Component({
   templateUrl: './unit-menu.component.html',
@@ -9,6 +10,7 @@ import {CustomtextService} from "iqb-components";
 })
 export class UnitMenuComponent implements OnInit {
   unitMenuButtonList: UnitMenuButtonData[] = [];
+  loginName = '??';
 
   constructor(
     public cts: CustomtextService,
@@ -18,6 +20,11 @@ export class UnitMenuComponent implements OnInit {
   ngOnInit(): void {
     this.unitMenuButtonList = [];
     setTimeout(() => {
+      const authData = MainDataService.getAuthData();
+      if (authData) {
+        this.loginName = authData.displayName;
+      }
+
       let testletMarkerSwitch = true;
       let prevTestletLabel = '';
       if (this.tcs.bookletConfig.unit_menu !== 'OFF' || this.tcs.testMode.showUnitMenu) {
@@ -47,7 +54,7 @@ export class UnitMenuComponent implements OnInit {
     });
   }
 
-  goBack() {
-    window.history.back();
+  terminateTest() {
+    this.tcs.terminateTest('BOOKLETLOCKEDbyTESTEE');
   }
 }
-- 
GitLab