Search in sources :

Example 16 with CourseGroupManager

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;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroupService(org.olat.group.BusinessGroupService) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv)

Example 17 with CourseGroupManager

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...
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarNotificationManager(org.olat.commons.calendar.CalendarNotificationManager) AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) OLATResourceable(org.olat.core.id.OLATResourceable) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 18 with CourseGroupManager

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);
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) TACourseNode(org.olat.course.nodes.TACourseNode)

Example 19 with CourseGroupManager

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();
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) GroupSelectionController(org.olat.course.condition.GroupSelectionController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ICourse(org.olat.course.ICourse)

Example 20 with CourseGroupManager

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();
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ICourse(org.olat.course.ICourse) AreaSelectionController(org.olat.course.condition.AreaSelectionController)

Aggregations

CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)84 Identity (org.olat.core.id.Identity)28 ICourse (org.olat.course.ICourse)28 BusinessGroup (org.olat.group.BusinessGroup)26 RepositoryEntry (org.olat.repository.RepositoryEntry)22 HashSet (java.util.HashSet)12 Roles (org.olat.core.id.Roles)12 ArrayList (java.util.ArrayList)10 BusinessGroupService (org.olat.group.BusinessGroupService)10 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)8 UserRequest (org.olat.core.gui.UserRequest)8 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)8 PersistingCourseGroupManager (org.olat.course.groupsandrights.PersistingCourseGroupManager)8 OLATResource (org.olat.resource.OLATResource)8 File (java.io.File)6 Date (java.util.Date)6 CalendarManager (org.olat.commons.calendar.CalendarManager)6 Publisher (org.olat.core.commons.services.notifications.Publisher)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 AssertException (org.olat.core.logging.AssertException)6