use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
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);
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class AssessmentNotificationsHandler method canSubscribeForAssessmentNotification.
/**
* Assessment notification rights check.<br>
* Tests if an <code>Identity</code> can subscribe for assessment
* notification for the specified <code>ICourse</code>.<br>
* <br>
* <b>PRE CONDITIONS</b>
* <ul>
* <li> <code>course != null</code>
* </ul>
*
* @param ident the identity to check rights for. Can be <code>null</code>
* @param course the course to check rights against
* @return if <code>ident == null</code> this method always returns false;
* otherwise subscriptions rights are met only by course
* administrators and course coaches
*/
private boolean canSubscribeForAssessmentNotification(Identity ident, ICourse course) {
if (ident == null)
return false;
CourseGroupManager grpMan = course.getCourseEnvironment().getCourseGroupManager();
boolean isInstitutionalResourceManager = securityManager.isIdentityInSecurityGroup(ident, securityManager.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER));
return isInstitutionalResourceManager || grpMan.isIdentityCourseAdministrator(ident) || grpMan.isIdentityCourseCoach(ident) || grpMan.hasRight(ident, CourseRights.RIGHT_ASSESSMENT);
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class AssessmentModeEditController method doChooseGroups.
private void doChooseGroups(UserRequest ureq) {
if (groupChooseCtrl != null)
return;
ICourse course = CourseFactory.loadCourse(courseOres);
CourseGroupManager groupManager = course.getCourseEnvironment().getCourseGroupManager();
groupChooseCtrl = new GroupSelectionController(ureq, getWindowControl(), true, groupManager, groupKeys);
listenTo(groupChooseCtrl);
cmc = new CloseableModalController(getWindowControl(), null, groupChooseCtrl.getInitialComponent(), true, translate("popup.choosegroups"), false);
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
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;
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class GTACoachedParticipantListController method collectIdentities.
private void collectIdentities(Consumer<Identity> participantCollector) {
Set<Identity> duplicateKiller = new HashSet<>();
CourseGroupManager cgm = coachCourseEnv.getCourseEnvironment().getCourseGroupManager();
boolean admin = coachCourseEnv.isAdmin();
List<BusinessGroup> coachedGroups = admin ? cgm.getAllBusinessGroups() : coachCourseEnv.getCoachedGroups();
List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
participantCollector.accept(participant);
duplicateKiller.add(participant);
}
}
RepositoryEntry re = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
boolean repoTutor = admin || (coachedGroups.isEmpty() && repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name()));
if (repoTutor) {
List<Identity> courseParticipants = repositoryService.getMembers(re, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
participantCollector.accept(participant);
duplicateKiller.add(participant);
}
}
}
}
Aggregations