diff --git a/src/app/test-controller/backend.service.ts b/src/app/test-controller/backend.service.ts index c15433a641ba9026a808029e61f23247f8714ed3..b41638efb1e6006746e2ba25a080702cbe5468d4 100644 --- a/src/app/test-controller/backend.service.ts +++ b/src/app/test-controller/backend.service.ts @@ -87,12 +87,6 @@ export class BackendService { } updateTestState(testId: string, newState: StateReportEntry[]): Subscription { - - if (!testId) { // TODO find out why does this happen at tst start and get rid of it - console.warn('called without testID', newState); - return of().subscribe(); - } - return this.http .patch(this.serverUrl + `test/${testId}/state`, newState) .subscribe({error: (err: ApiError) => console.error(`updateTestState Api-Error: ${err.code} ${err.info}`)}); diff --git a/src/app/test-controller/command.service.ts b/src/app/test-controller/command.service.ts index 546535e6f3f002681cf09f1e9e8e4a04fdade08b..f893488097c43528d6289d34a449cd1b483e03a6 100644 --- a/src/app/test-controller/command.service.ts +++ b/src/app/test-controller/command.service.ts @@ -59,7 +59,7 @@ export class CommandService extends WebsocketBackendService<Command[]> implement if ((testStatus === TestControllerState.RUNNING) || (testStatus === TestControllerState.PAUSED)) { return 'started'; } - if ((testStatus === TestControllerState.TERMINATED) || (testStatus === TestControllerState.ERROR)) { + if ((testStatus === TestControllerState.FINISHED) || (testStatus === TestControllerState.ERROR)) { return 'terminated'; } return ''; diff --git a/src/app/test-controller/test-controller-route-guards.ts b/src/app/test-controller/test-controller-route-guards.ts index f6436798a41aa99983457ee6c23890c4d0399ae0..3f990b721e1bae0a662d09c8d0e2c70fbc63c41d 100644 --- a/src/app/test-controller/test-controller-route-guards.ts +++ b/src/app/test-controller/test-controller-route-guards.ts @@ -19,7 +19,7 @@ export class TestControllerDeactivateGuard implements CanDeactivate<TestControll if (this.tcs.testMode.saveResponses) { const testStatus: TestControllerState = this.tcs.testStatus$.getValue(); - if ((testStatus !== TestControllerState.ERROR) && (testStatus !== TestControllerState.TERMINATED)) { + if ((testStatus !== TestControllerState.ERROR) && (testStatus !== TestControllerState.FINISHED)) { if (this.tcs.bookletConfig.unit_menu !== 'OFF' || this.tcs.testMode.showUnitMenu) { this.tcs.setUnitNavigationRequest(UnitNavigationTarget.MENU); } else { @@ -48,7 +48,9 @@ export class TestControllerErrorPausedActivateGuard implements CanActivate { canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { const testStatus: TestControllerState = this.tcs.testStatus$.getValue(); - return (testStatus !== TestControllerState.ERROR) && (testStatus !== TestControllerState.TERMINATED) && (testStatus !== TestControllerState.PAUSED) + return (testStatus !== TestControllerState.ERROR) + && (testStatus !== TestControllerState.FINISHED) + && (testStatus !== TestControllerState.PAUSED); } } diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts index 95cf7898fef984b01fd20a58fa90088d78d477d9..ed430fe7ab2aba461bd0998e394078b6528b8174 100644 --- a/src/app/test-controller/test-controller.component.ts +++ b/src/app/test-controller/test-controller.component.ts @@ -319,11 +319,15 @@ export class TestControllerComponent implements OnInit, OnDestroy { } this.tcs.testStatus$.next(TestControllerState.ERROR); }); - this.testStatusSubscription = this.tcs.testStatus$.subscribe(ts => { - this.bs.updateTestState(this.tcs.testId, [<StateReportEntry>{ - key: TestStateKey.CONTROLLER, timeStamp: Date.now(), content: ts - }]); - switch (ts) { + this.testStatusSubscription = this.tcs.testStatus$.subscribe(testContollerState => { + + if ([TestControllerState.FINISHED, TestControllerState.INIT].indexOf(testContollerState) === -1) { + this.bs.updateTestState(this.tcs.testId, [<StateReportEntry>{ + key: TestStateKey.CONTROLLER, timeStamp: Date.now(), content: testContollerState + }]); + } + + switch (testContollerState) { case TestControllerState.ERROR: this.tcs.loadProgressValue = 0; this.tcs.setUnitNavigationRequest(UnitNavigationTarget.ERROR); diff --git a/src/app/test-controller/test-controller.interfaces.ts b/src/app/test-controller/test-controller.interfaces.ts index 02059874fe00818559c19faa9bb5212e90658dd0..c79b66a14266d23371737421351e9767075355fc 100644 --- a/src/app/test-controller/test-controller.interfaces.ts +++ b/src/app/test-controller/test-controller.interfaces.ts @@ -49,8 +49,8 @@ export enum TestControllerState { INIT = 'INIT', LOADING = 'LOADING', RUNNING = 'RUNNING', - TERMINATING = 'TERMINATING', TERMINATED = 'TERMINATED', + FINISHED = 'FINISHED', PAUSED = 'PAUSED', ERROR = 'ERROR' } diff --git a/src/app/test-controller/test-controller.service.ts b/src/app/test-controller/test-controller.service.ts index cb73c706af6789d4ffab7592dc73bf42f053ddc8..6d0be7153ceebe1faf327222776257f3faf04806 100644 --- a/src/app/test-controller/test-controller.service.ts +++ b/src/app/test-controller/test-controller.service.ts @@ -273,15 +273,15 @@ export class TestControllerService { public terminateTest(logEntryKey: string) { if (this.testMode.saveResponses) { - if (this.testStatus$.getValue() !== TestControllerState.TERMINATING) { - this.testStatus$.next(TestControllerState.TERMINATING); // sometimes terminateTest get called two times from player + if (this.testStatus$.getValue() !== TestControllerState.TERMINATED) { + this.testStatus$.next(TestControllerState.TERMINATED); // sometimes terminateTest get called two times from player this.bs.lockTest(this.testId, Date.now(), logEntryKey).subscribe(bsOk => { - this.testStatus$.next(bsOk ? TestControllerState.TERMINATED : TestControllerState.ERROR); + this.testStatus$.next(bsOk ? TestControllerState.FINISHED : TestControllerState.ERROR); this.router.navigate(['/'], {state: {force: true}}); }); } } else { - this.testStatus$.next(TestControllerState.TERMINATED); + this.testStatus$.next(TestControllerState.FINISHED); this.router.navigate(['/'], {state: {force: true}}); } } @@ -335,13 +335,13 @@ export class TestControllerService { if (!navOk) { const navTarget = Number(navString); if (!isNaN(navTarget)) { - let startWith = this.currentUnitSequenceId; - if (startWith < this.minUnitSequenceId) { - startWith = this.minUnitSequenceId - 1; + let unitSequenceId = this.currentUnitSequenceId; + if (unitSequenceId < this.minUnitSequenceId) { + unitSequenceId = this.minUnitSequenceId - 1; } - const nextUnitSequenceId = this.rootTestlet.getNextUnlockedUnitSequenceId(startWith); - if (nextUnitSequenceId > 0 && nextUnitSequenceId !== navTarget) { - this.router.navigate([`/t/${this.testId}/u/${nextUnitSequenceId}`], + const unitSequenceIdNext = this.rootTestlet.getNextUnlockedUnitSequenceId(unitSequenceId); + if (unitSequenceIdNext > 0 && unitSequenceIdNext !== navTarget) { + this.router.navigate([`/t/${this.testId}/u/${unitSequenceIdNext}`], {state: {force: force}}); } } diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts index 9c0ce523f161ca2aae9017ed141b2cf0da93d827..b32c90241de317297515efc3bf8d1b8ae671b7c2 100644 --- a/src/environments/environment.dev.ts +++ b/src/environments/environment.dev.ts @@ -6,6 +6,6 @@ export const environment = { production: false, testcenterUrl: '/api/', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', - apiVersionExpected: '7.0.0', + apiVersionExpected: '7.1.0', veronaApiVersionSupported: '2.1.0' }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 344077856d5a76e91eb2b8f03c06501a1f515443..b55c1e8fb9ab01c6e1018b7845b5a92806a387fd 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -4,6 +4,6 @@ export const environment = { production: true, testcenterUrl: '/api/', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', - apiVersionExpected: '7.0.0', + apiVersionExpected: '7.1.0', veronaApiVersionSupported: '2.1.0' };