Search in sources :

Example 6 with CourseLinkProviderController

use of org.olat.course.run.calendar.CourseLinkProviderController in project openolat by klemens.

the class CourseCalendars method createCourseCalendarsWrapper.

public static CourseCalendars createCourseCalendarsWrapper(UserRequest ureq, WindowControl wControl, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    List<KalendarRenderWrapper> calendars = new ArrayList<>();
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
    KalendarRenderWrapper courseKalendarWrapper = getCourseCalendarWrapper(ureq, courseEnv, ne);
    // add link provider
    CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.singletonList(course), ureq, wControl);
    courseKalendarWrapper.setLinkProvider(clpc);
    calendars.add(courseKalendarWrapper);
    Identity identity = ureq.getIdentity();
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    // add course group calendars
    boolean isGroupManager = ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isGroupManager() || cgm.isIdentityCourseAdministrator(identity) || cgm.hasRight(identity, CourseRights.RIGHT_GROUPMANAGEMENT);
    boolean readOnly = courseEnv.isCourseReadOnly();
    if (isGroupManager) {
        // learning groups
        List<BusinessGroup> allGroups = cgm.getAllBusinessGroups();
        addCalendars(ureq, courseEnv, allGroups, !readOnly, clpc, calendars);
    } else {
        // learning groups
        List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(identity);
        addCalendars(ureq, courseEnv, ownerGroups, !readOnly, clpc, calendars);
        List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(identity);
        for (BusinessGroup ownerGroup : ownerGroups) {
            if (attendedGroups.contains(ownerGroup)) {
                attendedGroups.remove(ownerGroup);
            }
        }
        addCalendars(ureq, courseEnv, attendedGroups, false, clpc, calendars);
    }
    return new CourseCalendars(courseKalendarWrapper, calendars);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Identity(org.olat.core.id.Identity)

Aggregations

KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)6 ICourse (org.olat.course.ICourse)6 CourseLinkProviderController (org.olat.course.run.calendar.CourseLinkProviderController)6 ArrayList (java.util.ArrayList)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 HashSet (java.util.HashSet)2 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)2 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)2 Identity (org.olat.core.id.Identity)2 CorruptedCourseException (org.olat.course.CorruptedCourseException)2 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupService (org.olat.group.BusinessGroupService)2 OLATResource (org.olat.resource.OLATResource)2