From 83b267418f9243c6a2d055984d3904166ecb7a18 Mon Sep 17 00:00:00 2001
From: paflov <paf@titelfrei.de>
Date: Fri, 22 Apr 2022 13:31:54 +0200
Subject: [PATCH] Fix timer management in DEMO-mode

https://github.com/iqb-berlin/testcenter-frontend/issues/358
https://github.com/iqb-berlin/testcenter-frontend/issues/374
---
 src/app/test-controller/routing/unit-route-guards.ts | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/app/test-controller/routing/unit-route-guards.ts b/src/app/test-controller/routing/unit-route-guards.ts
index b9442b72..4c67187a 100644
--- a/src/app/test-controller/routing/unit-route-guards.ts
+++ b/src/app/test-controller/routing/unit-route-guards.ts
@@ -60,14 +60,15 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
     if (!this.tcs.currentMaxTimerTestletId) { // leaving unit is not in a timed block
       return of(true);
     }
-    if (!this.tcs.testMode.forceTimeRestrictions) {
-      return of(true);
-    }
     if (newUnit && newUnit.maxTimerRequiringTestlet && // staying in the same timed block
       (newUnit.maxTimerRequiringTestlet.id === this.tcs.currentMaxTimerTestletId)
     ) {
       return of(true);
     }
+    if (!this.tcs.testMode.forceTimeRestrictions) {
+      this.tcs.interruptMaxTimer();
+      return of(true);
+    }
     const dialogCDRef = this.confirmDialog.open(ConfirmDialogComponent, {
       width: '500px',
       data: <ConfirmDialogData>{
-- 
GitLab