Search in sources :

Example 11 with CourseGroupManager

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

the class CourseCalendars method getCourseCalendarWrapper.

/**
 * Return only the course calendar without any group calendar
 * @param ureq
 * @param wControl
 * @param ores
 * @param ne
 * @return
 */
public static KalendarRenderWrapper getCourseCalendarWrapper(UserRequest ureq, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    // add course calendar
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
    KalendarRenderWrapper courseKalendarWrapper = calendarManager.getCourseCalendar(course);
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    Identity identity = ureq.getIdentity();
    Roles roles = ureq.getUserSession().getRoles();
    boolean isPrivileged = !courseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || courseEnv.isAdmin() || (ne != null && ne.isCapabilityAccessible(CalCourseNode.EDIT_CONDITION_ID)) || RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, cgm.getCourseEntry()));
    if (isPrivileged) {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        courseKalendarWrapper.setPrivateEventsVisible(true);
    } else {
        courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        courseKalendarWrapper.setPrivateEventsVisible(courseEnv.isAdmin() || courseEnv.isCoach() || courseEnv.isParticipant());
    }
    CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), ureq.getIdentity());
    if (config != null) {
        courseKalendarWrapper.setConfiguration(config);
    }
    return courseKalendarWrapper;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CalendarManager(org.olat.commons.calendar.CalendarManager) 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) Identity(org.olat.core.id.Identity)

Example 12 with CourseGroupManager

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

the class ProjectGroupManagerImpl method createProjectGroupFor.

// //////////////////////////
// PROJECT GROUP MANAGEMENT
// //////////////////////////
@Override
public BusinessGroup createProjectGroupFor(Long projectBrokerId, Identity identity, String groupName, String groupDescription, Long courseId) {
    CourseGroupManager cgm = CourseFactory.loadCourse(courseId).getCourseEnvironment().getCourseGroupManager();
    RepositoryEntry re = cgm.getCourseEntry();
    log.debug("createProjectGroupFor groupName=" + groupName);
    BusinessGroup projectGroup = businessGroupService.createBusinessGroup(identity, groupName, groupDescription, -1, -1, false, false, re);
    // projectGroup could be null when a group with name already exists
    int counter = 2;
    while (projectGroup == null) {
        // name already exist try another one
        String newGroupName = groupName + " _" + counter;
        projectGroup = businessGroupService.createBusinessGroup(identity, newGroupName, groupDescription, -1, -1, false, false, re);
        counter++;
    }
    log.debug("Created a new projectGroup=" + projectGroup);
    return projectGroup;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 13 with CourseGroupManager

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

the class CourseRuntimeController method loadRights.

@Override
protected void loadRights(RepositoryEntrySecurity security) {
    super.loadRights(security);
    if (corrupted)
        return;
    ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    // 3) all other rights are defined in the groupmanagement using the learning
    // group rights
    UserCourseEnvironmentImpl uce = getUserCourseEnvironment();
    if (uce != null) {
        uce.setUserRoles(security.isEntryAdmin(), security.isCourseCoach() || security.isGroupCoach(), security.isCourseParticipant() || security.isGroupParticipant());
        if (security.isReadOnly()) {
            if (overrideReadOnly) {
                uce.setCourseReadOnly(Boolean.FALSE);
            } else {
                uce.setCourseReadOnly(Boolean.TRUE);
            }
        } else {
            uce.setCourseReadOnly(Boolean.FALSE);
        }
    }
    courseRightsCache = new HashMap<>();
    if (!security.isEntryAdmin() && !isGuestOnly) {
        List<String> rights = cgm.getRights(getIdentity());
        courseRightsCache.put(CourseRights.RIGHT_GROUPMANAGEMENT, Boolean.valueOf(rights.contains(CourseRights.RIGHT_GROUPMANAGEMENT)));
        courseRightsCache.put(CourseRights.RIGHT_MEMBERMANAGEMENT, Boolean.valueOf(rights.contains(CourseRights.RIGHT_MEMBERMANAGEMENT)));
        courseRightsCache.put(CourseRights.RIGHT_COURSEEDITOR, Boolean.valueOf(rights.contains(CourseRights.RIGHT_COURSEEDITOR)));
        courseRightsCache.put(CourseRights.RIGHT_ARCHIVING, Boolean.valueOf(rights.contains(CourseRights.RIGHT_ARCHIVING)));
        courseRightsCache.put(CourseRights.RIGHT_ASSESSMENT, Boolean.valueOf(rights.contains(CourseRights.RIGHT_ASSESSMENT)));
        courseRightsCache.put(CourseRights.RIGHT_ASSESSMENT_MODE, Boolean.valueOf(rights.contains(CourseRights.RIGHT_ASSESSMENT_MODE)));
        courseRightsCache.put(CourseRights.RIGHT_GLOSSARY, Boolean.valueOf(rights.contains(CourseRights.RIGHT_GLOSSARY)));
        courseRightsCache.put(CourseRights.RIGHT_STATISTICS, Boolean.valueOf(rights.contains(CourseRights.RIGHT_STATISTICS)));
        courseRightsCache.put(CourseRights.RIGHT_DB, Boolean.valueOf(rights.contains(CourseRights.RIGHT_DB)));
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) ICourse(org.olat.course.ICourse)

Example 14 with CourseGroupManager

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

the class CourseHandler method copy.

@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
    final OLATResource sourceResource = source.getOlatResource();
    final OLATResource targetResource = target.getOlatResource();
    CourseFactory.copyCourse(sourceResource, targetResource);
    // transaction copied
    ICourse sourceCourse = CourseFactory.loadCourse(source);
    CourseGroupManager sourceCgm = sourceCourse.getCourseEnvironment().getCourseGroupManager();
    CourseEnvironmentMapper env = PersistingCourseGroupManager.getInstance(sourceResource).getBusinessGroupEnvironment();
    File fExportDir = new File(WebappHelper.getTmpDir(), UUID.randomUUID().toString());
    fExportDir.mkdirs();
    sourceCgm.exportCourseBusinessGroups(fExportDir, env, false, false);
    ICourse course = CourseFactory.loadCourse(target);
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    // import groups
    CourseEnvironmentMapper envMapper = cgm.importCourseBusinessGroups(fExportDir);
    envMapper.setAuthor(author);
    // upgrade to the current version of the course
    course = CourseFactory.loadCourse(cgm.getCourseResource());
    course.postCopy(envMapper, sourceCourse);
    cloneReminders(author, envMapper, source, target);
    cloneLectureConfig(source, target);
    return target;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) File(java.io.File) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper)

Example 15 with CourseGroupManager

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

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)

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