From 0462b74aedc70f3bc48650dc3a0ec4dfe5743b04 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Tue, 7 Jan 2020 09:43:56 +0100
Subject: [PATCH] OO-4440: catch the error during selection of item and redraw
 the menu

---
 .../ui/AssessmentTestDisplayController.java   | 26 ++++++++++++-------
 1 file changed, 16 insertions(+), 10 deletions(-)

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 dee08f49bbe..aaeef071c03 100644
--- a/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
+++ b/src/main/java/org/olat/ims/qti21/ui/AssessmentTestDisplayController.java
@@ -842,17 +842,23 @@ public class AssessmentTestDisplayController extends BasicController implements
 			return;
 		}
 
-		TestPlanNodeKey nodeKey = TestPlanNodeKey.fromString(key);
-		Date requestTimestamp = ureq.getRequestTimestamp();
-		TestPlanNode selectedNode = testSessionController.selectItemNonlinear(requestTimestamp, nodeKey);
+		try {
+			TestPlanNodeKey nodeKey = TestPlanNodeKey.fromString(key);
+			Date requestTimestamp = ureq.getRequestTimestamp();
+			TestPlanNode selectedNode = testSessionController.selectItemNonlinear(requestTimestamp, nodeKey);
 
-		/* Record and log event */
-		TestPlanNodeKey selectedNodeKey = (selectedNode == null ? null : selectedNode.getKey());
-		NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
-		TestSessionState testSessionState = testSessionController.getTestSessionState();
-		CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry,
-				CandidateTestEventType.SELECT_MENU, null, selectedNodeKey,testSessionState, notificationRecorder);
-		candidateAuditLogger.logCandidateEvent(candidateEvent);
+			/* Record and log event */
+			TestPlanNodeKey selectedNodeKey = (selectedNode == null ? null : selectedNode.getKey());
+			NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
+			TestSessionState testSessionState = testSessionController.getTestSessionState();
+			CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry,
+					CandidateTestEventType.SELECT_MENU, null, selectedNodeKey,testSessionState, notificationRecorder);
+			candidateAuditLogger.logCandidateEvent(candidateEvent);
+		} catch (final QtiCandidateStateException e) {
+			logError("CANNOT_SELECT_MENU", e);//log informations
+			ServletUtil.printOutRequestParameters(ureq.getHttpReq());
+			mainVC.setDirty(true);// redraw the full panel -> browser view must be same as server states
+		}
 	}
 	
 	/**
-- 
GitLab