use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method getLastCertificates.
@Override
public List<CertificateLight> getLastCertificates(BusinessGroup businessGroup) {
List<BusinessGroup> groups = Collections.singletonList(businessGroup);
List<RepositoryEntry> entries = businessGroupRelationDao.findRepositoryEntries(groups, 0, -1);
if (entries.isEmpty()) {
// no courses, no certificates
return new ArrayList<>();
}
List<Long> resourceKeys = new ArrayList<>(entries.size());
for (RepositoryEntry entry : entries) {
resourceKeys.add(entry.getOlatResource().getKey());
}
StringBuilder sb = new StringBuilder();
sb.append("select cer from certificatelight cer").append(" where cer.olatResourceKey in (:resourceKeys) and cer.last=true");
return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), CertificateLight.class).setParameter("resourceKeys", resourceKeys).getResultList();
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method getCertificatesForNotifications.
@Override
public List<Certificate> getCertificatesForNotifications(Identity identity, RepositoryEntry entry, Date lastNews) {
Roles roles = securityManager.getRoles(identity);
RepositoryEntrySecurity security = repositoryManager.isAllowed(identity, roles, entry);
if (!security.isEntryAdmin() && !security.isCourseCoach() && !security.isGroupCoach() && !security.isCourseParticipant() && !security.isGroupParticipant()) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select cer from certificate cer").append(" inner join fetch cer.identity ident").append(" where cer.olatResource.key=:resourceKey and cer.last=true ");
// must be some kind of restrictions
boolean securityCheck = false;
List<Long> baseGroupKeys = null;
if (!security.isEntryAdmin()) {
sb.append(" and (");
boolean or = false;
if (security.isCourseCoach()) {
or = or(sb, or);
sb.append(" exists (select membership.identity.key from repoentrytogroup as rel, bgroup as reBaseGroup, bgroupmember membership ").append(" where ident.key=membership.identity.key and rel.entry.key=:repoKey and rel.group=reBaseGroup and membership.group=reBaseGroup and membership.role='").append(GroupRole.participant).append("'").append(" )");
securityCheck = true;
}
if (security.isGroupCoach()) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, false);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
if (groups.size() > 0) {
or = or(sb, or);
sb.append(" exists (select membership.identity.key from bgroupmember membership ").append(" where ident.key=membership.identity.key and membership.group.key in (:groups) and membership.role='").append(GroupRole.participant).append("'").append(" )");
baseGroupKeys = new ArrayList<>(groups.size());
for (BusinessGroup group : groups) {
baseGroupKeys.add(group.getBaseGroup().getKey());
}
securityCheck = true;
}
}
if (security.isCourseParticipant() || security.isGroupParticipant()) {
or = or(sb, or);
sb.append(" ident.key=:identityKey");
securityCheck = true;
}
sb.append(")");
} else {
securityCheck = true;
}
if (!securityCheck) {
return Collections.emptyList();
}
sb.append(" order by cer.creationDate");
TypedQuery<Certificate> certificates = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Certificate.class).setParameter("resourceKey", entry.getOlatResource().getKey());
if (!security.isEntryAdmin()) {
if (security.isCourseCoach()) {
certificates.setParameter("repoKey", entry.getKey());
}
if (security.isCourseParticipant() || security.isGroupParticipant()) {
certificates.setParameter("identityKey", identity.getKey());
}
}
if (baseGroupKeys != null && !baseGroupKeys.isEmpty()) {
certificates.setParameter("groups", baseGroupKeys);
}
return certificates.getResultList();
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class IdentityListCourseNodeController method fillAlternativeToAssessableIdentityList.
private void fillAlternativeToAssessableIdentityList(AssessmentToolOptions options, SearchAssessedIdentityParams params) {
List<Group> baseGroups = new ArrayList<>();
if ((assessmentCallback.canAssessRepositoryEntryMembers() && (assessmentCallback.getCoachedGroups() == null || assessmentCallback.getCoachedGroups().isEmpty())) || assessmentCallback.canAssessNonMembers()) {
baseGroups.add(repositoryService.getDefaultGroup(courseEntry));
}
if (assessmentCallback.getCoachedGroups() != null && assessmentCallback.getCoachedGroups().size() > 0) {
for (BusinessGroup coachedGroup : assessmentCallback.getCoachedGroups()) {
baseGroups.add(coachedGroup.getBaseGroup());
}
}
options.setGroups(baseGroups);
options.setNonMembers(params.isNonMembers());
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class AssessedBusinessGroupCourseNodeListController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
String resName = entries.get(0).getOLATResourceable().getResourceableTypeName();
if ("BusinessGroup".equalsIgnoreCase(resName) || "Group".equalsIgnoreCase(resName)) {
Long groupKey = entries.get(0).getOLATResourceable().getResourceableId();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(groupKey);
List<ContextEntry> subEntries = entries.subList(1, entries.size());
doSelect(ureq, businessGroup).activate(ureq, subEntries, entries.get(0).getTransientState());
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class AssessmentCourseTreeController method doSelectCourseNodeBusinessGroupsView.
private Controller doSelectCourseNodeBusinessGroupsView(UserRequest ureq, CourseNode courseNode) {
OLATResourceable oresGroups = OresHelper.createOLATResourceableInstance("BusinessGroups", 0l);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresGroups, null, getWindowControl());
OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("Node", new Long(courseNode.getIdent()));
WindowControl bbwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresNode, null, bwControl);
if (courseNode instanceof AssessableCourseNode && ((AssessableCourseNode) courseNode).isAssessedBusinessGroups()) {
if (courseNode instanceof GTACourseNode) {
CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
List<BusinessGroup> coachedGroups;
if (assessmentCallback.isAdmin()) {
coachedGroups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
} else {
coachedGroups = assessmentCallback.getCoachedGroups();
}
businessGroupListCtrl = ((GTACourseNode) courseNode).getCoachedGroupListController(ureq, bbwControl, stackPanel, coachCourseEnv, assessmentCallback.isAdmin(), coachedGroups);
}
} else {
businessGroupListCtrl = new AssessedBusinessGroupCourseNodeListController(ureq, bbwControl, stackPanel, courseEntry, courseNode, coachCourseEnv, toolContainer, assessmentCallback);
}
return businessGroupListCtrl;
}
Aggregations