Search in sources :

Example 61 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.

the class ChecklistCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    boolean canEdit = ureq.getUserSession().getRoles().isOLATAdmin() || cgm.isIdentityCourseAdministrator(ureq.getIdentity());
    boolean canManage;
    if (canEdit) {
        canManage = true;
    } else {
        canManage = cgm.isIdentityCourseCoach(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_GROUPMANAGEMENT);
    }
    Checklist checklist = loadOrCreateChecklist(userCourseEnv.getCourseEnvironment().getCoursePropertyManager());
    ChecklistDisplayController checkController = new ChecklistDisplayController(ureq, wControl, checklist, canEdit, canManage, userCourseEnv.isCourseReadOnly(), course);
    checkController.addLoggingResourceable(LoggingResourceable.wrap(this));
    // Add title and descrition
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, checkController, this, "o_cl_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : ChecklistDisplayController(de.bps.olat.modules.cl.ChecklistDisplayController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) Checklist(de.bps.olat.modules.cl.Checklist) ICourse(org.olat.course.ICourse) NodeEditController(org.olat.course.editor.NodeEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ChecklistDisplayController(de.bps.olat.modules.cl.ChecklistDisplayController) ChecklistEditController(de.bps.course.nodes.cl.ChecklistEditController) Controller(org.olat.core.gui.control.Controller) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 62 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.

the class AssessmentNotificationsHandler method canSubscribeForAssessmentNotification.

/**
 * Assessment notification rights check.<br>
 * Tests if an <code>Identity</code> can subscribe for assessment
 * notification for the specified <code>ICourse</code>.<br>
 * <br>
 * <b>PRE CONDITIONS</b>
 * <ul>
 * <li> <code>course != null</code>
 * </ul>
 *
 * @param ident the identity to check rights for. Can be <code>null</code>
 * @param course the course to check rights against
 * @return if <code>ident == null</code> this method always returns false;
 *         otherwise subscriptions rights are met only by course
 *         administrators and course coaches
 */
private boolean canSubscribeForAssessmentNotification(Identity ident, ICourse course) {
    if (ident == null)
        return false;
    CourseGroupManager grpMan = course.getCourseEnvironment().getCourseGroupManager();
    boolean isInstitutionalResourceManager = securityManager.isIdentityInSecurityGroup(ident, securityManager.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER));
    return isInstitutionalResourceManager || grpMan.isIdentityCourseAdministrator(ident) || grpMan.isIdentityCourseCoach(ident) || grpMan.hasRight(ident, CourseRights.RIGHT_ASSESSMENT);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager)

Example 63 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.

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 64 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.

the class InLearningAreaFunction 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.areaname"));
    } else if (inStack.length < 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.areaname"));
    }
    /*
		 * argument type check
		 */
    if (!(inStack[0] instanceof String))
        return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.areanameexpected", "solution.example.name.infunction"));
    String areaName = (String) inStack[0];
    areaName = areaName != null ? areaName.trim() : areaName;
    /*
		 * check reference integrity
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        if (!cev.existsArea(areaName)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, areaName, "error.notfound.name", "solution.checkgroupmanagement"));
        }
        // remember the reference to the node id for this condtion
        cev.addSoftReference("areaId", areaName, false);
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    // The real function evaluation which is used during run time
    Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
    CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
    if (StringHelper.isLong(areaName)) {
        Long areaKey = new Long(areaName);
        return cgm.isIdentityInLearningArea(ident, areaKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
    }
    List<Long> areaKeys = CoreSpringFactory.getImpl(BGAreaManager.class).toAreaKeys(areaName, cgm.getCourseResource());
    if (!areaKeys.isEmpty()) {
        return cgm.isIdentityInLearningArea(ident, areaKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
    }
    return ConditionInterpreter.INT_FALSE;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) Identity(org.olat.core.id.Identity) BGAreaManager(org.olat.group.area.BGAreaManager)

Example 65 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.

the class GTACoachedParticipantListController method collectIdentities.

private void collectIdentities(Consumer<Identity> participantCollector) {
    Set<Identity> duplicateKiller = new HashSet<>();
    CourseGroupManager cgm = coachCourseEnv.getCourseEnvironment().getCourseGroupManager();
    boolean admin = coachCourseEnv.isAdmin();
    List<BusinessGroup> coachedGroups = admin ? cgm.getAllBusinessGroups() : coachCourseEnv.getCoachedGroups();
    List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
    for (Identity participant : participants) {
        if (!duplicateKiller.contains(participant)) {
            participantCollector.accept(participant);
            duplicateKiller.add(participant);
        }
    }
    RepositoryEntry re = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    boolean repoTutor = admin || (coachedGroups.isEmpty() && repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name()));
    if (repoTutor) {
        List<Identity> courseParticipants = repositoryService.getMembers(re, GroupRoles.participant.name());
        for (Identity participant : courseParticipants) {
            if (!duplicateKiller.contains(participant)) {
                participantCollector.accept(participant);
                duplicateKiller.add(participant);
            }
        }
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

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