use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class IsLearningGroupFullFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.groupname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.groupname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.groupnameexpected", "solution.example.name.infunction"));
String groupName = (String) inStack[0];
groupName = groupName != null ? groupName.trim() : null;
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsGroup(groupName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, groupName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condition
cev.addSoftReference("groupId", groupName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
if (StringHelper.isLong(groupName)) {
Long groupKey = new Long(groupName);
return cgm.isBusinessGroupFull(groupKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
List<Long> groupKeys = CoreSpringFactory.getImpl(BusinessGroupService.class).toGroupKeys(groupName, cgm.getCourseEntry());
if (!groupKeys.isEmpty()) {
return cgm.isBusinessGroupFull(groupKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method clearCalenderSubscriptions.
/**
* Checks all learning group calendars and the course calendar for publishers (of subscriptions)
* and sets their state to "1" which indicates that the ressource is deleted.
*/
private static void clearCalenderSubscriptions(OLATResourceable res, ICourse course) {
// set Publisher state to 1 (= ressource is deleted) for all calendars of the course
CalendarManager calMan = CoreSpringFactory.getImpl(CalendarManager.class);
CalendarNotificationManager notificationManager = CoreSpringFactory.getImpl(CalendarNotificationManager.class);
NotificationsManager nfm = NotificationsManager.getInstance();
if (course != null) {
CourseGroupManager courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
List<BusinessGroup> learningGroups = courseGroupManager.getAllBusinessGroups();
// all learning and right group calendars
for (BusinessGroup bg : learningGroups) {
KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
SubscriptionContext subsContext = notificationManager.getSubscriptionContext(calRenderWrapper);
Publisher pub = nfm.getPublisher(subsContext);
if (pub != null) {
// int 0 is OK -> all other is not OK
pub.setState(1);
}
}
}
// the course calendar
try {
/**
* TODO:gs 2010-01-26
* OLAT-4947: if we do not have an repo entry we get an exception here.
* This is normal in the case of courseimport and click canceling.
*/
KalendarRenderWrapper courseCalendar = calMan.getCalendarForDeletion(res);
if (courseCalendar != null) {
SubscriptionContext subContext = notificationManager.getSubscriptionContext(courseCalendar, res);
OLATResourceable oresToDelete = OresHelper.createOLATResourceableInstance(subContext.getResName(), subContext.getResId());
nfm.deletePublishersOf(oresToDelete);
}
} catch (AssertException e) {
// if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
}
}
use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class GenericArchiveController method doSelectNode.
private void doSelectNode(UserRequest ureq, AssessmentNodeData nodeData) {
ICourse course = CourseFactory.loadCourse(ores);
CourseNode node = course.getRunStructure().getNode(nodeData.getIdent());
// some node can limit the archive to a business group
if (node instanceof TACourseNode) {
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
List<BusinessGroup> relatedGroups = cgm.getAllBusinessGroups();
if (relatedGroups.isEmpty()) {
archiveNode(ureq, node, null);
} else {
doSelectBusinessGroup(ureq, node, relatedGroups);
}
} else {
archiveNode(ureq, node, null);
}
}
use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class AssessmentModeEditController method doChooseGroups.
private void doChooseGroups(UserRequest ureq) {
if (groupChooseCtrl != null)
return;
ICourse course = CourseFactory.loadCourse(courseOres);
CourseGroupManager groupManager = course.getCourseEnvironment().getCourseGroupManager();
groupChooseCtrl = new GroupSelectionController(ureq, getWindowControl(), true, groupManager, groupKeys);
listenTo(groupChooseCtrl);
cmc = new CloseableModalController(getWindowControl(), null, groupChooseCtrl.getInitialComponent(), true, translate("popup.choosegroups"), false);
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class AssessmentModeEditController method doChooseAreas.
private void doChooseAreas(UserRequest ureq) {
if (areaChooseCtrl != null)
return;
ICourse course = CourseFactory.loadCourse(courseOres);
CourseGroupManager groupManager = course.getCourseEnvironment().getCourseGroupManager();
areaChooseCtrl = new AreaSelectionController(ureq, getWindowControl(), true, groupManager, areaKeys);
listenTo(areaChooseCtrl);
cmc = new CloseableModalController(getWindowControl(), null, areaChooseCtrl.getInitialComponent(), true, translate("popup.chooseareas"), false);
listenTo(cmc);
cmc.activate();
}
Aggregations