From 5fd925240b9fc958543fd9677cd3230021dab9d3 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Fri, 28 Apr 2017 13:56:35 +0200
Subject: [PATCH] OO-2725: enable suspend/resume which doesn't count the time
 between for time limited test

---
 pom.xml                                              |  2 +-
 .../qti21/ui/AssessmentTestDisplayController.java    | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index edddc98e5eb..887b702b880 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,7 +73,7 @@
 		<version.selenium>2.53.1</version.selenium>
 		<version.drone>2.0.1.Final</version.drone>
 		<activemq.version>5.11.1</activemq.version>
-		<qtiworks.version>1.0.3</qtiworks.version>
+		<qtiworks.version>1.0.4</qtiworks.version>
 
 	    <!-- properties for testing and Q&A -->
 	    <!-- by default no tests are executed so far (April 2011). Use appropriate profiles and properties on the command line -->
diff --git a/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java b/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
index 4aa3c89f529..997050dd280 100644
--- a/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
+++ b/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
@@ -324,7 +324,7 @@ public class AssessmentTestDisplayController extends BasicController implements
 			lastEvent = new CandidateEvent(candidateSession, testEntry, entry);
 			lastEvent.setTestEventType(CandidateTestEventType.ITEM_EVENT);
 			
-			testSessionController = resumeSession();
+			testSessionController = resumeSession(ureq);
 		}
 	}
 	
@@ -448,6 +448,9 @@ public class AssessmentTestDisplayController extends BasicController implements
 			return false;
 		}
 		
+		testSessionController.touchDurations(currentRequestTimestamp);
+		testSessionController.suspendTestSession(requestTimestamp);
+		
 		TestSessionState testSessionState = testSessionController.getTestSessionState();
 		TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
 		if(currentItemKey == null) {
@@ -1406,9 +1409,12 @@ public class AssessmentTestDisplayController extends BasicController implements
 		return result;
 	}
 	
-	private TestSessionController resumeSession() {
+	private TestSessionController resumeSession(UserRequest ureq) {
+		Date currentRequestTimestamp = ureq.getRequestTimestamp();
+		
         final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
         TestSessionController controller =  createTestSessionController(notificationRecorder);
+        controller.unsuspendTestSession(currentRequestTimestamp);
        
         TestSessionState testSessionState = controller.getTestSessionState();
 		TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
@@ -1419,7 +1425,7 @@ public class AssessmentTestDisplayController extends BasicController implements
 			if(itemProcessingContext instanceof ItemSessionController
 					&& itemSessionState.isSuspended()) {
 				ItemSessionController itemSessionController = (ItemSessionController)itemProcessingContext;
-				itemSessionController.unsuspendItemSession(new Date());
+				itemSessionController.unsuspendItemSession(currentRequestTimestamp);
 			}
 		}
 		
-- 
GitLab