From 08c010c0b1aae49b3200efae5e66c439e6de3b6f Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Mon, 15 Feb 2021 15:05:13 +0100
Subject: [PATCH] OO-5293: present the first question in test with multiple
 test parts

---
 .../ui/AssessmentTestDisplayController.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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 e0d36e83ee5..63adc820906 100644
--- a/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
+++ b/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
@@ -1588,6 +1588,9 @@ public class AssessmentTestDisplayController extends BasicController implements
         }
         
         boolean terminated = isTerminated();
+        
+        /* Enter first assessment item if possible */
+        enterFirstAssessmentItemOfAdvancedTestPart(nextTestPart, ureq);
 
         /* Record current result state */
         computeAndRecordTestAssessmentResult(currentTimestamp, testSessionState, terminated);
@@ -1604,6 +1607,22 @@ public class AssessmentTestDisplayController extends BasicController implements
         }
 	}
 	
+	private void enterFirstAssessmentItemOfAdvancedTestPart(TestPlanNode nextTestPart, UserRequest ureq) {
+		try {
+			if(!isTerminated() && nextTestPart != null) {
+			    TestPart currentTestPart = testSessionController.getCurrentTestPart();
+				if(currentTestPart != null && currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR) {
+			    	//go to the first assessment item
+			    	if(testSessionController.hasFollowingNonLinearItem()) {
+			    		testSessionController.selectFollowingItemNonLinear(ureq.getRequestTimestamp());
+			    	}
+				}
+			}
+		} catch (Exception e) {
+			logError("", e);
+		}
+	}
+	
 	private void processReviewTestPart() {
 		NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
         TestSessionState testSessionState = testSessionController.getTestSessionState();
-- 
GitLab