From 66f691ff9f97b9c3b06653c962706a55f51ee4c5 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Tue, 1 Sep 2020 15:59:58 +0200
Subject: [PATCH] OO-4678: back button support in user coaching's overview

---
 ...bCreator.java => TabComponentCreator.java} |   2 +-
 .../tabbedpane/TabControllerCreator.java      |  35 +++++
 .../gui/components/tabbedpane/TabbedPane.java |  74 ++++++----
 .../tabbedpane/TabbedPaneChangedEvent.java    |  10 +-
 .../ui/UserRelationOverviewController.java    | 126 ++++++++++--------
 .../CourseListWrapperController.java          |  37 +++--
 .../CurriculumElementListController.java      |   7 +-
 7 files changed, 197 insertions(+), 94 deletions(-)
 rename src/main/java/org/olat/core/gui/components/tabbedpane/{TabCreator.java => TabComponentCreator.java} (96%)
 create mode 100644 src/main/java/org/olat/core/gui/components/tabbedpane/TabControllerCreator.java

diff --git a/src/main/java/org/olat/core/gui/components/tabbedpane/TabCreator.java b/src/main/java/org/olat/core/gui/components/tabbedpane/TabComponentCreator.java
similarity index 96%
rename from src/main/java/org/olat/core/gui/components/tabbedpane/TabCreator.java
rename to src/main/java/org/olat/core/gui/components/tabbedpane/TabComponentCreator.java
index 334add4fd93..87b2889ae2a 100644
--- a/src/main/java/org/olat/core/gui/components/tabbedpane/TabCreator.java
+++ b/src/main/java/org/olat/core/gui/components/tabbedpane/TabComponentCreator.java
@@ -28,7 +28,7 @@ import org.olat.core.gui.components.Component;
  * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
  *
  */
-public interface TabCreator {
+public interface TabComponentCreator {
 	
 	public Component create(UserRequest ureq);
 
diff --git a/src/main/java/org/olat/core/gui/components/tabbedpane/TabControllerCreator.java b/src/main/java/org/olat/core/gui/components/tabbedpane/TabControllerCreator.java
new file mode 100644
index 00000000000..5c9c06c0ca7
--- /dev/null
+++ b/src/main/java/org/olat/core/gui/components/tabbedpane/TabControllerCreator.java
@@ -0,0 +1,35 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.core.gui.components.tabbedpane;
+
+import org.olat.core.gui.UserRequest;
+import org.olat.core.gui.control.Controller;
+
+/**
+ * 
+ * Initial date: 1 sept. 2020<br>
+ * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
+ *
+ */
+public interface TabControllerCreator {
+	
+	public Controller create(UserRequest ureq);
+
+}
diff --git a/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPane.java b/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPane.java
index da490a4fbae..3c8e61c32aa 100644
--- a/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPane.java
+++ b/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPane.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import org.apache.logging.log4j.Logger;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.Component;
 import org.olat.core.gui.components.ComponentRenderer;
@@ -42,7 +43,6 @@ import org.olat.core.id.OLATResourceable;
 import org.olat.core.id.context.BusinessControlFactory;
 import org.olat.core.id.context.ContextEntry;
 import org.olat.core.id.context.StateEntry;
-import org.apache.logging.log4j.Logger;
 import org.olat.core.logging.Tracing;
 import org.olat.core.util.Util;
 import org.olat.core.util.resource.OresHelper;
@@ -83,31 +83,24 @@ public class TabbedPane extends Container implements Activateable2 {
 		this.hideDisabledTab = hideDisabledTab;
 	}
 
-	/**
-	 * @see org.olat.core.gui.components.Component#dispatchRequest(org.olat.core.gui.UserRequest)
-	 */
 	@Override
 	protected void doDispatchRequest(UserRequest ureq) {
 		// the taid indicates which tab the user clicked
-		String s_taid = ureq.getParameter(PARAM_PANE_ID);
+		String taid = ureq.getParameter(PARAM_PANE_ID);
 		try {
-			int newTaid = Integer.parseInt(s_taid);
+			int newTaid = Integer.parseInt(taid);
 			dispatchRequest(ureq, newTaid);
 		} catch (NumberFormatException e) {
-			log.warn("Not a number: " + s_taid);
+			log.warn("Not a number: {}", taid);
 		}
 	}
 
-	/**
-	 * @param ureq
-	 * @param newTaid
-	 */
 	private void dispatchRequest(UserRequest ureq, int newTaid) {
 		if (isEnabled(newTaid) && newTaid >= 0 && newTaid < getTabCount()) {
 			TabPane pane = getTabPaneAt(selectedPane);	
 			setSelectedPane(ureq, newTaid);
 			TabPane newPane = getTabPaneAt(selectedPane);
-			fireEvent(ureq, new TabbedPaneChangedEvent(pane.getComponent(), newPane.getComponent()));
+			fireEvent(ureq, new TabbedPaneChangedEvent(pane.getComponent(), newPane.getComponent(), newPane.getController()));
 		}
 	}
 	
@@ -127,7 +120,7 @@ public class TabbedPane extends Container implements Activateable2 {
 		selectedPane = newSelectedPane;
 		TabPane newSelectedTab = getTabPaneAt(newSelectedPane);
 		Component component = newSelectedTab.getComponent();
-		if(component == null && newSelectedTab.getTabCreator() != null) {
+		if(component == null && newSelectedTab.hasTabCreator()) {
 			component = newSelectedTab.createComponent(ureq);
 		}
 		super.put("atp", component); 
@@ -166,7 +159,20 @@ public class TabbedPane extends Container implements Activateable2 {
 		return tabPanes.size() - 1;
 	}
 	
-	public int addTab(UserRequest ureq, String displayName, TabCreator creator) {
+	public int addTab(UserRequest ureq, String displayName, TabComponentCreator creator) {
+		TabPane tab = new TabPane(displayName, creator);
+		tabPanes.add(tab);
+		if (selectedPane == -1) {
+			selectedPane = 0; // if no pane has been selected, select the first one
+			if(tab.getComponent() == null) {
+				tab.createComponent(ureq);
+			}
+			super.put("atp", tab.getComponent()); 
+		}
+		return tabPanes.size() - 1;
+	}
+	
+	public int addTabControllerCreator(UserRequest ureq, String displayName, TabControllerCreator creator) {
 		TabPane tab = new TabPane(displayName, creator);
 		tabPanes.add(tab);
 		if (selectedPane == -1) {
@@ -210,6 +216,15 @@ public class TabbedPane extends Container implements Activateable2 {
 		return -1;
 	}
 	
+	public int indexOfTab(Controller controller) {
+		for(int i=tabPanes.size(); i-->0; ) {
+			if(tabPanes.get(i).getController() == controller) {
+				return i;
+			}
+		}
+		return -1;
+	}
+	
 	public boolean containsTab(String displayName) {
 		boolean found = false;
 		for(int i=tabPanes.size(); i-->0; ) {
@@ -294,10 +309,10 @@ public class TabbedPane extends Container implements Activateable2 {
 	}
 
 	/**
-	 * @return
+	 * @return The number of tabs
 	 */
 	protected int getTabCount() {
-		return (tabPanes == null ? 0 : tabPanes.size());
+		return tabPanes.size();
 	}
 
 	/**
@@ -336,9 +351,6 @@ public class TabbedPane extends Container implements Activateable2 {
 		}
 	}
 
-	/**
-	 * @see org.olat.core.gui.components.Component#getExtendedDebugInfo()
-	 */
 	@Override
 	public String getExtendedDebugInfo() {
 		return "selectedPane:" + selectedPane;
@@ -393,7 +405,8 @@ public class TabbedPane extends Container implements Activateable2 {
 		private final String displayName;
 		private Component component;
 		private Controller controller;
-		private TabCreator creator;
+		private TabComponentCreator componentCreator;
+		private TabControllerCreator controllerCreator;
 		
 		public TabPane(String displayName, Component component) {
 			this.displayName = displayName;
@@ -408,9 +421,15 @@ public class TabbedPane extends Container implements Activateable2 {
 			this.enabled = true;
 		}
 		
-		public TabPane(String displayName, TabCreator creator) {
+		public TabPane(String displayName, TabComponentCreator componentCreator) {
+			this.displayName = displayName;
+			this.componentCreator = componentCreator;
+			this.enabled = true;
+		}
+		
+		public TabPane(String displayName, TabControllerCreator controllerCreator) {
 			this.displayName = displayName;
-			this.creator = creator;
+			this.controllerCreator = controllerCreator;
 			this.enabled = true;
 		}
 		
@@ -426,12 +445,17 @@ public class TabbedPane extends Container implements Activateable2 {
 			return displayName;
 		}
 		
-		public TabCreator getTabCreator() {
-			return creator;
+		public boolean hasTabCreator() {
+			return componentCreator != null || controllerCreator != null;
 		}
 		
 		public Component createComponent(UserRequest ureq) {
-			component = creator.create(ureq);
+			if(componentCreator != null) {
+				component = componentCreator.create(ureq);
+			} else if(controllerCreator != null) {
+				controller = controllerCreator.create(ureq);
+				component = controller.getInitialComponent();
+			}
 			return component;
 		}
 		
diff --git a/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPaneChangedEvent.java b/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPaneChangedEvent.java
index 86461ddc97e..55b8d49ec08 100644
--- a/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPaneChangedEvent.java
+++ b/src/main/java/org/olat/core/gui/components/tabbedpane/TabbedPaneChangedEvent.java
@@ -27,6 +27,7 @@
 package org.olat.core.gui.components.tabbedpane;
 
 import org.olat.core.gui.components.Component;
+import org.olat.core.gui.control.Controller;
 import org.olat.core.gui.control.Event;
 
 /**
@@ -43,15 +44,17 @@ public class TabbedPaneChangedEvent extends Event {
 
 	private Component oldComponent;
 	private Component newComponent;
+	private Controller newController;
 
 	/**
 	 * @param oldComponent
 	 * @param newComponent
 	 */
-	public TabbedPaneChangedEvent(Component oldComponent, Component newComponent) {
+	public TabbedPaneChangedEvent(Component oldComponent, Component newComponent, Controller newController) {
 		super(TAB_CHANGED);
 		this.oldComponent = oldComponent;
 		this.newComponent = newComponent;
+		this.newController = newController;
 	}
 
 	/**
@@ -60,6 +63,11 @@ public class TabbedPaneChangedEvent extends Event {
 	public Component getNewComponent() {
 		return newComponent;
 	}
+	
+	
+	public Controller getNewController() {
+		return newController;
+	}
 
 	/**
 	 * @return Returns the oldComponent.
diff --git a/src/main/java/org/olat/modules/coach/ui/UserRelationOverviewController.java b/src/main/java/org/olat/modules/coach/ui/UserRelationOverviewController.java
index f920e680753..39ca41f590d 100644
--- a/src/main/java/org/olat/modules/coach/ui/UserRelationOverviewController.java
+++ b/src/main/java/org/olat/modules/coach/ui/UserRelationOverviewController.java
@@ -20,9 +20,7 @@
 package org.olat.modules.coach.ui;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.olat.admin.user.UserChangePasswordController;
 import org.olat.admin.user.UserShortDescription;
@@ -42,12 +40,12 @@ import org.olat.core.gui.components.stack.TooledController;
 import org.olat.core.gui.components.stack.TooledStackedPanel;
 import org.olat.core.gui.components.stack.TooledStackedPanel.Align;
 import org.olat.core.gui.components.tabbedpane.TabbedPane;
+import org.olat.core.gui.components.tabbedpane.TabbedPaneChangedEvent;
 import org.olat.core.gui.components.velocity.VelocityContainer;
 import org.olat.core.gui.control.Controller;
 import org.olat.core.gui.control.Event;
 import org.olat.core.gui.control.WindowControl;
 import org.olat.core.gui.control.controller.BasicController;
-import org.olat.core.gui.control.creator.ControllerCreator;
 import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
 import org.olat.core.gui.control.generic.dtabs.Activateable2;
 import org.olat.core.gui.control.generic.spacesaver.ToggleBoxController;
@@ -103,8 +101,16 @@ public class UserRelationOverviewController extends BasicController implements A
 	private static final String CMD_PROFILE = "Profile";
 	private static final String CMD_ENROLLMENTS = "Enrollments";
 
-	private VelocityContainer mainVC;
+	private final VelocityContainer mainVC;
 
+	private int orderTabIndex;
+	private int courseTabIndex;
+	private int lecturesTabIndex;
+	private int certificatesTabIndex;
+	private int groupTabIndex;
+	private int calendarTabIndex;
+	private int profileTabIndex;
+	
 	private Link homeLink, contactLink, resetLink;
 	private Link nextStudent, detailsStudentCmp, previousStudent;
 
@@ -126,7 +132,6 @@ public class UserRelationOverviewController extends BasicController implements A
 	private CourseListWrapperController courseListWrapperController;
 
 	private TabbedPane functionsTabbedPane;
-	private Map<Integer, String> positionsMap;
 
 	private final int index;
 	private final int numOfStudents;
@@ -161,12 +166,11 @@ public class UserRelationOverviewController extends BasicController implements A
 		this.numOfStudents = numOfStudents;
 		this.userRelationSecurityCallback = userRelationSecurityCallback;
 		this.relationRole = relationRole;
-		this.positionsMap = new HashMap<>();
 
 		mainVC = createVelocityContainer("user_relation_overview");
 
 		initUserDetails(ureq, mentee);
-		initTabbedPane(ureq, mentee);
+		initTabbedPane(ureq);
 
 		putInitialPanel(mainVC);
 	}
@@ -236,74 +240,74 @@ public class UserRelationOverviewController extends BasicController implements A
 		userShortDescriptionController = new UserShortDescription(ureq, getWindowControl(), identity, userRelationSecurityCallback.isAdministrativeUser());
 		userDetails.put("userShortDescription", userShortDescriptionController.getInitialComponent());
 	}
+	
 
-	private void initTabbedPane(UserRequest ureq, Identity identity) {
+
+	private void initTabbedPane(UserRequest ureq) {
 		functionsTabbedPane = new TabbedPane("functionsTabbedPane", ureq.getLocale());
 		functionsTabbedPane.addListener(this);
-		int totalTabs = 0;
 
 		if (userRelationSecurityCallback.canViewCoursesAndCurriculum()) {
 			List<CurriculumRef> curriculumRefs = curriculumService.getMyActiveCurriculumRefs(mentee);
 			CurriculumSecurityCallback curriculumSecurityCallback = CurriculumSecurityCallbackFactory.createDefaultCallback();
 
-			functionsTabbedPane.addTab(ureq, translate("enrollments"), uureq -> {
-				courseListWrapperController = new CourseListWrapperController(uureq, getWindowControl(), stackPanel, mentee, curriculumSecurityCallback, userRelationSecurityCallback, curriculumRefs, statEntry);
+			courseTabIndex = functionsTabbedPane.addTabControllerCreator(ureq, translate("enrollments"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_ENROLLMENTS), null);
+				courseListWrapperController = new CourseListWrapperController(uureq, bwControl, stackPanel, mentee, curriculumSecurityCallback, userRelationSecurityCallback, curriculumRefs, statEntry);
 				listenTo(courseListWrapperController);
-				return courseListWrapperController.getInitialComponent();
+				return courseListWrapperController;
 			});
-			positionsMap.put(totalTabs++, CMD_ENROLLMENTS);
 		}
 
 		if (userRelationSecurityCallback.canViewResourcesAndBookings()) {
-			functionsTabbedPane.addTab(ureq, translate("bookings"), uureq -> {
-				userOrderController = new UserOrderController(uureq, getWindowControl(), mentee);
+			orderTabIndex = functionsTabbedPane.addTabControllerCreator(ureq, translate("bookings"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_BOOKINGS), null);
+				userOrderController = new UserOrderController(uureq, bwControl, mentee);
 				listenTo(userOrderController);
-				return userOrderController.getInitialComponent();
+				return userOrderController;
 			});
-			positionsMap.put(totalTabs++, CMD_BOOKINGS);
 		}
 
 		if (lectureModule.isEnabled() && userRelationSecurityCallback.canViewLecturesAndAbsences()) {
-			functionsTabbedPane.addTab(ureq, translate("lectures"), uureq -> {
-				lecturesController = new ParticipantLecturesOverviewController(uureq, getWindowControl(), mentee, null, true, true, true, true, false, true);
+			lecturesTabIndex = functionsTabbedPane.addTabControllerCreator(ureq, translate("lectures"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_LECTURES), null);
+				lecturesController = new ParticipantLecturesOverviewController(uureq, bwControl, mentee, null, true, true, true, true, false, true);
 				lecturesController.setBreadcrumbPanel(stackPanel);
 				listenTo(lecturesController);
-				return lecturesController.getInitialComponent();
+				return lecturesController;
 			});
-			positionsMap.put(totalTabs++, CMD_LECTURES);
 		}
 
 		if (userRelationSecurityCallback.canViewEfficiencyStatements()) {
-			functionsTabbedPane.addTab(ureq, translate("statements"), uureq -> {
-				efficiencyStatementListController = new CertificateAndEfficiencyStatementListController(ureq, getWindowControl(), mentee, true);
+			certificatesTabIndex = functionsTabbedPane.addTabControllerCreator(ureq, translate("statements"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_STATEMENTS), null);
+				efficiencyStatementListController = new CertificateAndEfficiencyStatementListController(ureq, bwControl, mentee, true);
 				efficiencyStatementListController.setBreadcrumbPanel(stackPanel);
 				listenTo(efficiencyStatementListController);
-				return efficiencyStatementListController.getInitialComponent();
+				return efficiencyStatementListController;
 			});
-			positionsMap.put(totalTabs++, CMD_STATEMENTS);
 		}
 
 		if (userRelationSecurityCallback.canViewGroupMemberships()) {
-			functionsTabbedPane.addTab(ureq, translate("groups.menu.title"), uureq -> {
-				groupOverviewController = new GroupOverviewController(ureq, getWindowControl(), mentee, false, false);
+			groupTabIndex = functionsTabbedPane.addTab(ureq, translate("groups.menu.title"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_GROUPS), null);
+				groupOverviewController = new GroupOverviewController(ureq, bwControl, mentee, false, false);
 				listenTo(groupOverviewController);
 				return groupOverviewController.getInitialComponent();
 			});
-			positionsMap.put(totalTabs++, CMD_GROUPS);
 		}
 
 		if (userRelationSecurityCallback.canViewCalendar()) {
-			functionsTabbedPane.addTab(ureq, translate("calendar"), uureq -> doOpenCalendar(uureq).getInitialComponent());
-			positionsMap.put(totalTabs++, CMD_CALENDAR);
+			calendarTabIndex = functionsTabbedPane.addTab(ureq, translate("calendar"), uureq -> doOpenCalendar(uureq).getInitialComponent());
 		}
 
 		if (userRelationSecurityCallback.canViewAndEditProfile()) {
-			functionsTabbedPane.addTab(ureq, translate("profile"), uureq -> {
-				profileAndHomePageEditController =  new ProfileAndHomePageEditController(ureq, getWindowControl(), identity, userRelationSecurityCallback.isAdministrativeUser());
+			profileTabIndex = functionsTabbedPane.addTab(ureq, translate("profile"), uureq -> {
+				WindowControl bwControl = addToHistory(uureq, OresHelper.createOLATResourceableType(CMD_PROFILE), null);
+				profileAndHomePageEditController =  new ProfileAndHomePageEditController(ureq, bwControl, mentee, userRelationSecurityCallback.isAdministrativeUser());
 				listenTo(profileAndHomePageEditController);
 				return profileAndHomePageEditController.getInitialComponent();
-			} );
-			positionsMap.put(totalTabs, CMD_PROFILE);
+			});
 		}
 
 		mainVC.put("functionsTabbedPane", functionsTabbedPane);
@@ -318,15 +322,13 @@ public class UserRelationOverviewController extends BasicController implements A
 
 	@Override
 	public void event(Event event) {
-
+		//
 	}
 
 	public StudentStatEntry getEntry() {
 		return statEntry;
 	}
 
-
-
 	@Override
 	public void event(UserRequest ureq, Component source, Event event) {
 		if(previousStudent == source || nextStudent == source) {
@@ -338,8 +340,12 @@ public class UserRelationOverviewController extends BasicController implements A
 		} else if (source == resetLink) {
 			resetPassword(ureq);
 		} else if (source == functionsTabbedPane) {
-			OLATResourceable ores = OresHelper.createOLATResourceableType(positionsMap.get(functionsTabbedPane.getSelectedPane()));
-			addToHistory(ureq, ores, null);
+			if(event instanceof TabbedPaneChangedEvent) {
+				TabbedPaneChangedEvent pce = (TabbedPaneChangedEvent)event;
+				if(pce.getNewController() != null) {
+					addToHistory(ureq, pce.getNewController());
+				}
+			}
 		}
 	}
 
@@ -372,23 +378,30 @@ public class UserRelationOverviewController extends BasicController implements A
 	public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
 		if(entries == null || entries.isEmpty()) return;
 
-		ContextEntry ce = entries.get(0);
-		OLATResourceable ores = ce.getOLATResourceable();
-		String oresName = ores.getResourceableTypeName();
-
-		if (positionsMap.values().contains(oresName)) {
-			functionsTabbedPane.setSelectedPane(ureq, positionsMap.entrySet().stream().filter(entry -> entry.getValue().equals(oresName)).findAny().get().getKey());
-			List<ContextEntry> subEntries = entries.subList(1, entries.size());
-
-			Controller controller = functionsTabbedPane.getSelectedController();
-
-			if (controller == null) {
-			} else {
-				if (functionsTabbedPane.getSelectedController() instanceof ControllerCreator) {
-					Activateable2 selectedCtrl = (Activateable2) functionsTabbedPane.getSelectedController();
-					selectedCtrl.activate(ureq, subEntries, ce.getTransientState());
-				}
+		String type = entries.get(0).getOLATResourceable().getResourceableTypeName();
+		if(CMD_ENROLLMENTS.equalsIgnoreCase(type) && courseTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, courseTabIndex);
+			if(courseListWrapperController != null) {
+				courseListWrapperController.activate(ureq, entries.subList(1, entries.size()), null);
+			}
+		} else if(CMD_BOOKINGS.equalsIgnoreCase(type) && orderTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, orderTabIndex);
+		} else if(CMD_LECTURES.equalsIgnoreCase(type) && lecturesTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, lecturesTabIndex);
+			if(lecturesController != null) {
+				lecturesController.activate(ureq, entries.subList(1, entries.size()), null);
+			}
+		} else if(CMD_CALENDAR.equalsIgnoreCase(type) && calendarTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, calendarTabIndex);
+			if(calendarController != null) {
+				calendarController.activate(ureq, entries.subList(1, entries.size()), null);
 			}
+		} else if(CMD_STATEMENTS.equalsIgnoreCase(type) && certificatesTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, certificatesTabIndex);
+		} else if(CMD_GROUPS.equalsIgnoreCase(type) && groupTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, groupTabIndex);
+		} else if(CMD_PROFILE.equalsIgnoreCase(type) && profileTabIndex >= 0) {
+			functionsTabbedPane.setSelectedPane(ureq, profileTabIndex);
 		}
 	}
 
@@ -446,7 +459,8 @@ public class UserRelationOverviewController extends BasicController implements A
 		calendars.add(calendarWrapper);
 
 		OLATResourceable callerOres = OresHelper.createOLATResourceableInstance(mentee.getName(), mentee.getKey());
-		calendarController = new WeeklyCalendarController(ureq, getWindowControl(), calendars,
+		WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType(CMD_CALENDAR), null);
+		calendarController = new WeeklyCalendarController(ureq, bwControl, calendars,
 				CalendarController.CALLER_CURRICULUM, callerOres, false);
 		listenTo(calendarController);
 
diff --git a/src/main/java/org/olat/modules/coach/ui/curriculum/CourseListWrapperController.java b/src/main/java/org/olat/modules/coach/ui/curriculum/CourseListWrapperController.java
index b40e7e0ff9d..a1544fec257 100644
--- a/src/main/java/org/olat/modules/coach/ui/curriculum/CourseListWrapperController.java
+++ b/src/main/java/org/olat/modules/coach/ui/curriculum/CourseListWrapperController.java
@@ -1,3 +1,22 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
 package org.olat.modules.coach.ui.curriculum;
 
 import java.util.List;
@@ -27,8 +46,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 public class CourseListWrapperController extends BasicController implements Activateable2, GenericEventListener {
 
-    private final static String WITH_CURRICULUM = "Curriculum";
-    private final static String WITHOUT_CURRICULM = "List";
+    private static final String WITH_CURRICULUM = "Curriculum";
+    private static final String WITHOUT_CURRICULM = "List";
 
     private final TooledStackedPanel stackPanel;
     private final Identity mentee;
@@ -112,43 +131,41 @@ public class CourseListWrapperController extends BasicController implements Acti
 
     @Override
     public void event(Event event) {
-
+    	//
     }
 
     @Override
     protected void doDispose() {
-
+    	//
     }
 
     public Activateable2 showCurriculumStructure(UserRequest ureq) {
         showCurriculum = true;
 
-        WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(WITH_CURRICULUM, 0l), null);
-
         if (curriculumListController == null) {
+            WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType(WITH_CURRICULUM), null);
             curriculumListController = new CurriculumElementListController(ureq, bwControl, stackPanel, mentee, curriculumRefs, curriculumSecurityCallback, userRelationSecurityCallback);
             listenTo(curriculumListController);
         }
 
         content.contextPut("showCurriculum", showCurriculum);
         content.put("content", curriculumListController.getInitialComponent());
-
+    	addToHistory(ureq, curriculumListController);
         return curriculumListController;
     }
 
     public Activateable2 hideCurriculumStructure(UserRequest ureq) {
         showCurriculum = false;
 
-        WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(WITHOUT_CURRICULM, 0l), null);
-
         if (userRelationEnrollmentListController == null) {
+            WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType(WITHOUT_CURRICULM), null);
             userRelationEnrollmentListController = new UserRelationEnrollmentListController(ureq, bwControl, stackPanel, statEntry, mentee, userRelationSecurityCallback);
             listenTo(userRelationEnrollmentListController);
         }
 
         content.contextPut("showCurriculum", showCurriculum);
         content.put("content", userRelationEnrollmentListController.getInitialComponent());
-
+    	addToHistory(ureq, userRelationEnrollmentListController);
         return userRelationEnrollmentListController;
     }
 }
diff --git a/src/main/java/org/olat/modules/coach/ui/curriculum/CurriculumElementListController.java b/src/main/java/org/olat/modules/coach/ui/curriculum/CurriculumElementListController.java
index 5a87d5cc8c7..a728565415f 100644
--- a/src/main/java/org/olat/modules/coach/ui/curriculum/CurriculumElementListController.java
+++ b/src/main/java/org/olat/modules/coach/ui/curriculum/CurriculumElementListController.java
@@ -31,6 +31,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.olat.NewControllerFactory;
+import org.olat.basesecurity.BaseSecurity;
 import org.olat.core.commons.services.mark.Mark;
 import org.olat.core.commons.services.mark.MarkManager;
 import org.olat.core.dispatcher.mapper.MapperService;
@@ -157,6 +158,8 @@ public class CurriculumElementListController extends FormBasicController impleme
     private RepositoryManager repositoryManager;
     @Autowired
     private AssessmentService assessmentService;
+    @Autowired
+    private BaseSecurity securityManager;
 
     public CurriculumElementListController(UserRequest ureq, WindowControl wControl, BreadcrumbPanel stackPanel,
                                            Identity assessedIdentity, List<CurriculumRef> curriculumRefList, CurriculumSecurityCallback curriculumSecurityCallback, UserRelationSecurityCallback userRelationSecurityCallback) {
@@ -358,7 +361,9 @@ public class CurriculumElementListController extends FormBasicController impleme
             }
         }
 
-        SearchMyRepositoryEntryViewParams params = new SearchMyRepositoryEntryViewParams(assessedIdentity, roles);
+        Roles assessedRoles = securityManager.getRoles(assessedIdentity);
+        SearchMyRepositoryEntryViewParams params = new SearchMyRepositoryEntryViewParams(assessedIdentity, assessedRoles);
+        params.setMembershipMandatory(true);
         List<RepositoryEntryMyView> courses = repositoryService.searchMyView(params, 0, 0);
         // Filter for entries which are already in a curriculum
 
-- 
GitLab