Search in sources :

Example 76 with CourseGroupManager

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

the class PFNotifications method getItems.

public List<SubscriptionListItem> getItems() throws Exception {
    Publisher p = subscriber.getPublisher();
    Identity identity = subscriber.getIdentity();
    ICourse course = CourseFactory.loadCourse(p.getResId());
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CourseGroupManager groupManager = courseEnv.getCourseGroupManager();
    CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    Date latestNews = p.getLatestNewsDate();
    if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
        this.displayname = entry.getDisplayname();
        if (groupManager.isIdentityCourseCoach(identity) || groupManager.isIdentityCourseAdministrator(identity)) {
            List<Identity> participants = pfManager.getParticipants(identity, courseEnv, groupManager.isIdentityCourseAdministrator(identity));
            for (Identity participant : participants) {
                gatherItems(participant, p, courseEnv, node);
            }
        } else {
            gatherItems(identity, p, courseEnv, node);
        }
    }
    return items;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date)

Example 77 with CourseGroupManager

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

the class RunMainController method loadUserCourseEnvironment.

private UserCourseEnvironmentImpl loadUserCourseEnvironment(UserRequest ureq, RepositoryEntrySecurity reSecurity) {
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    List<BusinessGroup> coachedGroups;
    if (reSecurity.isGroupCoach()) {
        coachedGroups = cgm.getOwnedBusinessGroups(ureq.getIdentity());
    } else {
        coachedGroups = Collections.emptyList();
    }
    List<BusinessGroup> participatedGroups;
    if (reSecurity.isGroupParticipant()) {
        participatedGroups = cgm.getParticipatingBusinessGroups(ureq.getIdentity());
    } else {
        participatedGroups = Collections.emptyList();
    }
    List<BusinessGroup> waitingLists;
    if (reSecurity.isGroupWaiting()) {
        waitingLists = cgm.getWaitingListGroups(ureq.getIdentity());
    } else {
        waitingLists = Collections.emptyList();
    }
    return new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment(), getWindowControl(), coachedGroups, participatedGroups, waitingLists, reSecurity.isCourseCoach() || reSecurity.isGroupCoach(), reSecurity.isEntryAdmin(), reSecurity.isCourseParticipant() || reSecurity.isGroupParticipant(), reSecurity.isReadOnly());
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroup(org.olat.group.BusinessGroup)

Example 78 with CourseGroupManager

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

the class RunMainController method reloadGroupMemberships.

/**
 * Initialize the users group memberships for groups used within this course
 *
 * @param identity
 */
protected void reloadGroupMemberships(RepositoryEntrySecurity reSecurity) {
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    List<BusinessGroup> coachedGroups;
    if (reSecurity.isGroupCoach()) {
        coachedGroups = cgm.getOwnedBusinessGroups(getIdentity());
    } else {
        coachedGroups = Collections.emptyList();
    }
    List<BusinessGroup> participatedGroups;
    if (reSecurity.isGroupParticipant()) {
        participatedGroups = cgm.getParticipatingBusinessGroups(getIdentity());
    } else {
        participatedGroups = Collections.emptyList();
    }
    List<BusinessGroup> waitingLists;
    if (reSecurity.isGroupWaiting()) {
        waitingLists = cgm.getWaitingListGroups(getIdentity());
    } else {
        waitingLists = Collections.emptyList();
    }
    uce.setCourseReadOnly(reSecurity.isReadOnly());
    uce.setGroupMemberships(coachedGroups, participatedGroups, waitingLists);
    needsRebuildAfterRunDone = true;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup)

Example 79 with CourseGroupManager

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

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

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

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)

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