From c60bedf71860a88cf2dad47cbde89dd2d140d9b3 Mon Sep 17 00:00:00 2001 From: mechtelm <nicht@mehr.fragen> Date: Wed, 29 Apr 2020 13:20:24 +0200 Subject: [PATCH] bugfix right order 'add log' -> 'lock booklet' #134 --- src/app/app-root/login/login.component.ts | 1 + .../test-controller.service.ts | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/app-root/login/login.component.ts b/src/app/app-root/login/login.component.ts index 6d79fad5..df90df85 100644 --- a/src/app/app-root/login/login.component.ts +++ b/src/app/app-root/login/login.component.ts @@ -35,6 +35,7 @@ export class LoginComponent implements OnInit, OnDestroy { ) { } ngOnInit(): void { + this.mds.setSpinnerOff(); this.routingSubscription = this.route.params.subscribe(params => { this.returnTo = params['returnTo']; }) diff --git a/src/app/test-controller/test-controller.service.ts b/src/app/test-controller/test-controller.service.ts index 8f8d30e3..f840fc1c 100644 --- a/src/app/test-controller/test-controller.service.ts +++ b/src/app/test-controller/test-controller.service.ts @@ -1,4 +1,4 @@ -import {debounceTime, map, switchMap, takeUntil} from 'rxjs/operators'; +import {debounceTime, map, takeUntil} from 'rxjs/operators'; import {BehaviorSubject, interval, Subject, Subscription, timer} from 'rxjs'; import {Injectable} from '@angular/core'; import {MaxTimerData, Testlet} from './test-controller.classes'; @@ -299,13 +299,17 @@ export class TestControllerService { public terminateTest() { if (this.testConfig.saveResponses) { - this.bs.addBookletLog(this.testId, Date.now(), 'BOOKLETLOCKEDbyTESTEE').pipe( - switchMap(() => { - return this.bs.lockBooklet(this.testId) - }) - ).subscribe(() => { - this.testStatus$.next(TestStatus.TERMINATED); - this.router.navigate(['/']); + this.bs.addBookletLog(this.testId, Date.now(), 'BOOKLETLOCKEDbyTESTEE').subscribe(OK =>{ + // TODO who evaluates TestStatus when navigating to root? + if (OK) { + this.bs.lockBooklet(this.testId).subscribe(bsOk => { + this.testStatus$.next(bsOk ? TestStatus.TERMINATED : TestStatus.ERROR); + this.router.navigate(['/']); + }) + } else { + this.testStatus$.next(TestStatus.ERROR); + this.router.navigate(['/']); + } }) } else { this.testStatus$.next(TestStatus.TERMINATED); -- GitLab