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;
}
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())));
}
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());
}
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;
}
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);
}
Aggregations