From 10bf7baa9947067f52102f642910415394c69da0 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Fri, 13 Jul 2012 10:55:45 +0200
Subject: [PATCH] OO-291: make the course preview and the contact (e-mail)
 course building block works

---
 .../user/groups/GroupOverviewController.java  |   2 +-
 .../collaboration/CollaborationTools.java     |   6 +-
 .../CollaborationToolsFactory.java            |   2 +-
 .../java/org/olat/course/CourseFactory.java   |   7 +-
 .../condition/AreaSelectionController.java    |  10 +
 .../ConditionConfigEasyController.java        |  50 +-
 .../condition/GroupSelectionController.java   |  10 +
 .../course/editor/EditorMainController.java   |   2 +-
 .../groupsandrights/CourseGroupManager.java   |  11 +
 .../PersistingCourseGroupManager.java         |  42 ++
 .../CourseGroupManagementMainController.java  |  58 +-
 .../org/olat/course/nodes/COCourseNode.java   |  98 +++-
 .../olat/course/nodes/co/COConfigForm.java    | 509 ++++++++++--------
 .../course/nodes/co/COEditController.java     |   6 +
 .../olat/course/nodes/co/CORunController.java |  92 +++-
 .../course/nodes/en/EnrollmentManager.java    |   6 +-
 .../olat/course/nodes/iq/IQRunController.java |   2 +-
 .../service/ProjectGroupManagerImpl.java      |   6 +-
 .../olat/course/run/RunMainController.java    |   3 +-
 .../run/preview/PreviewConfigController.java  |  49 +-
 .../preview/PreviewCourseGroupManager.java    |  55 +-
 .../run/preview/PreviewRunController.java     |  28 +-
 .../run/preview/PreviewSettingsForm.java      |  79 +--
 .../olat/group/BusinessGroupManagerImpl.java  |   4 +-
 .../olat/group/area/BGAreaManagerImpl.java    |   4 +-
 .../group/LearningGroupWebService.java        |   8 +-
 .../org/olat/upgrade/OLATUpgrade_8_2_0.java   |  15 +-
 27 files changed, 697 insertions(+), 467 deletions(-)

diff --git a/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java b/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java
index f654fb2f79f..ddeb447feac 100644
--- a/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java
+++ b/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java
@@ -298,7 +298,7 @@ public class GroupOverviewController extends BasicController {
 
 			// 2) remove as participant
 			final BusinessGroup toRemFromGroup = currBusinessGroup;
-			//TODO gm sync
+			//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(currBusinessGroup, new SyncerExecutor() {
 				public void execute() {
 					businessGroupService.removeParticipant(getIdentity(), identity, toRemFromGroup, flags);
diff --git a/src/main/java/org/olat/collaboration/CollaborationTools.java b/src/main/java/org/olat/collaboration/CollaborationTools.java
index 80e2d9d95bf..02afc10a14d 100644
--- a/src/main/java/org/olat/collaboration/CollaborationTools.java
+++ b/src/main/java/org/olat/collaboration/CollaborationTools.java
@@ -316,7 +316,7 @@ public class CollaborationTools implements Serializable {
 		//final List<Forum> forumHolder = new ArrayList<Forum>();
 		
 		Codepoint.codepoint(CollaborationTools.class, "pre_sync_enter");
-	//TODO gm sync
+	//TODO gsync
 		Forum forum = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>(){
 			public Forum execute() {
 				
@@ -536,7 +536,7 @@ public class CollaborationTools implements Serializable {
 	public Controller createPortfolioController(final UserRequest ureq, WindowControl wControl, final BusinessGroup group) {
 		final EPFrontendManager ePFMgr = (EPFrontendManager)CoreSpringFactory.getBean("epFrontendManager");
 		final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
-	//TODO gm sync
+	//TODO gsync
 		PortfolioStructureMap map = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<PortfolioStructureMap>(){
 			public PortfolioStructureMap execute() {
 				PortfolioStructureMap aMap;
@@ -675,7 +675,7 @@ public class CollaborationTools implements Serializable {
 		// handle Boolean Values via String Field in Property DB Table
 		final String toolValueStr = toolValue ? TRUE : FALSE;
 		final PropertyManager pm = PropertyManager.getInstance();
-		//TODO gm sync
+		//TODO gsync
 		coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
 			public void execute() {				
 				//was: synchronized (CollaborationTools.class) {
diff --git a/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java b/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java
index f76b3b58234..65c3e07d679 100644
--- a/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java
+++ b/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java
@@ -76,7 +76,7 @@ public class CollaborationToolsFactory {
 		if (ores == null) throw new AssertException("Null is not allowed here, you have to provide an existing ores here!");
 		final String cacheKey = Long.valueOf(ores.getResourceableId()).toString();
 		//sync operation cluster wide
-	//TODO gm sync
+	//TODO gsync
 		return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<CollaborationTools>() {
 			
 			public CollaborationTools execute() {
diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java
index cd022218e8f..dc4509c1cc6 100644
--- a/src/main/java/org/olat/course/CourseFactory.java
+++ b/src/main/java/org/olat/course/CourseFactory.java
@@ -1030,10 +1030,9 @@ public class CourseFactory extends BasicManager {
 		//close courseEditSession if not already closed
 		closeCourseEditSession(resourceableId, false);
 	}
-
-	public static Controller createDisposedCourseRestartController(UserRequest ureq, WindowControl wControl, long resId) {
-		RepositoryEntry courseRepositoryEntry = RepositoryManager.getInstance().lookupRepositoryEntry(resId);
-		return new DisposedCourseRestartController(ureq, wControl, courseRepositoryEntry);
+	
+	public static Controller createDisposedCourseRestartController(UserRequest ureq, WindowControl wControl, RepositoryEntry re) {
+		return new DisposedCourseRestartController(ureq, wControl, re);
 	}
 
 	/**
diff --git a/src/main/java/org/olat/course/condition/AreaSelectionController.java b/src/main/java/org/olat/course/condition/AreaSelectionController.java
index c23325687d9..16aef594bd4 100644
--- a/src/main/java/org/olat/course/condition/AreaSelectionController.java
+++ b/src/main/java/org/olat/course/condition/AreaSelectionController.java
@@ -165,6 +165,16 @@ public class AreaSelectionController extends FormBasicController {
 		return entrySelector.getSelectedKeys();
 	}
 	
+	public List<String> getSelectedNames() {
+		List<String> selectedNames = new ArrayList<String>();
+		for(int i=0; i<areaKeys.length; i++) {
+			if(entrySelector.isSelected(i)) {
+				selectedNames.add(areaNames[i]);
+			}
+		}
+		return selectedNames;
+	}
+	
 	public List<Long> getSelectedKeys() {
 		Set<String> selectedKeys = entrySelector.getSelectedKeys();
 		List<Long> groupKeys = new ArrayList<Long>();
diff --git a/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java b/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java
index ea522808b9e..ccf7d651c3a 100644
--- a/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java
+++ b/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java
@@ -338,8 +338,7 @@ public class ConditionConfigEasyController extends FormBasicController implement
 			removeAsListenerAndDispose(groupCreateCtlr);
 			
 			OLATResource courseResource = courseEditorEnv.getCourseGroupManager().getCourseResource();
-			String csvGroupName = isEmpty(easyGroupList) ? null : getGroupNames(getKeys(easyGroupList));
-			groupCreateCtlr = new NewBGController(ureq, getWindowControl(),  true, courseResource, true, csvGroupName);
+			groupCreateCtlr = new NewBGController(ureq, getWindowControl(),  true, courseResource, true, null);
 			listenTo(groupCreateCtlr);
 			cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCtlr.getInitialComponent());
 			listenTo(cmc);
@@ -361,9 +360,8 @@ public class ConditionConfigEasyController extends FormBasicController implement
 			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose(areaCreateCtlr);
 
-			String csvAreaName = isEmpty(easyAreaList) ? null : getAreaNames(getKeys(easyAreaList));
 			OLATResource courseResource = courseEditorEnv.getCourseGroupManager().getCourseResource();
-			areaCreateCtlr = new NewAreaController(ureq, getWindowControl(), courseResource, true, csvAreaName);
+			areaCreateCtlr = new NewAreaController(ureq, getWindowControl(), courseResource, true, null);
 			listenTo(areaCreateCtlr);
 
 			cmc = new CloseableModalController(getWindowControl(), "close",areaCreateCtlr.getInitialComponent());
@@ -1211,28 +1209,6 @@ public class ConditionConfigEasyController extends FormBasicController implement
 		
 		updateGroupsAndAreasCheck();
 	}
-	
-	private String getGroupNames(List<Long> keys) {
-		StringBuilder sb = new StringBuilder();
-		List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(keys);
-		for(BusinessGroupShort group:groups) {
-			if(sb.length() > 0) sb.append(", ");
-			sb.append(group.getName());
-		}
-		return sb.toString();
-	}
-	
-	private String getAreaNames(List<Long> keys) {
-		StringBuilder sb = new StringBuilder();
-		for(Long key:keys) {
-			BGArea area = areaManager.loadArea(key);
-			if(area != null) {
-				if(sb.length() > 0) sb.append(", ");
-				sb.append(area.getName());
-			}
-		}
-		return sb.toString();
-	}
 
 	private void addAssessmentSwitch(FormItemContainer formLayout, Controller listener) {
 
@@ -1411,4 +1387,26 @@ public class ConditionConfigEasyController extends FormBasicController implement
 		}
 		return sb.toString();
 	}
+	
+	private String getGroupNames(List<Long> keys) {
+		StringBuilder sb = new StringBuilder();
+		List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(keys);
+		for(BusinessGroupShort group:groups) {
+			if(sb.length() > 0) sb.append(", ");
+			sb.append(group.getName());
+		}
+		return sb.toString();
+	}
+	
+	private String getAreaNames(List<Long> keys) {
+		StringBuilder sb = new StringBuilder();
+		for(Long key:keys) {
+			BGArea area = areaManager.loadArea(key);
+			if(area != null) {
+				if(sb.length() > 0) sb.append(", ");
+				sb.append(area.getName());
+			}
+		}
+		return sb.toString();
+	}
 }
diff --git a/src/main/java/org/olat/course/condition/GroupSelectionController.java b/src/main/java/org/olat/course/condition/GroupSelectionController.java
index 5910a65c6a2..6ee2eb897ea 100644
--- a/src/main/java/org/olat/course/condition/GroupSelectionController.java
+++ b/src/main/java/org/olat/course/condition/GroupSelectionController.java
@@ -168,6 +168,16 @@ public class GroupSelectionController extends FormBasicController {
 		return entrySelector.getSelectedKeys();
 	}
 	
+	public List<String> getSelectedNames() {
+		List<String> selectedNames = new ArrayList<String>();
+		for(int i=0; i<groupKeys.length; i++) {
+			if(entrySelector.isSelected(i)) {
+				selectedNames.add(groupNames[i]);
+			}
+		}
+		return selectedNames;
+	}
+	
 	public List<Long> getSelectedKeys() {
 		Set<String> selectedKeys = entrySelector.getSelectedKeys();
 		List<Long> groupKeys = new ArrayList<Long>();
diff --git a/src/main/java/org/olat/course/editor/EditorMainController.java b/src/main/java/org/olat/course/editor/EditorMainController.java
index acd07815402..2a886f032d0 100644
--- a/src/main/java/org/olat/course/editor/EditorMainController.java
+++ b/src/main/java/org/olat/course/editor/EditorMainController.java
@@ -240,7 +240,7 @@ public class EditorMainController extends MainLayoutBasicController implements G
 			Panel empty = new Panel("empty");// empty panel set as "menu" and "tool"
 			OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", ores.getResourceableId());
 			RepositoryEntry repo = RepositoryManager.getInstance().lookupRepositoryEntry(courseOres, false);
-			Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, wControl, repo.getResourceableId());
+			Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, wControl, repo);
 			Controller disposedRestartController = new LayoutMain3ColsController(ureq, wControl, empty, empty,
 					courseCloser.getInitialComponent(), "disposed course" + course.getResourceableId());
 			setDisposedMsgController(disposedRestartController);
diff --git a/src/main/java/org/olat/course/groupsandrights/CourseGroupManager.java b/src/main/java/org/olat/course/groupsandrights/CourseGroupManager.java
index a4c8d1f02c3..ea55da24ab2 100644
--- a/src/main/java/org/olat/course/groupsandrights/CourseGroupManager.java
+++ b/src/main/java/org/olat/course/groupsandrights/CourseGroupManager.java
@@ -137,6 +137,7 @@ public interface CourseGroupManager {
 	 * @return A list of all learning groups with the given group name from all
 	 *         contexts of this course
 	 */
+	//TODO gm why is it needed?
 	public List<BusinessGroup> getLearningGroupsFromAllContexts(String groupName);
 	
 	public boolean existGroup(String nameOrKey);
@@ -255,6 +256,8 @@ public interface CourseGroupManager {
 	 */
 	public List<Identity> getCoachesFromLearningGroup(String groupName);
 	
+	public List<Identity> getCoachesFromLearningGroups(List<Long> groupKeys);
+	
 	//fxdiff VCRP-1,2: access control of resources
 	public List<Identity> getCoaches();
 
@@ -266,6 +269,8 @@ public interface CourseGroupManager {
 	 * @return a list with all coaches of this course
 	 */
 	public List<Identity> getCoachesFromArea(String areaName);
+	
+	public List<Identity> getCoachesFromAreas(List<Long> areaKeys);
 
 	/**
 	 * List with identities being participants in the learning groups of this course. If
@@ -276,6 +281,10 @@ public interface CourseGroupManager {
 	 */
 	public List<Identity> getParticipantsFromLearningGroup(String groupName);
 	
+	public List<Identity> getParticipantsFromLearningGroups(List<Long> groupKeys);
+	
+	
+	
 	//fxdiff VCRP-1,2: access control of resources
 	public List<Identity> getParticipants();
 
@@ -287,6 +296,8 @@ public interface CourseGroupManager {
 	 * @return a list with participants of this course
 	 */
 	public List<Identity> getParticipantsFromArea(String areaName);
+	
+	public List<Identity> getParticipantsFromAreas(List<Long> areaKeys);
 
 	/**
 	 * @param identity
diff --git a/src/main/java/org/olat/course/groupsandrights/PersistingCourseGroupManager.java b/src/main/java/org/olat/course/groupsandrights/PersistingCourseGroupManager.java
index 4e1a7fb3c50..69586259288 100644
--- a/src/main/java/org/olat/course/groupsandrights/PersistingCourseGroupManager.java
+++ b/src/main/java/org/olat/course/groupsandrights/PersistingCourseGroupManager.java
@@ -473,6 +473,26 @@ public class PersistingCourseGroupManager extends BasicManager implements Course
 		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
 	}
 	
+	@Override
+	public List<Identity> getCoachesFromLearningGroups(List<Long> groupKeys) {
+		List<BusinessGroup> bgs = businessGroupService.loadBusinessGroups(groupKeys);
+		List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>();
+		for(BusinessGroup group:bgs) {
+			secGroups.add(group.getOwnerGroup());
+		}
+		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
+	}
+	
+	@Override
+	public List<Identity> getParticipantsFromLearningGroups(List<Long> groupKeys) {
+		List<BusinessGroup> bgs = businessGroupService.loadBusinessGroups(groupKeys);
+		List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>();
+		for(BusinessGroup group:bgs) {
+			secGroups.add(group.getPartipiciantGroup());
+		}
+		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
+	}
+
 	@Override
 	//fxdiff VCRP-1,2: access control of resources
 	public List<Identity> getCoaches() {
@@ -512,6 +532,17 @@ public class PersistingCourseGroupManager extends BasicManager implements Course
 		}
 		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
 	}
+	
+	@Override
+	public List<Identity> getCoachesFromAreas(List<Long> areaKeys) {
+		List<BGArea> areas = areaManager.loadAreas(areaKeys);
+		List<BusinessGroup> groups = areaManager.findBusinessGroupsOfAreas(areas);
+		List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>();
+		for(BusinessGroup group:groups) {
+			secGroups.add(group.getOwnerGroup());
+		}
+		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
+	}
 
 	/**
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#getParticipantsFromArea(java.lang.String)
@@ -531,6 +562,17 @@ public class PersistingCourseGroupManager extends BasicManager implements Course
 		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
 	}
 
+	@Override
+	public List<Identity> getParticipantsFromAreas(List<Long> areaKeys) {
+		List<BGArea> areas = areaManager.loadAreas(areaKeys);
+		List<BusinessGroup> groups = areaManager.findBusinessGroupsOfAreas(areas);
+		List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>();
+		for(BusinessGroup group:groups) {
+			secGroups.add(group.getPartipiciantGroup());
+		}
+		return securityManager.getIdentitiesOfSecurityGroups(secGroups);
+	}
+
 	/**
 	 * 
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#getWaitingListGroupsFromAllContexts(org.olat.core.id.Identity)
diff --git a/src/main/java/org/olat/course/groupsandrights/ui/CourseGroupManagementMainController.java b/src/main/java/org/olat/course/groupsandrights/ui/CourseGroupManagementMainController.java
index 33382f2ae84..38a90311799 100644
--- a/src/main/java/org/olat/course/groupsandrights/ui/CourseGroupManagementMainController.java
+++ b/src/main/java/org/olat/course/groupsandrights/ui/CourseGroupManagementMainController.java
@@ -25,20 +25,12 @@
 
 package org.olat.course.groupsandrights.ui;
 
-import java.util.List;
-
-import org.olat.core.commons.fullWebApp.LayoutMain3ColsController;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.Component;
-import org.olat.core.gui.components.panel.Panel;
-import org.olat.core.gui.components.table.Table;
-import org.olat.core.gui.components.table.TableController;
-import org.olat.core.gui.components.table.TableEvent;
 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.MainLayoutBasicController;
-import org.olat.core.gui.control.generic.tool.ToolController;
 import org.olat.core.id.OLATResourceable;
 import org.olat.core.logging.activity.ActionType;
 import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
@@ -60,16 +52,9 @@ import org.olat.util.logging.activity.LoggingResourceable;
  * @author gnaegi
  */
 public class CourseGroupManagementMainController extends MainLayoutBasicController {
-	private static final String CMD_CLOSE = "cmd.close";
-
-	private Panel content;
 
-	private LayoutMain3ColsController columnLayoutCtr;
-	private ToolController toolC;
-	private TableController contextListCtr;
+	private final BGManagementController groupManageCtr;
 
-	private BGManagementController groupManageCtr;
-	private OLATResourceable ores;
 	
 	/**
 	 * Constructor for the course group management main controller
@@ -84,7 +69,6 @@ public class CourseGroupManagementMainController extends MainLayoutBasicControll
 		
 		getUserActivityLogger().setStickyActionType(ActionType.admin);
 		
-		this.ores = ores;
 		// set user activity logger for this controller
 		ICourse course = CourseFactory.loadCourse(ores);
 		addLoggingResourceable(LoggingResourceable.wrap(course));
@@ -92,20 +76,14 @@ public class CourseGroupManagementMainController extends MainLayoutBasicControll
 		CourseGroupManager groupManager = course.getCourseEnvironment().getCourseGroupManager();
 		OLATResource courseResource = groupManager.getCourseResource();
 
-		// init content panel. current panel content will be set later in init process, use null for now
-		content = putInitialPanel(null);
-
-		removeAsListenerAndDispose(groupManageCtr);
 		groupManageCtr = BGControllerFactory.getInstance().createManagementController(ureq, getWindowControl(), courseResource, false);
 		listenTo(groupManageCtr);
-		content.setContent(groupManageCtr.getInitialComponent());
+		putInitialPanel(groupManageCtr.getInitialComponent());
 		
 		// logging
 		ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUPMANAGEMENT_START, getClass());
 	}
 
-
-
 	/**
 	 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 	 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
@@ -123,39 +101,8 @@ public class CourseGroupManagementMainController extends MainLayoutBasicControll
 			if (event == Event.DONE_EVENT) {
 				// Send done event to parent controller
 				fireEvent(ureq, Event.DONE_EVENT);
-			} else if (event == Event.BACK_EVENT) {
-				// show context list again
-				// reinitialize context list since it could be dirty
-				List groupContexts;
-				ICourse course = CourseFactory.loadCourse(ores);
-				CourseGroupManager groupManager = course.getCourseEnvironment().getCourseGroupManager();
-				//TODO gm
-				/*
-				if (BusinessGroup.TYPE_LEARNINGROUP.equals(groupType)) {
-					groupContexts = groupManager.getLearningGroupContexts();
-				} else {
-					groupContexts = groupManager.getRightGroupContexts();
-				}
-				*/
-				//doInitContextList(ureq, groupContexts);
-				content.setContent(columnLayoutCtr.getInitialComponent());
-			}
-		} else if (source == contextListCtr) {
-			if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
-				TableEvent te = (TableEvent) event;
-				String actionid = te.getActionId();
-				int rowid = te.getRowId();
-				/*BGContext context = contextTableModel.getGroupContextAt(rowid);
-				if (actionid.equals(CMD_CONTEXT_RUN)) {
-					doInitGroupmanagement(ureq, context, true);
-				}*/
-			}
-		} else if (source == toolC) {
-			if (event.getCommand().equals(CMD_CLOSE)) {
-				fireEvent(ureq, Event.DONE_EVENT);
 			}
 		}
-
 	}
 
 	/**
@@ -164,5 +111,4 @@ public class CourseGroupManagementMainController extends MainLayoutBasicControll
 	protected void doDispose() {
 		ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUPMANAGEMENT_CLOSE, getClass());
 	}
-
 }
\ No newline at end of file
diff --git a/src/main/java/org/olat/course/nodes/COCourseNode.java b/src/main/java/org/olat/course/nodes/COCourseNode.java
index 3879a3cf8fd..bb8dfe9cb4e 100644
--- a/src/main/java/org/olat/course/nodes/COCourseNode.java
+++ b/src/main/java/org/olat/course/nodes/COCourseNode.java
@@ -28,6 +28,7 @@ package org.olat.course.nodes;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.olat.core.CoreSpringFactory;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.control.Controller;
 import org.olat.core.gui.control.WindowControl;
@@ -47,6 +48,10 @@ import org.olat.course.nodes.co.CORunController;
 import org.olat.course.run.navigation.NodeRunConstructionResult;
 import org.olat.course.run.userview.NodeEvaluation;
 import org.olat.course.run.userview.UserCourseEnvironment;
+import org.olat.group.BusinessGroupService;
+import org.olat.group.BusinessGroupShort;
+import org.olat.group.area.BGArea;
+import org.olat.group.area.BGAreaManager;
 import org.olat.modules.ModuleConfiguration;
 import org.olat.repository.RepositoryEntry;
 
@@ -118,7 +123,8 @@ public class COCourseNode extends AbstractAccessableCourseNode {
 		 * expensive operation to fetch the e-mail adresses for tutors,
 		 * participants, group and area members. simple config here!
 		 */
-		List emailList = (List) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
+		@SuppressWarnings("unchecked")
+		List<String> emailList = (List<String>) getModuleConfiguration().get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
 		boolean isValid = (emailList != null && emailList.size() > 0);
 		Boolean email2coaches = getModuleConfiguration().getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOCOACHES);
 		Boolean email2partips = getModuleConfiguration().getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS);
@@ -151,36 +157,80 @@ public class COCourseNode extends AbstractAccessableCourseNode {
 		// only here we know which translator to take for translating condition
 		// error messages
 		String translatorStr = Util.getPackageName(ConditionEditController.class);
-		List condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
-		List missingNames = new ArrayList();
+		List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
+		List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
 		/*
 		 * check group and area names for existence
 		 */
-		ModuleConfiguration mc = getModuleConfiguration();
-		String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
 		String nodeId = getIdent();
-		if (areaStr != null) {
-			String[] areas = areaStr.split(",");
-			for (int i = 0; i < areas.length; i++) {
-				String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
-				if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
-					StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
-							new String[] { "NONE", trimmed }, translatorStr);
-					sd.setDescriptionForUnit(nodeId);
-					missingNames.add(sd);
+		ModuleConfiguration mc = getModuleConfiguration();
+
+		@SuppressWarnings("unchecked")
+		List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOAREA_IDS);
+		if(areaKeys != null) {
+			BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
+			List<BGArea> areas = areaManager.loadAreas(areaKeys);
+
+			a_a:
+			for(Long areaKey:areaKeys) {
+				for(BGArea area:areas) {
+					if(area.getKey().equals(areaKey)) {
+						continue a_a;
+					}
+				}
+				
+				StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
+						new String[] { "NONE", areaKey.toString() }, translatorStr);
+				sd.setDescriptionForUnit(nodeId);
+				missingNames.add(sd);
+			}
+		} else {
+			String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
+			if (areaStr != null) {
+				String[] areas = areaStr.split(",");
+				for (int i = 0; i < areas.length; i++) {
+					String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
+					if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
+						StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
+								new String[] { "NONE", trimmed }, translatorStr);
+						sd.setDescriptionForUnit(nodeId);
+						missingNames.add(sd);
+					}
 				}
 			}
 		}
-		String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
-		if (groupStr != null) {
-			String[] groups = groupStr.split(",");
-			for (int i = 0; i < groups.length; i++) {
-				String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
-				if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
-					StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
-							new String[] { "NONE", trimmed }, translatorStr);
-					sd.setDescriptionForUnit(nodeId);
-					missingNames.add(sd);
+
+		@SuppressWarnings("unchecked")
+		List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOGROUP_IDS);
+		if(groupKeys != null) {
+			BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
+			List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
+			
+			a_a:
+			for(Long activeGroupKey:groupKeys) {
+				for(BusinessGroupShort group:groups) {
+					if(group.getKey().equals(activeGroupKey)) {
+						continue a_a;
+					}
+				}
+				
+				StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
+						new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
+				sd.setDescriptionForUnit(nodeId);
+				missingNames.add(sd);
+			}
+		} else {
+			String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
+			if (groupStr != null) {
+				String[] groups = groupStr.split(",");
+				for (int i = 0; i < groups.length; i++) {
+					String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
+					if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
+						StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement",
+								new String[] { "NONE", trimmed }, translatorStr);
+						sd.setDescriptionForUnit(nodeId);
+						missingNames.add(sd);
+					}
 				}
 			}
 		}
diff --git a/src/main/java/org/olat/course/nodes/co/COConfigForm.java b/src/main/java/org/olat/course/nodes/co/COConfigForm.java
index 16d3fe9cad1..db5d28557ba 100644
--- a/src/main/java/org/olat/course/nodes/co/COConfigForm.java
+++ b/src/main/java/org/olat/course/nodes/co/COConfigForm.java
@@ -27,16 +27,19 @@ package org.olat.course.nodes.co;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.olat.core.CoreSpringFactory;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.form.flexible.FormItem;
 import org.olat.core.gui.components.form.flexible.FormItemContainer;
 import org.olat.core.gui.components.form.flexible.elements.FormLink;
 import org.olat.core.gui.components.form.flexible.elements.SelectionElement;
 import org.olat.core.gui.components.form.flexible.elements.SpacerElement;
+import org.olat.core.gui.components.form.flexible.elements.StaticTextElement;
 import org.olat.core.gui.components.form.flexible.elements.TextElement;
 import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
 import org.olat.core.gui.components.form.flexible.impl.FormEvent;
@@ -53,6 +56,11 @@ import org.olat.course.condition.AreaSelectionController;
 import org.olat.course.condition.GroupSelectionController;
 import org.olat.course.editor.CourseEditorEnv;
 import org.olat.course.run.userview.UserCourseEnvironment;
+import org.olat.group.BusinessGroup;
+import org.olat.group.BusinessGroupService;
+import org.olat.group.BusinessGroupShort;
+import org.olat.group.area.BGArea;
+import org.olat.group.area.BGAreaManager;
 import org.olat.group.ui.BGControllerFactory;
 import org.olat.group.ui.NewAreaController;
 import org.olat.group.ui.NewBGController;
@@ -78,14 +86,14 @@ public class COConfigForm extends FormBasicController {
 	private SelectionElement partips;
 	private FormLayoutContainer coachesAndPartips;
 	
-	private SpacerElement s1, s2, s3, s4;
+	private SpacerElement s1, s2, s3;
 	
 	
-	private TextElement easyGroupTE;
+	private StaticTextElement easyGroupList;
 	private FormLink chooseGroupsLink;
 	private FormLink createGroupsLink;
 	
-	private TextElement easyAreaTE;
+	private StaticTextElement easyAreaList;
 	private FormLink chooseAreasLink;
 	private FormLink createAreasLink;
 	
@@ -109,11 +117,13 @@ public class COConfigForm extends FormBasicController {
 	
 	private CloseableModalController cmc;
 	
-	private List eList;
+	private List<String> eList;
 	private ModuleConfiguration config;
 	private CourseEditorEnv cev;
 	
-	
+	private final BGAreaManager areaManager;
+	private final BusinessGroupService businessGroupService;
+
 	/**
 	 * Form constructor
 	 * 
@@ -125,6 +135,8 @@ public class COConfigForm extends FormBasicController {
 		super(ureq, wControl);
 		this.config = config;
 		this.cev = uce.getCourseEditorEnv();
+		areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
+		businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
 		initForm(ureq);
 	}
 
@@ -156,9 +168,6 @@ public class COConfigForm extends FormBasicController {
 		 * The case that the specified groups can contain zero members must be
 		 * handled by the e-mail controller!
 		 */
-		
-		
-		
 		String emailToAdresses = teArElEmailToAdresses.getValue();
 		String[] emailAdress = emailToAdresses.split("\\s*\\r?\\n\\s*");
 		
@@ -170,12 +179,9 @@ public class COConfigForm extends FormBasicController {
 			return false;
 		}
 		
-		/*
-		 * check validity of manually provided e-mails
-		 */
-		
+		//check validity of manually provided e-mails
 		if ((emailAdress != null) && (emailAdress.length > 0) && (!"".equals(emailAdress[0]))) {
-			this.eList = new ArrayList();
+			this.eList = new ArrayList<String>();
 			for (int i = 0; i < emailAdress.length; i++) {
 				String eAd = emailAdress[i].trim();
 				boolean emailok = MailHelper.isValidEmailAddress(eAd);
@@ -191,57 +197,56 @@ public class COConfigForm extends FormBasicController {
 	
 	private boolean validateGroupFields () {
 		boolean retVal = true;
-		String[] activeGroupSelection = new String[0];
-		String[] activeAreaSelection = new String[0];
+		List<Long> activeGroupSelection = null;
+		List<Long> activeAreaSelection = null;
 
-		if (!easyGroupTE.isEmpty()) {
+		if (!isEmpty(easyGroupList)) {
 			// check whether groups exist
-			activeGroupSelection = easyGroupTE.getValue().split(",");
-			boolean exists = false;
-			Set<String> missingGroups = new HashSet<String>();
+			activeGroupSelection = getKeys(easyGroupList);
 			
-			for (int i = 0; i < activeGroupSelection.length; i++) {
-				String trimmed = activeGroupSelection[i].trim();
-				exists = cev.existsGroup(trimmed);
-				if (!exists && trimmed.length() > 0 && !missingGroups.contains(trimmed)) {
-					missingGroups.add(trimmed);
+			Set<Long> missingGroups = new HashSet<Long>();
+			List<BusinessGroupShort> existingGroups =  businessGroupService.loadShortBusinessGroups(activeGroupSelection);
+			a_a:
+			for(Long activeGroupKey:activeGroupSelection) {
+				for(BusinessGroupShort group:existingGroups) {
+					if(group.getKey().equals(activeGroupKey)) {
+						continue a_a;
+					}
 				}
+				missingGroups.add(activeGroupKey);
 			}
 			
-			if (missingGroups.size() > 0) {
+			if (!missingGroups.isEmpty()) {
 				retVal = false;
 				String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
-				String csvMissGrps = StringHelper.formatAsCSVString(missingGroups);
+				String csvMissGrps = toString(missingGroups);
 				String[] params = new String[] { "-", csvMissGrps };
 
-				/*
-				 * create error with link to fix it
-				 */
+				// create error with link to fix it
 				String vc_errorPage = velocity_root + "/erroritem.html";
 				FormLayoutContainer errorGroupItemLayout = FormLayoutContainer.createCustomFormLayout(
-						"errorgroupitem", getTranslator(), vc_errorPage
-				);
-
-					groupChooseSubContainer.setErrorComponent(errorGroupItemLayout, this.flc);
-					// FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
-					fixGroupError = new FormLinkImpl("error.fix", "create");
-					// link
-					fixGroupError.setCustomEnabledLinkCSS("b_button");
-					errorGroupItemLayout.add(fixGroupError);
-
-					fixGroupError.setErrorKey(labelKey, params);
-					fixGroupError.showError(true);
-					fixGroupError.showLabel(false);
-					// hinty to pass the information if one group is
-					// missing or if 2 or more groups are missing
-					// (see fixGroupErrer.getUserObject to understand)
-					// e.g. if userobject String[].lenght == 1 -> one group only
-					// String[].lenght > 1 -> show bulkmode creation group
-					if (missingGroups.size() > 1) {
-						fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
-					} else {
-						fixGroupError.setUserObject(new String[] { csvMissGrps });
-					}
+						"errorgroupitem", getTranslator(), vc_errorPage);
+
+				groupChooseSubContainer.setErrorComponent(errorGroupItemLayout, this.flc);
+				// FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
+				fixGroupError = new FormLinkImpl("error.fix", "create");
+				// link
+				fixGroupError.setCustomEnabledLinkCSS("b_button");
+				errorGroupItemLayout.add(fixGroupError);
+
+				fixGroupError.setErrorKey(labelKey, params);
+				fixGroupError.showError(true);
+				fixGroupError.showLabel(false);
+				// hinty to pass the information if one group is
+				// missing or if 2 or more groups are missing
+				// (see fixGroupErrer.getUserObject to understand)
+				// e.g. if userobject String[].lenght == 1 -> one group only
+				// String[].lenght > 1 -> show bulkmode creation group
+				if (missingGroups.size() > 1) {
+					fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
+				} else {
+					fixGroupError.setUserObject(new String[] { csvMissGrps });
+				}
 
 				groupChooseSubContainer.showError(true);
 			} else {
@@ -249,50 +254,55 @@ public class COConfigForm extends FormBasicController {
 				groupChooseSubContainer.clearError();
 			}
 		}
-		if (!easyAreaTE.isEmpty()) {
+		if (!isEmpty(easyAreaList)) {
 			// check whether areas exist
-			activeAreaSelection = easyAreaTE.getValue().split(",");
-
-			List<String> activeAreaList = new ArrayList<String>();
-			for (int i=activeAreaSelection.length; i-->0; ) {
-				activeAreaList.add(activeAreaSelection[i].trim());
+			activeAreaSelection = getKeys(easyAreaList);
+
+			List<Long> missingAreas = new ArrayList<Long>();
+			List<BGArea> cnt = areaManager.loadAreas(activeAreaSelection);
+			a_a:
+			for(Long activeAreaKey:activeAreaSelection) {
+				for (BGArea element : cnt) {
+					if (element.getKey().equals(activeAreaKey)) { 
+						continue a_a;
+					}
+				}
+				missingAreas.add(activeAreaKey);
 			}
-			List<String> missingAreas = cev.validateAreas(activeAreaList);
-			if (missingAreas.size() > 0) {
+
+			if (!missingAreas.isEmpty()) {
 				retVal = false;
 				String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
-				String csvMissAreas = StringHelper.formatAsCSVString(missingAreas);
+				String csvMissAreas = toString(missingAreas);
 				String[] params = new String[] { "-", csvMissAreas };
 
-				/*
-				 * create error with link to fix it
-				 */
+				// create error with link to fix it
 				String vc_errorPage = velocity_root + "/erroritem.html";
 				FormLayoutContainer errorAreaItemLayout = FormLayoutContainer.createCustomFormLayout(
 						"errorareaitem", getTranslator(), vc_errorPage
 				);
 				
-					areaChooseSubContainer.setErrorComponent(errorAreaItemLayout, this.flc);
-					// FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
-					fixAreaError = new FormLinkImpl("error.fix", "create");// erstellen
-					// link
-					fixAreaError.setCustomEnabledLinkCSS("b_button");
-					errorAreaItemLayout.add(fixAreaError);
-
-					fixAreaError.setErrorKey(labelKey, params);
-					fixAreaError.showError(true);
-					fixAreaError.showLabel(false);
-					
-					// hint to pass the information if one area is
-					// missing or if 2 or more areas are missing
-					// (see fixGroupErrer.getUserObject to understand)
-					// e.g. if userobject String[].lenght == 1 -> one group only
-					// String[].lenght > 1 -> show bulkmode creation group
-					if (missingAreas.size() > 1) {
-						fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
-					} else {
-						fixAreaError.setUserObject(new String[] { csvMissAreas });
-					}
+				areaChooseSubContainer.setErrorComponent(errorAreaItemLayout, this.flc);
+				// FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
+				fixAreaError = new FormLinkImpl("error.fix", "create");// erstellen
+				// link
+				fixAreaError.setCustomEnabledLinkCSS("b_button");
+				errorAreaItemLayout.add(fixAreaError);
+
+				fixAreaError.setErrorKey(labelKey, params);
+				fixAreaError.showError(true);
+				fixAreaError.showLabel(false);
+				
+				// hint to pass the information if one area is
+				// missing or if 2 or more areas are missing
+				// (see fixGroupErrer.getUserObject to understand)
+				// e.g. if userobject String[].lenght == 1 -> one group only
+				// String[].lenght > 1 -> show bulkmode creation group
+				if (missingAreas.size() > 1) {
+					fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
+				} else {
+					fixAreaError.setUserObject(new String[] { csvMissAreas });
+				}
 			
 				areaChooseSubContainer.showError(true);
 			} else {
@@ -300,14 +310,14 @@ public class COConfigForm extends FormBasicController {
 			}	
 		}
 
-		boolean easyGroupOK = (!easyGroupTE.isEmpty() && activeGroupSelection.length != 0);
-		boolean easyAreaOK = (!easyAreaTE.isEmpty() && activeAreaSelection.length != 0);
+		boolean easyGroupOK = !activeGroupSelection.isEmpty();
+		boolean easyAreaOK = !activeAreaSelection.isEmpty();
 		if (easyGroupOK || easyAreaOK) {
 			// clear general error
-			this.flc.clearError();
+			flc.clearError();
 		} else {
 			// error concerns both fields -> set it as switch error
-			this.groupsAndAreasSubContainer.setErrorKey("form.noGroupsOrAreas", null);
+			groupsAndAreasSubContainer.setErrorKey("form.noGroupsOrAreas", null);
 			retVal = false;
 		}
 		
@@ -346,7 +356,7 @@ public class COConfigForm extends FormBasicController {
 	/**
 	 * @return the email list
 	 */
-	protected List getEmailList() {
+	protected List<String> getEmailList() {
 		return eList;
 	}
 
@@ -356,7 +366,16 @@ public class COConfigForm extends FormBasicController {
 	 * @return
 	 */
 	protected String getEmailGroups() {
-		if (StringHelper.containsNonWhitespace(easyGroupTE.getValue())) return easyGroupTE.getValue();
+		if (!isEmpty(easyGroupList)) {
+			return easyGroupList.getValue();
+		}
+		return null;
+	}
+	
+	protected List<Long> getEmailGroupIds() {
+		if (!isEmpty(easyGroupList)) {
+			return getKeys(easyGroupList);
+		}
 		return null;
 	}
 
@@ -364,7 +383,16 @@ public class COConfigForm extends FormBasicController {
 	 * returns the choosen learning areas, or null if no ares were choosen.
 	 */
 	protected String getEmailAreas() {
-		if (StringHelper.containsNonWhitespace(easyAreaTE.getValue())) return easyAreaTE.getValue();
+		if(!isEmpty(easyAreaList)) {
+			return easyAreaList.getValue();
+		}
+		return null;
+	}
+	
+	protected List<Long> getEmailAreaIds() {
+		if(!isEmpty(easyAreaList)) {
+			return getKeys(easyAreaList);
+		}
 		return null;
 	}
 
@@ -408,16 +436,24 @@ public class COConfigForm extends FormBasicController {
 		);
 		groupChooseSubContainer.setLabel("form.message.group", null);
 		
-		formLayout.add(groupChooseSubContainer);		
-		String groupInitVal = (String) config.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
-		easyGroupTE = uifactory.addTextElement("group", null, 1024, groupInitVal, groupChooseSubContainer);
-		easyGroupTE.setDisplaySize(24);
-		easyGroupTE.setExampleKey("form.message.example.group", null);
+		formLayout.add(groupChooseSubContainer);
+		
+		String groupInitVal;
+		@SuppressWarnings("unchecked")
+		List<Long> groupKeys = (List<Long>)config.get(COEditController.CONFIG_KEY_EMAILTOGROUP_IDS);
+		if(groupKeys == null) {
+			groupInitVal = (String)config.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
+			groupKeys = getGroupKeys(groupInitVal);
+		} else {
+			groupInitVal = getGroupNames(groupKeys);
+		}
+		easyGroupList = uifactory.addStaticTextElement("group", null, groupInitVal, groupChooseSubContainer);
+		easyGroupList.setUserObject(groupKeys);
 		
 		chooseGroupsLink = uifactory.addFormLink("choose", groupChooseSubContainer,"b_form_groupchooser");
 		createGroupsLink = uifactory.addFormLink("create", groupChooseSubContainer,"b_form_groupchooser");	
 
-		hasGroups = cev.getCourseGroupManager().getAllLearningGroupsFromAllContexts().size() > 0;
+		hasGroups = businessGroupService.countBusinessGroups(null, cev.getCourseGroupManager().getCourseResource()) > 0;
 		
 		// areas
 		areaChooseSubContainer = FormLayoutContainer.createHorizontalFormLayout(
@@ -429,15 +465,22 @@ public class COConfigForm extends FormBasicController {
 		groupsAndAreasSubContainer = FormLayoutContainer.createHorizontalFormLayout("groupSubContainer", getTranslator());
 		formLayout.add(groupsAndAreasSubContainer);
 		
-		String areaInitVal = (String) config.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
-		easyAreaTE = uifactory.addTextElement("area", null, 1024, areaInitVal, areaChooseSubContainer);
-		easyAreaTE.setDisplaySize(24);
-		easyAreaTE.setExampleKey("form.message.example.area", null);
+		String areaInitVal;
+		@SuppressWarnings("unchecked")
+		List<Long> areaKeys = (List<Long>)config.get(COEditController.CONFIG_KEY_EMAILTOAREA_IDS);
+		if(areaKeys == null) {
+			areaInitVal = (String) config.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
+			areaKeys = getAreaKeys(areaInitVal);
+		} else {
+			areaInitVal = getAreaNames(areaKeys);
+		}
+		easyAreaList = uifactory.addStaticTextElement("area", null, areaInitVal, areaChooseSubContainer);
+		easyAreaList.setUserObject(areaKeys);
 		
 		chooseAreasLink = uifactory.addFormLink("choose", areaChooseSubContainer,"b_form_groupchooser");
 		createAreasLink = uifactory.addFormLink("create", areaChooseSubContainer,"b_form_groupchooser");
 		
-		hasAreas = cev.getCourseGroupManager().getAllAreasFromAllContexts().size() > 0;
+		hasAreas = areaManager.countBGAreasInContext(cev.getCourseGroupManager().getCourseResource()) > 0;
 		
 		s2 = uifactory.addSpacerElement("s2", formLayout, false);
 		
@@ -445,7 +488,7 @@ public class COConfigForm extends FormBasicController {
 		wantEmail.addActionListener(this, FormEvent.ONCLICK);
 		
 		//recipients
-		this.eList = (List) config.get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
+		eList = (List<String>) config.get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
 		String emailToAdresses = "";
 		if (eList != null) {
 			emailToAdresses = StringHelper.formatIdentitesAsEmailToString(eList, "\n");
@@ -462,7 +505,7 @@ public class COConfigForm extends FormBasicController {
 		);
 		formLayout.add(recipentsContainer);
 		
-		s4 = uifactory.addSpacerElement("s4", formLayout, false);
+		uifactory.addSpacerElement("s4", formLayout, false);
 				
 		//subject
 		String mS = (String) config.get(COEditController.CONFIG_KEY_MSUBJECT_DEFAULT);
@@ -495,15 +538,17 @@ public class COConfigForm extends FormBasicController {
 		if (!wg) {
 			coaches.select("xx", false);
 			partips.select("xx", false);
-			easyAreaTE.setValue("");
-			easyGroupTE.setValue("");
+			easyAreaList.setValue("");
+			easyAreaList.setUserObject(null);
+			easyGroupList.setValue("");
+			easyGroupList.setUserObject(null);
 		}
 		
-		hasGroups = cev.getCourseGroupManager().getAllLearningGroupsFromAllContexts().size() > 0;	
+		hasGroups = businessGroupService.countBusinessGroups(null, cev.getCourseGroupManager().getCourseResource()) > 0;
 		chooseGroupsLink.setVisible(wg &&  hasGroups);
 		createGroupsLink.setVisible(wg && !hasGroups);
 		
-		hasAreas = cev.getCourseGroupManager().getAllAreasFromAllContexts().size() > 0;
+		hasAreas = areaManager.countBGAreasInContext(cev.getCourseGroupManager().getCourseResource()) > 0;
 		chooseAreasLink.setVisible(wg &&  hasAreas);
 		createAreasLink.setVisible(wg && !hasAreas);	
 		
@@ -519,94 +564,60 @@ public class COConfigForm extends FormBasicController {
 	
 	@Override
 	protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
-
 		if (source == chooseGroupsLink) {
-			
+			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose(groupChooseC);
+			
 			groupChooseC = new GroupSelectionController(ureq, getWindowControl(), "group",
-					cev.getCourseGroupManager(), null /* easyGroupTE.getValue() */); //TODO gm
+					cev.getCourseGroupManager(), getKeys(easyGroupList));
 			listenTo(groupChooseC);
 
-			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-					getWindowControl(), "close",
-					groupChooseC.getInitialComponent()
-			);
+			cmc = new CloseableModalController(getWindowControl(), "close", groupChooseC.getInitialComponent());
 			listenTo(cmc);
-			
 			cmc.activate();
 			subm.setEnabled(false);
-
 		} else if (source == createGroupsLink) {
+			removeAsListenerAndDispose(cmc);
+			removeAsListenerAndDispose(groupCreateCntrllr);
+			
 			// no groups in group management -> directly show group create dialog
-			String[] csvGroupName = easyGroupTE.isEmpty() ? new String[0] : easyGroupTE.getValue().split(",");
 			OLATResource courseResource = cev.getCourseGroupManager().getCourseResource();
-			removeAsListenerAndDispose(groupCreateCntrllr);
-			groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(
-					ureq, getWindowControl(), 
-					true, courseResource,
-					true, easyGroupTE.getValue()
-			);
+			groupCreateCntrllr = new NewBGController(ureq, getWindowControl(), true, courseResource, true, null);
 			listenTo(groupCreateCntrllr);
-
-			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-					getWindowControl(), "close",
-					groupCreateCntrllr.getInitialComponent()
-			);
+			cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCntrllr.getInitialComponent());
 			listenTo(cmc);
-			
 			cmc.activate();
 			subm.setEnabled(false);
-			
 		} else if (source == chooseAreasLink) {
-
 			// already areas -> choose areas
+			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose(areaChooseC);
+			
 			areaChooseC = new AreaSelectionController (ureq, getWindowControl(), "area",
-					cev.getCourseGroupManager(), null /* easyAreaTE.getValue() */);//TODO gm
+					cev.getCourseGroupManager(), getKeys(easyAreaList));
 			listenTo(areaChooseC);
-			
-			
-			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-					getWindowControl(), "close",
-					areaChooseC.getInitialComponent()
-			);
+
+			cmc = new CloseableModalController(getWindowControl(), "close", areaChooseC.getInitialComponent());
 			listenTo(cmc);
-			
 			cmc.activate();
 			subm.setEnabled(false);
-			
 		} else if (source == createAreasLink) {
+			removeAsListenerAndDispose(cmc);
+			removeAsListenerAndDispose(areaCreateCntrllr);
+			
 			// no areas -> directly show creation dialog
-
 			OLATResource courseResource = cev.getCourseGroupManager().getCourseResource();
-			removeAsListenerAndDispose(areaCreateCntrllr);
-			areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(
-					ureq, getWindowControl(), courseResource, true, easyAreaTE.getValue()
-			);
+			areaCreateCntrllr = new NewAreaController(ureq, getWindowControl(), courseResource, true, null);
 			listenTo(areaCreateCntrllr);
-			
-			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-					getWindowControl(), "close",
-					areaCreateCntrllr.getInitialComponent()
-			);
+			cmc = new CloseableModalController(getWindowControl(), "close", areaCreateCntrllr.getInitialComponent());
 			listenTo(cmc);
-			
 			cmc.activate();
 			subm.setEnabled(false);
-			
 		} else if (source == fixGroupError) {
-			/*
-			 * user wants to fix problem with fixing group error link e.g. create one
-			 * or more group at once.
-			 */
-			
+			// user wants to fix problem with fixing group error link e.g. create one or more group at once.
 			String[] csvGroupName = (String[]) fixGroupError.getUserObject();
 			OLATResource courseResource = cev.getCourseGroupManager().getCourseResource();
-			easyGroupTE.setEnabled(false);
+			easyGroupList.setEnabled(false);
 			removeAsListenerAndDispose(groupCreateCntrllr);
 			groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(
 					ureq, getWindowControl(), true, courseResource, true, csvGroupName[0]
@@ -624,124 +635,180 @@ public class COConfigForm extends FormBasicController {
 			subm.setEnabled(false);
 			
 		} else if (source == fixAreaError) {
-			/*
-			 * user wants to fix problem with fixing area error link e.g. create one
-			 * or more areas at once.
-			 */
+			// user wants to fix problem with fixing area error link e.g. create one or more areas at once.
 			String[] csvAreaName = (String[]) fixAreaError.getUserObject();
 			OLATResource courseResource = cev.getCourseGroupManager().getCourseResource();
-			easyAreaTE.setEnabled(false);
+			easyAreaList.setEnabled(false);
 			removeAsListenerAndDispose(areaCreateCntrllr);
 			areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(
-					ureq, getWindowControl(), courseResource, true, csvAreaName[0]
-			);
+					ureq, getWindowControl(), courseResource, true, csvAreaName[0]);
 			listenTo(areaCreateCntrllr);
 			
 			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-					getWindowControl(), "close",
-					areaCreateCntrllr.getInitialComponent()
-			);
+			cmc = new CloseableModalController(getWindowControl(), "close", areaCreateCntrllr.getInitialComponent());
 			listenTo(cmc);
 			
 			cmc.activate();
 			subm.setEnabled(false);
-			
 		}
-		
 		update();
 	}
 	
 	@Override
-	@SuppressWarnings("unused")
 	protected void event(UserRequest ureq, Controller source, Event event) {
-		
 		subm.setEnabled(true);
-		
 		if (source == groupChooseC) {
 			if (event == Event.DONE_EVENT) {
 				cmc.deactivate();
-				easyGroupTE.setValue(StringHelper.formatAsSortUniqCSVString(groupChooseC.getSelectedEntries()));
-				easyGroupTE.getRootForm().submit(ureq);
-	
+				easyGroupList.setValue(StringHelper.formatAsSortUniqCSVString(groupChooseC.getSelectedNames()));
+				easyGroupList.setUserObject(groupChooseC.getSelectedKeys());
+				easyGroupList.getRootForm().submit(ureq);
 			} else if (Event.CANCELLED_EVENT == event) {
 				cmc.deactivate();
-				return;
-				
-			} else if (event == Event.CHANGED_EVENT && !hasGroups){
-				//singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
-				//why? fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
 			}
-			
 		} else if (source == areaChooseC) {
 			if (event == Event.DONE_EVENT) {
 				cmc.deactivate();
-				easyAreaTE.setValue(StringHelper.formatAsSortUniqCSVString(areaChooseC.getSelectedEntries()));
-				easyAreaTE.getRootForm().submit(ureq);
-				
+				easyAreaList.setValue(StringHelper.formatAsSortUniqCSVString(areaChooseC.getSelectedNames()));
+				easyAreaList.setUserObject(areaChooseC.getSelectedKeys());
+				easyAreaList.getRootForm().submit(ureq);
 			} else if (event == Event.CANCELLED_EVENT) {
 				cmc.deactivate();
-				return;
-				
-			} else if (event == Event.CHANGED_EVENT && !hasAreas) {
-				//singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
-				//why? fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
 			}
-			
 		} else if (source == groupCreateCntrllr) {
-			
-			easyGroupTE.setEnabled(true);
+			easyGroupList.setEnabled(true);
 			cmc.deactivate();
-
 			if (event == Event.DONE_EVENT) {
-				
-				List <String>c = new ArrayList<String>();
-				c.addAll(Arrays.asList(easyGroupTE.getValue().split(",")));
+				List<Long> c = new ArrayList<Long>();
+				c.addAll(getKeys(easyGroupList));
 				if (fixGroupError != null && fixGroupError.getUserObject() != null) {
 					c.removeAll(Arrays.asList((String[])fixGroupError.getUserObject()));
 				}
-				c.addAll (groupCreateCntrllr.getCreatedGroupNames());
-				
-				easyGroupTE.setValue(StringHelper.formatAsSortUniqCSVString(c));
+				c.addAll(groupCreateCntrllr.getCreatedGroupKeys());
+				easyGroupList.setValue(getGroupNames(c));
+				easyGroupList.setUserObject(c);
 				
 				if (groupCreateCntrllr.getCreatedGroupNames().size() > 0 && !hasGroups) {
 					chooseGroupsLink.setVisible(true);
 					createGroupsLink.setVisible(false);
-					//singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
 				}
-				
-				easyGroupTE.getRootForm().submit(ureq);
+				easyGroupList.getRootForm().submit(ureq);
 			}
-			
 		} else if (source == areaCreateCntrllr) {
-			
-			easyAreaTE.setEnabled(true);
+			easyAreaList.setEnabled(true);
 			cmc.deactivate();
 			
 			if (event == Event.DONE_EVENT) {
-				List <String>c = new ArrayList<String>();
-				c.addAll(Arrays.asList(easyAreaTE.getValue().split(",")));
+				List<Long> c = new ArrayList<Long>();
+				c.addAll(getKeys(easyAreaList));
 				if (fixAreaError != null && fixAreaError.getUserObject() != null) {
 					c.removeAll(Arrays.asList((String[])fixAreaError.getUserObject()));
 				}
-				c.addAll (areaCreateCntrllr.getCreatedAreaNames());
+				c.addAll(areaCreateCntrllr.getCreatedAreaKeys());
 				
-				easyAreaTE.setValue(StringHelper.formatAsSortUniqCSVString(c));
+				easyAreaList.setValue(getAreaNames(c));
+				easyAreaList.setUserObject(c);
 				
 				if (areaCreateCntrllr.getCreatedAreaNames().size() > 0 && !hasAreas) {
 					chooseAreasLink.setVisible(true);
 					createAreasLink.setVisible(false);
-					//singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
 				}
-				easyAreaTE.getRootForm().submit(ureq);
+				easyAreaList.getRootForm().submit(ureq);
 			} 
 		}
 	}
 
-	
-	
 	@Override
 	protected void doDispose() {
 		//
 	}
+	
+	private boolean isEmpty(StaticTextElement element) {
+		List<Long> keys = getKeys(element);
+		if(keys == null || keys.isEmpty()) {
+			return true;
+		}
+		return false;
+	}
+	
+	private List<Long> getKeys(StaticTextElement element) {
+		@SuppressWarnings("unchecked")
+		List<Long> keys = (List<Long>)element.getUserObject();
+		if(keys == null) {
+			keys = new ArrayList<Long>();
+			element.setUserObject(keys);
+		}
+		return keys;
+	}
+	
+	private String toString(Collection<Long> keys) {
+		StringBuilder sb = new StringBuilder();
+		for(Long key:keys) {
+			if(sb.length() > 0) sb.append(',');
+			sb.append(key);
+		}
+		return sb.toString();
+	}
+	
+	private String getGroupNames(List<Long> keys) {
+		StringBuilder sb = new StringBuilder();
+		List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(keys);
+		for(BusinessGroupShort group:groups) {
+			if(sb.length() > 0) sb.append(", ");
+			sb.append(group.getName());
+		}
+		return sb.toString();
+	}
+	
+	private String getAreaNames(List<Long> keys) {
+		StringBuilder sb = new StringBuilder();
+		for(Long key:keys) {
+			BGArea area = areaManager.loadArea(key);
+			if(area != null) {
+				if(sb.length() > 0) sb.append(", ");
+				sb.append(area.getName());
+			}
+		}
+		return sb.toString();
+	}
+	
+	private List<Long> getGroupKeys(String groupNames) {
+		List<Long> groupKeys = new ArrayList<Long>();
+		if(StringHelper.containsNonWhitespace(groupNames)) {
+			String[] groupNameArr = groupNames.split(",");
+			List<BusinessGroup> groups = cev.getCourseGroupManager().getAllLearningGroupsFromAllContexts();
+			for(String groupName:groupNameArr) {
+				groupName = groupName.trim();
+				for(BusinessGroup group:groups) {
+					if(groupName.equalsIgnoreCase(group.getName())) {
+						groupKeys.add(group.getKey());
+						break;
+					}
+				}
+			}
+		}
+		return groupKeys;
+	}
+	
+	private List<Long> getAreaKeys(String areaNames) {
+		List<Long> areaKeys = new ArrayList<Long>();
+		if(StringHelper.containsNonWhitespace(areaNames)) {
+			List<BGArea> areas = cev.getCourseGroupManager().getAllAreasFromAllContexts();
+			String[] areaNameArr = areaNames.split(",");
+			StringBuilder sb = new StringBuilder();
+			for(String areaName:areaNameArr) {
+				areaName = areaName.trim();
+				for(BGArea area:areas) {
+					if(areaName.equalsIgnoreCase(area.getName())) {
+						if(sb.length() > 0) {
+							sb.append(',');
+						}
+						sb.append(area.getKey());
+						break;
+					}
+				}
+			}
+		}
+		return areaKeys;
+	}
 }
diff --git a/src/main/java/org/olat/course/nodes/co/COEditController.java b/src/main/java/org/olat/course/nodes/co/COEditController.java
index 782f335d9ae..2bed2ea9897 100644
--- a/src/main/java/org/olat/course/nodes/co/COEditController.java
+++ b/src/main/java/org/olat/course/nodes/co/COEditController.java
@@ -65,6 +65,10 @@ public class COEditController extends ActivateableTabbableDefaultController impl
 	public static final String CONFIG_KEY_EMAILTOGROUPS = "emailToGroups";
 	/** config key: to email addresses to be extracted from specified learn areas */
 	public static final String CONFIG_KEY_EMAILTOAREAS = "emailToAreas";
+	/** config key: to email addresses to be extracted from specified groups */
+	public static final String CONFIG_KEY_EMAILTOGROUP_IDS = "emailToGroupIds";
+	/** config key: to email addresses to be extracted from specified learn areas */
+	public static final String CONFIG_KEY_EMAILTOAREA_IDS = "emailToAreaIds";
 	/** config key: email goes to partipiciants */
 	public static final String CONFIG_KEY_EMAILTOPARTICIPANTS = "emailtToPartips";
 	/** config key: email goes to coaches */
@@ -150,6 +154,8 @@ public class COEditController extends ActivateableTabbableDefaultController impl
 			} else if (event == Event.DONE_EVENT) {
 				moduleConfiguration.set(CONFIG_KEY_EMAILTOGROUPS, configForm.getEmailGroups());
 				moduleConfiguration.set(CONFIG_KEY_EMAILTOAREAS, configForm.getEmailAreas());
+				moduleConfiguration.set(CONFIG_KEY_EMAILTOGROUP_IDS, configForm.getEmailGroupIds());
+				moduleConfiguration.set(CONFIG_KEY_EMAILTOAREA_IDS, configForm.getEmailAreaIds());
 				moduleConfiguration.setBooleanEntry(CONFIG_KEY_EMAILTOCOACHES, configForm.sendToCoaches());
 				moduleConfiguration.setBooleanEntry(CONFIG_KEY_EMAILTOPARTICIPANTS, configForm.sendToPartips());
 				moduleConfiguration.set(CONFIG_KEY_EMAILTOADRESSES, configForm.getEmailList());
diff --git a/src/main/java/org/olat/course/nodes/co/CORunController.java b/src/main/java/org/olat/course/nodes/co/CORunController.java
index 857e293f31b..044adee0bf8 100644
--- a/src/main/java/org/olat/course/nodes/co/CORunController.java
+++ b/src/main/java/org/olat/course/nodes/co/CORunController.java
@@ -63,7 +63,7 @@ public class CORunController extends BasicController {
 
 	private VelocityContainer myContent;
 	private ContactFormController coFoCtr;
-	private UserCourseEnvironment userCourseEnv;
+	private final CourseGroupManager cgm;
 
 	/**
 	 * Constructor for the contact form run controller
@@ -76,11 +76,12 @@ public class CORunController extends BasicController {
 	public CORunController(ModuleConfiguration moduleConfiguration, UserRequest ureq, WindowControl wControl,
 			UserCourseEnvironment userCourseEnv, COCourseNode coCourseNode) {
 		super(ureq, wControl);
-		this.userCourseEnv = userCourseEnv;
+		cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
 		//set translator with fall back translator.
 		Translator fallback = Util.createPackageTranslator(ContactFormController.class, ureq.getLocale());
 		setTranslator(Util.createPackageTranslator(CORunController.class, ureq.getLocale(), fallback));
 		
+		@SuppressWarnings("unchecked")
 		List<String> emailListConfig = (List<String>) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOADRESSES);
 		String mSubject = (String) moduleConfiguration.get(COEditController.CONFIG_KEY_MSUBJECT_DEFAULT);
 		String mBody = (String) moduleConfiguration.get(COEditController.CONFIG_KEY_MBODY_DEFAULT);
@@ -105,34 +106,56 @@ public class CORunController extends BasicController {
 
 		Stack<ContactList> contactLists = new Stack<ContactList>();
 		
-		CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
-		
-		String grpNames = (String)moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
-		
-		List<String> grpList = splitNames(grpNames);
-		for (int i=0; i<grpList.size(); i++) {
+		@SuppressWarnings("unchecked")
+		List<Long> groupKeys = (List<Long>) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOGROUP_IDS);
+		if(groupKeys != null) {
 			if (coachesConfigured) {
-				ContactList cl = retrieveCoachesFromGroup (grpList.get(i));
+				ContactList cl = retrieveCoachesFromGroups(groupKeys);
 				contactLists.push(cl);
 			}
 			if (partipsConfigured) {
-				ContactList cl = retrieveParticipantsFromGroup(grpList.get(i));
+				ContactList cl = retrieveParticipantsFromGroups(groupKeys);
 				contactLists.push(cl);
 			}
+		} else {
+			String grpNames = (String)moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
+			List<String> grpList = splitNames(grpNames);
+			for (String groupName:grpList) {
+				if (coachesConfigured) {
+					ContactList cl = retrieveCoachesFromGroup(groupName);
+					contactLists.push(cl);
+				}
+				if (partipsConfigured) {
+					ContactList cl = retrieveParticipantsFromGroup(groupName);
+					contactLists.push(cl);
+				}
+			}
 		}
 		
-		String areas = (String) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
-		
-		List<String> areaList = splitNames(areas);
-		for (int i=0; i<areaList.size(); i++) {
+		@SuppressWarnings("unchecked")
+		List<Long> areaKeys = (List<Long>) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOAREA_IDS);
+		if(areaKeys != null) {
 			if (coachesConfigured) {
-				ContactList cl = retrieveCoachesFromArea (areaList.get(i));
+				ContactList cl = retrieveCoachesFromAreas(areaKeys);
 				contactLists.push(cl);
 			}
 			if (partipsConfigured) {
-				ContactList cl = retrieveParticipantsFromArea(areaList.get(i));
+				ContactList cl = retrieveParticipantsFromAreas(areaKeys);
 				contactLists.push(cl);
 			}
+		} else {
+			String areas = (String) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
+			List<String> areaList = splitNames(areas);
+			for (String areaName:areaList) {
+				if (coachesConfigured) {
+					ContactList cl = retrieveCoachesFromArea(areaName);
+					contactLists.push(cl);
+				}
+				if (partipsConfigured) {
+					ContactList cl = retrieveParticipantsFromArea(areaName);
+					contactLists.push(cl);
+				}
+			}
 		}
 
 		// Adding contact form
@@ -166,9 +189,17 @@ public class CORunController extends BasicController {
 			putInitialPanel(mCtr.getInitialComponent());
 		}
 	}
+	
+	private ContactList retrieveCoachesFromGroups(List<Long> groupKeys) {
+		List<Identity> coaches = cgm.getCoachesFromLearningGroups(groupKeys);
+		Set<Identity> coachesWithoutDuplicates = new HashSet<Identity>(coaches);
+		coaches = new ArrayList<Identity>(coachesWithoutDuplicates);
+		ContactList cl = new ContactList(translate("form.message.chckbx.coaches"));
+		cl.addAllIdentites(coaches);
+		return cl;
+	}
 
 	private ContactList retrieveCoachesFromGroup(String grpName) {
-		CourseGroupManager cgm = this.userCourseEnv.getCourseEnvironment().getCourseGroupManager();
 		List<Identity> coaches = cgm.getCoachesFromLearningGroup(grpName);
 		Set<Identity> coachesWithoutDuplicates = new HashSet<Identity>(coaches);
 		coaches = new ArrayList<Identity>(coachesWithoutDuplicates);
@@ -177,8 +208,16 @@ public class CORunController extends BasicController {
 		return cl;
 	}
 	
+	private ContactList retrieveCoachesFromAreas(List<Long> areaKeys) {
+		List<Identity> coaches = cgm.getCoachesFromAreas(areaKeys);
+		Set<Identity> coachesWithoutDuplicates = new HashSet<Identity>(coaches);
+		coaches = new ArrayList<Identity>(coachesWithoutDuplicates);
+		ContactList cl = new ContactList(translate("form.message.chckbx.coaches"));
+		cl.addAllIdentites(coaches);
+		return cl;
+	}
+	
 	private ContactList retrieveCoachesFromArea(String areaName) {
-		CourseGroupManager cgm = this.userCourseEnv.getCourseEnvironment().getCourseGroupManager();
 		List<Identity> coaches = cgm.getCoachesFromArea(areaName);
 		Set<Identity> coachesWithoutDuplicates = new HashSet<Identity>(coaches);
 		coaches = new ArrayList<Identity>(coachesWithoutDuplicates);
@@ -188,15 +227,27 @@ public class CORunController extends BasicController {
 	}
 	
 	private ContactList retrieveParticipantsFromGroup(String grpName) {
-		CourseGroupManager cgm = this.userCourseEnv.getCourseEnvironment().getCourseGroupManager();
 		List<Identity> participiants = cgm.getParticipantsFromLearningGroup(grpName);
 		ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
 		cl.addAllIdentites(participiants);
 		return cl;
 	}
 	
+	private ContactList retrieveParticipantsFromGroups(List<Long> groupKeys) {
+		List<Identity> participiants = cgm.getParticipantsFromLearningGroups(groupKeys);
+		ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
+		cl.addAllIdentites(participiants);
+		return cl;
+	}
+	
+	private ContactList retrieveParticipantsFromAreas(List<Long> areaKeys) {
+		List<Identity> participiants = cgm.getParticipantsFromAreas(areaKeys);
+		ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
+		cl.addAllIdentites(participiants);
+		return cl;
+	}
+	
 	private ContactList retrieveParticipantsFromArea(String areaName) {
-		CourseGroupManager cgm = this.userCourseEnv.getCourseEnvironment().getCourseGroupManager();
 		List<Identity> participiants = cgm.getParticipantsFromArea(areaName);
 		ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
 		cl.addAllIdentites(participiants);
@@ -207,7 +258,6 @@ public class CORunController extends BasicController {
 	 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 	 * @see org.olat.core.gui.components.Component, @see org.olat.core.gui.control.Event)
 	 */
-	@SuppressWarnings("unused")
 	public void event(UserRequest ureq, Component source, Event event) {
 	// no components to listen to
 	}
diff --git a/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java b/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java
index ab8af400800..032d3042d7c 100644
--- a/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java
+++ b/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java
@@ -90,7 +90,7 @@ public class EnrollmentManager extends BasicManager {
 			// the group was chosen, so why do we need the groupNames and areaNames here???
 
 			Codepoint.codepoint(EnrollmentManager.class, "beforeDoInSync");
-		//TODO gm sync
+		//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(group, new SyncerExecutor(){
 				public void execute() {
 					Tracing.logInfo("doEnroll start: group="+OresHelper.createStringRepresenting(group), identity.getName(), EnrollmentManager.class);
@@ -138,7 +138,7 @@ public class EnrollmentManager extends BasicManager {
 		if (Tracing.isDebugEnabled(this.getClass())) Tracing.logDebug("doCancelEnrollment", this.getClass());
 		// 1. Remove group membership, fire events, do loggin etc.
 		final BGConfigFlags flags = BGConfigFlags.createLearningGroupDefaultFlags();
-	//TODO gm sync
+	//TODO gsync
 		CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(enrolledGroup, new SyncerExecutor(){
 			public void execute() {
 				// Remove participant. This will also check if a waiting-list with auto-close-ranks is configurated
@@ -167,7 +167,7 @@ public class EnrollmentManager extends BasicManager {
 	public void doCancelEnrollmentInWaitingList(final Identity identity, final BusinessGroup enrolledWaitingListGroup, final ENCourseNode enNode,
 			final CoursePropertyManager coursePropertyManager, WindowControl wControl, Translator trans) {
 		// 1. Remove group membership, fire events, do loggin etc.
-		//TODO gm sync
+		//TODO gsync
 		CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(enrolledWaitingListGroup, new SyncerExecutor(){
 			public void execute() {
 				businessGroupService.removeFromWaitingList(identity, identity, enrolledWaitingListGroup);
diff --git a/src/main/java/org/olat/course/nodes/iq/IQRunController.java b/src/main/java/org/olat/course/nodes/iq/IQRunController.java
index 81f6d84dbef..90fb27c0603 100644
--- a/src/main/java/org/olat/course/nodes/iq/IQRunController.java
+++ b/src/main/java/org/olat/course/nodes/iq/IQRunController.java
@@ -407,7 +407,7 @@ public class IQRunController extends BasicController implements GenericEventList
 					ICourse course = CourseFactory.loadCourse(callingResId);
 					RepositoryEntry courseRepositoryEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
 					Panel empty = new Panel("empty");//empty panel set as "menu" and "tool"
-					Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, getWindowControl(), courseRepositoryEntry.getResourceableId());
+					Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, getWindowControl(), courseRepositoryEntry);
 					Controller disposedRestartController = new LayoutMain3ColsController(ureq, getWindowControl(), empty, empty, courseCloser.getInitialComponent(), "disposed course whily in iqRun" + callingResId);
 					displayContainerController.setDisposedMessageController(disposedRestartController);
 					
diff --git a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java
index 5854d0dc10b..af238855539 100644
--- a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java
+++ b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java
@@ -220,7 +220,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
 
 	public List<Identity> addCandidates(final List<Identity> addIdentities, final Project project) {
 		Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync");
-	//TODO gm sync
+	//TODO gsync
 		List<Identity> addedIdentities = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<List<Identity>>(){
 			public List<Identity> execute() {
 				List<Identity> addedIdentities = new ArrayList<Identity>();
@@ -241,7 +241,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
 
 	public void removeCandidates(final List<Identity> addIdentities, final Project project) {
 		Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync");
-	//TODO gm sync
+	//TODO gsync
 		CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>(){
 			public Boolean execute() {
 				Project reloadedProject = (Project) DBFactory.getInstance().loadObject(project, true);
@@ -261,7 +261,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
 		final Project reloadedProject = (Project) DBFactory.getInstance().loadObject(project, true);
 		final BusinessGroupAddResponse response = new BusinessGroupAddResponse();
 		final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
-	//TODO gm sync
+	//TODO gsync
 		Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>(){
 			public Boolean execute() {
 				for (final Identity identity : identities) {
diff --git a/src/main/java/org/olat/course/run/RunMainController.java b/src/main/java/org/olat/course/run/RunMainController.java
index 4ddf548379b..c60e3c2efbe 100644
--- a/src/main/java/org/olat/course/run/RunMainController.java
+++ b/src/main/java/org/olat/course/run/RunMainController.java
@@ -418,8 +418,7 @@ public class RunMainController extends MainLayoutBasicController implements Gene
 			// disposed message controller
 			// must be created beforehand
 			Panel empty = new Panel("empty");// empty panel set as "menu" and "tool"
-			Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, wControl,
-					courseRepositoryEntry.getResourceableId());
+			Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, wControl, courseRepositoryEntry);
 			Controller disposedRestartController = new LayoutMain3ColsController(ureq, wControl, empty, empty,
 					courseCloser.getInitialComponent(), "disposed course" + this.course.getResourceableId());
 			setDisposedMsgController(disposedRestartController);
diff --git a/src/main/java/org/olat/course/run/preview/PreviewConfigController.java b/src/main/java/org/olat/course/run/preview/PreviewConfigController.java
index f63f54f2570..aa41b730506 100644
--- a/src/main/java/org/olat/course/run/preview/PreviewConfigController.java
+++ b/src/main/java/org/olat/course/run/preview/PreviewConfigController.java
@@ -26,17 +26,14 @@
 package org.olat.course.run.preview;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-
+import org.olat.core.CoreSpringFactory;
 import org.olat.core.commons.fullWebApp.LayoutMain3ColsPreviewController;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.Component;
-
 import org.olat.core.gui.components.velocity.VelocityContainer;
 import org.olat.core.gui.control.Controller;
 import org.olat.core.gui.control.Event;
@@ -54,7 +51,10 @@ import org.olat.course.auditing.UserNodeAuditManager;
 import org.olat.course.groupsandrights.CourseGroupManager;
 import org.olat.course.properties.CoursePropertyManager;
 import org.olat.course.run.environment.CourseEnvironment;
+import org.olat.group.BusinessGroup;
+import org.olat.group.BusinessGroupService;
 import org.olat.group.area.BGArea;
+import org.olat.group.area.BGAreaManager;
 
 /**
  * Description: <br>
@@ -78,7 +78,10 @@ public class PreviewConfigController extends MainLayoutBasicController {
 	private boolean isCourseAdmin = false;
 	private String role = PreviewSettingsForm.ROLE_STUDENT;
 	private LayoutMain3ColsPreviewController previewLayoutCtr;
-	OLATResourceable ores;
+	private final OLATResourceable ores;
+	
+	private final BGAreaManager areaManager;
+	private final BusinessGroupService businessGroupService;
 
 	/**
 	 * Constructor for the run main controller
@@ -91,6 +94,9 @@ public class PreviewConfigController extends MainLayoutBasicController {
 	public PreviewConfigController(UserRequest ureq, WindowControl wControl, ICourse course) { 
 		super(ureq, wControl);
 		this.ores = course;
+		businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
+		areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
+		
 		psf = new PreviewSettingsForm(ureq, wControl, course);
 		listenTo(psf);
 		
@@ -142,33 +148,16 @@ public class PreviewConfigController extends MainLayoutBasicController {
 	}
 
 	private void generateEnvironment() {
-		String sGroups = psf.getGroup();
-		List groups;
-		// only do a split if we really have something to split, otherwise we'll get
-		// an empty object
-		if (sGroups.length() == 0) groups = new ArrayList();
-		else groups = Arrays.asList(psf.getGroup().split(","));
-
-		String sAreas = psf.getArea();
-		List tmpAreas;
-		// only do a split if we really have something to split, otherwise we'll get
-		// an empty object
-		if (sAreas.length() == 0) tmpAreas = new ArrayList();
-		else tmpAreas = Arrays.asList(psf.getArea().split(","));
-
+		List<BGArea> tmpAreas = areaManager.loadAreas(psf.getAreaKeys());
+		List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(psf.getGroupKeys());
 		// get learning areas for groups
-		Set areas = new HashSet();
+		Set<BGArea> areas = new HashSet<BGArea>();
 		areas.addAll(tmpAreas);
-		ICourse course = CourseFactory.loadCourse(ores);
-		for (Iterator iter = groups.iterator(); iter.hasNext();) {
-			String groupName = (String) iter.next();
-			List newAreas = course.getCourseEnvironment().getCourseGroupManager().getLearningAreasOfGroupFromAllContexts(groupName);
-			for (Iterator iterator = newAreas.iterator(); iterator.hasNext();) {
-				BGArea newArea = (BGArea) iterator.next();
-				areas.add(newArea.getName());
-			}
-		}
+		List<BGArea> areaByGroups = areaManager.findBGAreasOfBusinessGroups(groups);
+		areas.addAll(areaByGroups);
+		
 		role = psf.getRole();
+		ICourse course = CourseFactory.loadCourse(ores);
 		// default is student
 		isGlobalAuthor = false;
 		isGuestOnly = false;
@@ -187,7 +176,7 @@ public class PreviewConfigController extends MainLayoutBasicController {
 			isGlobalAuthor = true;
 		}
 
-		final CourseGroupManager cgm = new PreviewCourseGroupManager(groups, new ArrayList(areas), isCoach, isCourseAdmin);
+		final CourseGroupManager cgm = new PreviewCourseGroupManager(groups, new ArrayList<BGArea>(areas), isCoach, isCourseAdmin);
 		final UserNodeAuditManager auditman = new PreviewAuditManager();
 		final AssessmentManager am = new PreviewAssessmentManager();
 		final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
diff --git a/src/main/java/org/olat/course/run/preview/PreviewCourseGroupManager.java b/src/main/java/org/olat/course/run/preview/PreviewCourseGroupManager.java
index 0bbf14f2e80..8c93913fe88 100644
--- a/src/main/java/org/olat/course/run/preview/PreviewCourseGroupManager.java
+++ b/src/main/java/org/olat/course/run/preview/PreviewCourseGroupManager.java
@@ -87,7 +87,12 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#isIdentityInLearningGroup(org.olat.core.id.Identity, java.lang.String)
 	 */
 	public boolean isIdentityInGroup(Identity identity, String groupName) {
-		return groups.contains(groupName);
+		for(BusinessGroup group:groups) {
+			if(groupName.equals(group.getName())) {
+				return true;
+			}
+		}
+		return false;
 	}
 	
 	@Override
@@ -104,14 +109,24 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#isLearningGroupFull(java.lang.String)
 	 */
 	public boolean isLearningGroupFull(String groupName){
-		return groups.contains(groupName);
+		for(BusinessGroup group:groups) {
+			if(groupName.equals(group.getName())) {
+				return true;
+			}
+		}
+		return false;
 	}
 
 	/**
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#isIdentityInLearningArea(org.olat.core.id.Identity, java.lang.String)
 	 */
 	public boolean isIdentityInLearningArea(Identity identity, String areaName) {
-		return areas.contains(areaName);
+		for(BGArea area:areas) {
+			if(areaName.equals(area.getName())) {
+				return true;
+			}
+		}
+		return false;
 	}
 
 	@Override
@@ -126,11 +141,21 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 
 	@Override
 	public boolean existGroup(String nameOrKey) {
+		for(BusinessGroup group:groups) {
+			if(nameOrKey.equals(group.getName()) || nameOrKey.equals(group.getKey().toString())) {
+				return true;
+			}
+		}
 		return false;
 	}
 
 	@Override
 	public boolean existArea(String nameOrKey) {
+		for(BGArea area:areas) {
+			if(nameOrKey.equals(area.getName()) || nameOrKey.equals(area.getKey().toString())) {
+				return true;
+			}
+		}
 		return false;
 	}
 
@@ -213,7 +238,7 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 	 * @see org.olat.course.groupsandrights.CourseGroupManager#getAllRightGroupsFromAllContexts()
 	 */
 	public List<BusinessGroup> getAllRightGroupsFromAllContexts() {
-		throw new AssertException("unsupported");
+		return groups;
 	}
 
 	/**
@@ -225,7 +250,7 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 
 	@Override
 	public List<BGArea> getAreasFromContext(String areaname) {
-		return null;
+		return areas;
 	}
 
 	/**
@@ -275,6 +300,26 @@ final class PreviewCourseGroupManager extends BasicManager implements CourseGrou
 		throw new AssertException("unsupported");
 	}
 
+	@Override
+	public List<Identity> getCoachesFromLearningGroups(List<Long> groupKeys) {
+		throw new AssertException("unsupported");
+	}
+
+	@Override
+	public List<Identity> getCoachesFromAreas(List<Long> areaKeys) {
+		throw new AssertException("unsupported");
+	}
+
+	@Override
+	public List<Identity> getParticipantsFromLearningGroups(List<Long> groupKeys) {
+		throw new AssertException("unsupported");
+	}
+
+	@Override
+	public List<Identity> getParticipantsFromAreas(List<Long> areaKeys) {
+		throw new AssertException("unsupported");
+	}
+
 	public List<Identity> getParticipantsFromArea(String areaName) {
 		throw new AssertException("unsupported");
 	}
diff --git a/src/main/java/org/olat/course/run/preview/PreviewRunController.java b/src/main/java/org/olat/course/run/preview/PreviewRunController.java
index 3a3012f620e..dc504bd5066 100644
--- a/src/main/java/org/olat/course/run/preview/PreviewRunController.java
+++ b/src/main/java/org/olat/course/run/preview/PreviewRunController.java
@@ -27,7 +27,6 @@ package org.olat.course.run.preview;
 
 import java.text.DateFormat;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 import org.olat.core.commons.fullWebApp.LayoutMain3ColsPreviewController;
@@ -55,6 +54,8 @@ import org.olat.course.run.navigation.NavigationHandler;
 import org.olat.course.run.navigation.NodeClickedRef;
 import org.olat.course.run.userview.UserCourseEnvironment;
 import org.olat.course.run.userview.UserCourseEnvironmentImpl;
+import org.olat.group.BusinessGroup;
+import org.olat.group.area.BGArea;
 
 /**
  * Description: <br>
@@ -119,21 +120,28 @@ public class PreviewRunController extends MainLayoutBasicController {
 		detail.contextPut("time", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale())
 				.format(new Date(uce.getCourseEnvironment().getCurrentTimeMillis())));
 		CourseGroupManager cgm = uce.getCourseEnvironment().getCourseGroupManager();
-		detail.contextPut("groups", assembleNamesFromList(cgm.getAllLearningGroupsFromAllContexts()));
-		detail.contextPut("areas", assembleNamesFromList(cgm.getAllAreasFromAllContexts()));
+		detail.contextPut("groups", assembleNamesFromGroupList(cgm.getAllLearningGroupsFromAllContexts()));
+		detail.contextPut("areas", assembleNamesFromAreaList(cgm.getAllAreasFromAllContexts()));
 		detail.contextPut("asRole",role);
 		previewLayoutCtr.setCol3(detail);
-		
 	}
 
-	private String assembleNamesFromList(List nameList) {
+	private String assembleNamesFromGroupList(List<BusinessGroup> groups) {
+		StringBuilder sb = new StringBuilder();
+		for (BusinessGroup group:groups) {
+			if(sb.length() > 0) sb.append(',');
+			sb.append(group.getName());
+		}
+		return sb.toString();
+	}
+	
+	private String assembleNamesFromAreaList(List<BGArea> areas) {
 		StringBuilder sb = new StringBuilder();
-		for (Iterator iter = nameList.iterator(); iter.hasNext();) {
-			sb.append((String)iter.next());
-			sb.append(',');
+		for (BGArea area:areas) {
+			if(sb.length() > 0) sb.append(',');
+			sb.append(area.getName());
 		}
-		if (sb.length() == 0) return new String();
-		else return sb.substring(0, sb.length() -1); // truncate last colon
+		return sb.toString();
 	}
 	
 	/**
diff --git a/src/main/java/org/olat/course/run/preview/PreviewSettingsForm.java b/src/main/java/org/olat/course/run/preview/PreviewSettingsForm.java
index b5e1078f062..c2e8440483a 100644
--- a/src/main/java/org/olat/course/run/preview/PreviewSettingsForm.java
+++ b/src/main/java/org/olat/course/run/preview/PreviewSettingsForm.java
@@ -37,6 +37,7 @@ import org.olat.core.gui.components.form.flexible.FormItemContainer;
 import org.olat.core.gui.components.form.flexible.elements.DateChooser;
 import org.olat.core.gui.components.form.flexible.elements.FormLink;
 import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
+import org.olat.core.gui.components.form.flexible.elements.StaticTextElement;
 import org.olat.core.gui.components.form.flexible.elements.TextElement;
 import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
 import org.olat.core.gui.components.form.flexible.impl.FormEvent;
@@ -49,6 +50,7 @@ import org.olat.core.util.StringHelper;
 import org.olat.course.ICourse;
 import org.olat.course.condition.AreaSelectionController;
 import org.olat.course.condition.GroupSelectionController;
+import org.olat.course.groupsandrights.CourseGroupManager;
 
 /**
  * Description:<br>
@@ -69,7 +71,7 @@ public class PreviewSettingsForm extends FormBasicController {
 	
 	private DateChooser sdate;
 	
-	private TextElement group, area;
+	private StaticTextElement group, area;
 	private FormLink groupChooserLink, areaChooserLink;
 
 	private final int NUMATTR = 5;
@@ -78,7 +80,7 @@ public class PreviewSettingsForm extends FormBasicController {
 	
 	private SingleSelection roles;
 	
-	private ICourse course;
+	private final CourseGroupManager courseGroupManager;
 	private AreaSelectionController areaChooser;
 	private GroupSelectionController groupChooser;
 	
@@ -86,7 +88,7 @@ public class PreviewSettingsForm extends FormBasicController {
 	
 	public PreviewSettingsForm(UserRequest ureq, WindowControl wControl, ICourse course) {
 		super(ureq, wControl);
-		this.course = course;
+		courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
 		initForm(ureq);	
 	}
 
@@ -94,22 +96,28 @@ public class PreviewSettingsForm extends FormBasicController {
 	/**
 	 * @return group
 	 */
-	public String getGroup() { return group.getValue(); }
+	public List<Long> getGroupKeys() { 
+		return getKeys(group);
+	}
 
 	/**
 	 * @return area
 	 */
-	public String getArea() { return area.getValue(); }
+	public List<Long> getAreaKeys() { 
+		return getKeys(area);
+	}
 	
 	/**
 	 * @return date
 	 */
-	public Date getDate() { return sdate.getDate(); }
+	public Date getDate() { 
+		return sdate.getDate();
+	}
 	
 	/**
 	 * @return attributes map
 	 */
-	public Map getAttributesMap() {
+	public Map<String,String> getAttributesMap() {
 		Map <String,String>attributesMap = new HashMap<String,String>();
 		for (int i=0; i<attrNames.size(); i++) {
 			if (!attrNames.get(i).isEmpty()) {
@@ -132,9 +140,7 @@ public class PreviewSettingsForm extends FormBasicController {
 
 	@Override
 	protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
-		
-		sdate = uifactory.addDateChooser("sdate","form.sdate" , "", formLayout);
-				
+		sdate = uifactory.addDateChooser("sdate","form.sdate" , "", formLayout);	
 		sdate.setExampleKey("form.easy.example.bdate", null);
 		sdate.setDateChooserDateFormat("%d.%m.%Y %H:%M");
 		sdate.setCustomDateFormat("dd.MM.yyyy HH:mm");
@@ -147,14 +153,14 @@ public class PreviewSettingsForm extends FormBasicController {
 		FormLayoutContainer groupLayout = FormLayoutContainer.createHorizontalFormLayout("groupChooser", getTranslator());
 		groupLayout.setLabel("form.group", null);
 		formLayout.add(groupLayout);
-		group = uifactory.addTextElement("group", null, 255, "", groupLayout);
+		group = uifactory.addStaticTextElement("group", null, "", groupLayout);
 		groupChooserLink = uifactory.addFormLink("choose", groupLayout,"b_form_genericchooser");
 	
 		
 		FormLayoutContainer areaLayout = FormLayoutContainer.createHorizontalFormLayout("areaChooser", getTranslator());
 		areaLayout.setLabel("form.area", null);
 		formLayout.add(areaLayout);
-		area = uifactory.addTextElement("area", null, 255, "", areaLayout);
+		area = uifactory.addStaticTextElement("area", null, "", areaLayout);
 		areaChooserLink = uifactory.addFormLink("choose", areaLayout,"b_form_genericchooser");
 		
 		
@@ -194,32 +200,21 @@ public class PreviewSettingsForm extends FormBasicController {
 	@Override
 	protected void  formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
 		if (source == groupChooserLink) {
-			removeAsListenerAndDispose (groupChooser);
-			groupChooser = new GroupSelectionController(ureq, getWindowControl(), "group",
-					course.getCourseEnvironment().getCourseGroupManager(), null /* group.getValue() */); //TODO gm
-			listenTo(groupChooser);
-				
 			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-				getWindowControl(),
-				translate("close"),
-				groupChooser.getInitialComponent()
-			);
+			removeAsListenerAndDispose (groupChooser);
+			
+			groupChooser = new GroupSelectionController(ureq, getWindowControl(), "group", courseGroupManager, getKeys(group));
+			listenTo(groupChooser);	
+			cmc = new CloseableModalController(getWindowControl(), translate("close"), groupChooser.getInitialComponent());
 			listenTo(cmc);
 			cmc.activate();
-			
 		} else if (source == areaChooserLink) {
+			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose (areaChooser);
-			areaChooser = new AreaSelectionController(ureq, getWindowControl(), "area",
-					course.getCourseEnvironment().getCourseGroupManager(), null /* area.getValue() */);//TODO gm
+			
+			areaChooser = new AreaSelectionController(ureq, getWindowControl(), "area", courseGroupManager, getKeys(area));
 			listenTo(areaChooser);
-
-			removeAsListenerAndDispose(cmc);
-			cmc = new CloseableModalController(
-				getWindowControl(),
-				translate("close"),
-				areaChooser.getInitialComponent()
-			);
+			cmc = new CloseableModalController(getWindowControl(), translate("close"), areaChooser.getInitialComponent());
 			listenTo(cmc);
 			cmc.activate();
 		}
@@ -229,11 +224,12 @@ public class PreviewSettingsForm extends FormBasicController {
 	protected void event(UserRequest ureq, Controller source, Event event) {
 		if (source == groupChooser) {
 			cmc.deactivate();
-			group.setValue(StringHelper.formatAsCSVString(groupChooser.getSelectedEntries()));
-
+			group.setValue(StringHelper.formatAsCSVString(groupChooser.getSelectedNames()));
+			group.setUserObject(groupChooser.getSelectedKeys());
 		} else if (source == areaChooser) {
 			cmc.deactivate();
-			area.setValue(StringHelper.formatAsCSVString(areaChooser.getSelectedEntries()));
+			area.setValue(StringHelper.formatAsCSVString(areaChooser.getSelectedNames()));
+			area.setUserObject(areaChooser.getSelectedKeys());
 		}
 	}
 	@Override
@@ -244,5 +240,14 @@ public class PreviewSettingsForm extends FormBasicController {
 	protected boolean validateFormLogic(UserRequest ureq) {
 		return sdate.getDate()!=null;
 	}
-}
-
+	
+	private List<Long> getKeys(StaticTextElement element) {
+		@SuppressWarnings("unchecked")
+		List<Long> keys = (List<Long>)element.getUserObject();
+		if(keys == null) {
+			keys = new ArrayList<Long>();
+			element.setUserObject(keys);
+		}
+		return keys;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/org/olat/group/BusinessGroupManagerImpl.java b/src/main/java/org/olat/group/BusinessGroupManagerImpl.java
index 344cbf0fd30..f5f69aad7e6 100644
--- a/src/main/java/org/olat/group/BusinessGroupManagerImpl.java
+++ b/src/main/java/org/olat/group/BusinessGroupManagerImpl.java
@@ -489,9 +489,7 @@ public class BusinessGroupManagerImpl extends BasicManager implements BusinessGr
 			}
 		}
 	}
-	
-	//TODO gm
-	
+
 	private void removeFromRepositoryEntrySecurityGroup(BusinessGroup group) {
 		*//*
 		BGContext context = group.getGroupContext();
diff --git a/src/main/java/org/olat/group/area/BGAreaManagerImpl.java b/src/main/java/org/olat/group/area/BGAreaManagerImpl.java
index 11f7d910690..d74f36ae77a 100644
--- a/src/main/java/org/olat/group/area/BGAreaManagerImpl.java
+++ b/src/main/java/org/olat/group/area/BGAreaManagerImpl.java
@@ -388,6 +388,7 @@ public class BGAreaManagerImpl extends BasicManager implements BGAreaManager {
 		Number count = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Number.class)
 				.setParameter("resourceKey", resource.getKey())
 				.setParameter("names", allNames)
+				.setHint("org.hibernate.cacheable", Boolean.TRUE)
 				.getSingleResult();
 		return count.intValue() > 0;
 	}
@@ -412,6 +413,7 @@ public class BGAreaManagerImpl extends BasicManager implements BGAreaManager {
 		Number count = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Number.class)
 				.setParameter("resourceKey", resource.getKey())
 				.setParameter("nameOrKey", key == null ? nameOrKey : key)
+				.setHint("org.hibernate.cacheable", Boolean.TRUE)
 				.getSingleResult();
 		return count.intValue() > 0;
 	}
@@ -436,7 +438,7 @@ public class BGAreaManagerImpl extends BasicManager implements BGAreaManager {
 	
 	/**
 	 * Remove a business group from a business group area. If no such relation
-	 * exists, the mehthod does nothing.
+	 * exists, the method does nothing.
 	 * 
 	 * @param businessGroupKey
 	 * @param bgAreaKey
diff --git a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java
index f2054fc176f..e92823d678c 100644
--- a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java
+++ b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java
@@ -480,7 +480,7 @@ public class LearningGroupWebService {
 			if(identity == null || group == null) {
 				return Response.serverError().status(Status.NOT_FOUND).build();
 			}
-		//TODO gm sync
+		//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(group, new SyncerCallback<Boolean>(){
 				public Boolean execute() {
 					BGConfigFlags flags = BGConfigFlags.createLearningGroupDefaultFlags();
@@ -540,7 +540,7 @@ public class LearningGroupWebService {
 			if(identity == null || group == null) {
 				return Response.serverError().status(Status.NOT_FOUND).build();
 			}
-		//TODO gm sync
+		//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(group, new SyncerCallback<Boolean>(){
 				public Boolean execute() {
 					BGConfigFlags flags = BGConfigFlags.createLearningGroupDefaultFlags();
@@ -597,7 +597,7 @@ public class LearningGroupWebService {
 			if(identity == null || group == null) {
 				return Response.serverError().status(Status.NOT_FOUND).build();
 			}
-		//TODO gm sync
+		//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(group, new SyncerCallback<Boolean>(){
 				public Boolean execute() {
 					BGConfigFlags flags = BGConfigFlags.createLearningGroupDefaultFlags();
@@ -654,7 +654,7 @@ public class LearningGroupWebService {
 			if(identity == null || group == null) {
 				return Response.serverError().status(Status.NOT_FOUND).build();
 			}
-			//TODO gm sync
+			//TODO gsync
 			CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(group, new SyncerExecutor(){
 				public void execute() {
 					BGConfigFlags flags = BGConfigFlags.createLearningGroupDefaultFlags();
diff --git a/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java b/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
index c57486765f4..d24b90a286b 100644
--- a/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
+++ b/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
@@ -127,7 +127,6 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 	
 	private boolean upgradeGroups(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
 		if (!uhd.getBooleanDataValue(TASK_CONTEXTS)) {
-
 			int counter = 0;
 			List<BusinessGroup> groups;
 			do {
@@ -141,14 +140,12 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 			
 			uhd.setBooleanDataValue(TASK_CONTEXTS, true);
 			upgradeManager.setUpgradesHistory(uhd, VERSION);
-			return false;
 		}
-		return false;
+		return true;
 	}
 	
 	private boolean upgradeAreas(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
 		if (!uhd.getBooleanDataValue(TASK_AREAS)) {
-
 			int counter = 0;
 			List<BGAreaImpl> areas;
 			do {
@@ -162,9 +159,8 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 			
 			uhd.setBooleanDataValue(TASK_AREAS, true);
 			upgradeManager.setUpgradesHistory(uhd, VERSION);
-			return false;
 		}
-		return false;
+		return true;
 	}
 	
 	private boolean upgradeCourseConditions(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
@@ -185,9 +181,8 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 			
 			uhd.setBooleanDataValue(TASK_CONDITIONS, false);
 			upgradeManager.setUpgradesHistory(uhd, VERSION);
-			return false;
 		}
-		return false;
+		return true;
 	}
 	
 	private void processCourse(RepositoryEntry entry) {
@@ -324,7 +319,7 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 		for(String groupName:groupNameArr) {
 			groupName = groupName.trim();
 			for(BusinessGroup group:groups) {
-				if(groupName.equals(group.getName())) {
+				if(groupName.equalsIgnoreCase(group.getName())) {
 					if(sb.length() > 0) {
 						sb.append(',');
 					}
@@ -343,7 +338,7 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 		for(String areaName:areaNameArr) {
 			areaName = areaName.trim();
 			for(BGArea area:areas) {
-				if(areaName.equals(area.getName())) {
+				if(areaName.equalsIgnoreCase(area.getName())) {
 					if(sb.length() > 0) {
 						sb.append(',');
 					}
-- 
GitLab