Search in sources :

Example 41 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.

the class CourseCalendarController method getListOfCalendarWrappers.

private List<KalendarRenderWrapper> getListOfCalendarWrappers(UserRequest ureq) {
    List<KalendarRenderWrapper> calendars = new ArrayList<>();
    // add course calendar
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
    courseKalendarWrapper = calendarManager.getCourseCalendar(course);
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    Roles roles = ureq.getUserSession().getRoles();
    boolean isPrivileged = !userCourseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || userCourseEnv.isAdmin() || repositoryManager.isInstitutionalRessourceManagerFor(getIdentity(), roles, cgm.getCourseEntry()));
    if (isPrivileged) {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        courseKalendarWrapper.setPrivateEventsVisible(true);
    } else {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        courseKalendarWrapper.setPrivateEventsVisible(userCourseEnv.isAdmin() || userCourseEnv.isCoach() || userCourseEnv.isParticipant());
    }
    CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), getIdentity());
    if (config != null) {
        courseKalendarWrapper.setConfiguration(config);
    }
    // add link provider
    CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.<ICourse>singletonList(course), ureq, getWindowControl());
    courseKalendarWrapper.setLinkProvider(clpc);
    calendars.add(courseKalendarWrapper);
    // add course group calendars
    // learning groups
    List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(getIdentity());
    addCalendars(ownerGroups, !userCourseEnv.isCourseReadOnly(), clpc, calendars);
    List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(getIdentity());
    for (Iterator<BusinessGroup> ownerGroupsIterator = ownerGroups.iterator(); ownerGroupsIterator.hasNext(); ) {
        BusinessGroup ownerGroup = ownerGroupsIterator.next();
        if (attendedGroups.contains(ownerGroup))
            attendedGroups.remove(ownerGroup);
    }
    addCalendars(attendedGroups, false, clpc, calendars);
    return calendars;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 42 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.

the class MembersPeekViewController method readFormData.

protected void readFormData(ModuleConfiguration config) {
    CourseGroupManager cgm = courseEnv.getCourseGroupManager();
    RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<Identity> owners = MembersHelpers.getOwners(repositoryService, courseRepositoryEntry);
    List<Identity> coaches = new ArrayList<>();
    MembersHelpers.addCoaches(config, cgm, businessGroupService, coaches);
    List<Identity> participants = new ArrayList<>();
    MembersHelpers.addParticipants(config, cgm, businessGroupService, participants);
    Set<Long> duplicateCatcher = new HashSet<Long>();
    List<Identity> filteredOwners = owners.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    List<Identity> filteredCoaches = coaches.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    List<Identity> filteredParticipants = participants.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    entries.add(new Row(translate("members.owners"), Integer.toString(filteredOwners.size())));
    entries.add(new Row(translate("members.coaches"), Integer.toString(filteredCoaches.size())));
    entries.add(new Row(translate("members.participants"), Integer.toString(filteredParticipants.size())));
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) RepositoryService(org.olat.repository.RepositoryService) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) BasicController(org.olat.core.gui.control.controller.BasicController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) DefaultTableDataModel(org.olat.core.gui.components.table.DefaultTableDataModel) List(java.util.List) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) TableController(org.olat.core.gui.components.table.TableController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 43 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.

the class PreviewConfigController method generateEnvironment.

private void generateEnvironment() {
    List<BGArea> tmpAreas = areaManager.loadAreas(psf.getAreaKeys());
    List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(psf.getGroupKeys());
    // get learning areas for groups
    Set<BGArea> areas = new HashSet<BGArea>();
    areas.addAll(tmpAreas);
    List<BGArea> areaByGroups = areaManager.findBGAreasOfBusinessGroups(groups);
    areas.addAll(areaByGroups);
    role = psf.getRole();
    ICourse course = CourseFactory.loadCourse(ores);
    // default is student
    isGlobalAuthor = false;
    isGuestOnly = false;
    isCoach = false;
    isCourseAdmin = false;
    /*
		 * if (role.equals(PreviewSettingsForm.ROLE_STUDENT)) { } else
		 */
    if (role.equals(PreviewSettingsForm.ROLE_GUEST)) {
        isGuestOnly = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSECOACH)) {
        isCoach = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSEADMIN)) {
        isCourseAdmin = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_GLOBALAUTHOR)) {
        isGlobalAuthor = true;
    }
    final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(groups), new ArrayList<BGArea>(areas), isCoach, isCourseAdmin);
    final UserNodeAuditManager auditman = new PreviewAuditManager();
    final AssessmentManager am = new PreviewAssessmentManager();
    final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
    final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
    final String title = course.getCourseTitle();
    final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    simCourseEnv = new PreviewCourseEnvironment(title, runStructure, psf.getDate(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
    simIdentEnv = new IdentityEnvironment();
    simIdentEnv.setRoles(new Roles(false, false, false, isGlobalAuthor, isGuestOnly, false, false));
    final Identity ident = new PreviewIdentity();
    simIdentEnv.setIdentity(ident);
    // identity must be set before attributes OLAT-4811
    simIdentEnv.setAttributes(psf.getAttributesMap());
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseConfig(org.olat.course.config.CourseConfig) BGArea(org.olat.group.area.BGArea) Structure(org.olat.course.Structure) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) HashSet(java.util.HashSet) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 44 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.

the class SPRunController method hasEditRights.

private boolean hasEditRights(UserRequest ureq) {
    if (userCourseEnv.isCourseReadOnly())
        return false;
    if (fileName != null && fileName.startsWith("/_sharedfolder")) {
        if (userCourseEnv.getCourseEnvironment().getCourseConfig().isSharedFolderReadOnlyMount()) {
            return false;
        }
    }
    if (isFileTypeEditable(fileName)) {
        Roles roles = ureq.getUserSession().getRoles();
        if (roles.isOLATAdmin()) {
            return true;
        }
        CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
        if (roles.isInstitutionalResourceManager() && repositoryManager.isInstitutionalRessourceManagerFor(getIdentity(), roles, cgm.getCourseEntry())) {
            return true;
        }
        if (config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false)) {
            if (cgm.isIdentityCourseCoach(ureq.getIdentity())) {
                return true;
            }
        }
        return cgm.isIdentityCourseAdministrator(getIdentity()) || cgm.hasRight(getIdentity(), CourseRights.RIGHT_COURSEEDITOR);
    }
    return false;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) Roles(org.olat.core.id.Roles)

Example 45 with CourseGroupManager

use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.

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)

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