Skip to content
Snippets Groups Projects
Commit c7d3bb0f authored by srosse's avatar srosse
Browse files

OO-3955: add filter for curriculum elements in participant folder

parent 92548161
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,8 @@ import org.olat.course.run.environment.CourseEnvironment;
import org.olat.course.run.userview.UserCourseEnvironment;
import org.olat.group.BusinessGroupRef;
import org.olat.group.manager.BusinessGroupRelationDAO;
import org.olat.modules.curriculum.CurriculumElementRef;
import org.olat.modules.curriculum.manager.CurriculumElementDAO;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryRelationType;
import org.olat.repository.manager.RepositoryEntryRelationDAO;
......@@ -93,6 +95,8 @@ public class PFManager {
@Autowired
private UserManager userManager;
@Autowired
private CurriculumElementDAO curriculumElementDao;
@Autowired
private BusinessGroupRelationDAO businessGroupRelationDao;
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
......@@ -556,10 +560,15 @@ public class PFManager {
return getParticipants(pfNode, userPropertyHandlers, locale, identityList, courseEnv);
}
public List<DropBoxRow> getParticipants(List<BusinessGroupRef> businessGroupRefs, PFCourseNode pfNode, List<UserPropertyHandler> userPropertyHandlers,
public List<DropBoxRow> getParticipants(List<BusinessGroupRef> businessGroupRefs, List<CurriculumElementRef> curriculumElements,
PFCourseNode pfNode, List<UserPropertyHandler> userPropertyHandlers,
Locale locale, CourseEnvironment courseEnv) {
List<Identity> allIdentities = new ArrayList<>(32);
List<Identity> identityList = businessGroupRelationDao.getMembers(businessGroupRefs, GroupRoles.participant.name());
return getParticipants(pfNode, userPropertyHandlers, locale, identityList, courseEnv);
allIdentities.addAll(identityList);
List<Identity> identityElementList = curriculumElementDao.getMembers(curriculumElements, GroupRoles.participant.name());
allIdentities.addAll(identityElementList);
return getParticipants(pfNode, userPropertyHandlers, locale, allIdentities, courseEnv);
}
private List<DropBoxRow> getParticipants(PFCourseNode pfNode, List<UserPropertyHandler> userPropertyHandlers,
......
......@@ -68,10 +68,12 @@ import org.olat.course.nodes.pf.manager.PFView;
import org.olat.course.nodes.pf.ui.DropBoxTableModel.DropBoxCols;
import org.olat.course.run.environment.CourseEnvironment;
import org.olat.course.run.userview.UserCourseEnvironment;
import org.olat.course.run.userview.UserCourseEnvironmentImpl;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupRef;
import org.olat.group.model.BusinessGroupRefImpl;
import org.olat.modules.curriculum.CurriculumElement;
import org.olat.modules.curriculum.CurriculumElementRef;
import org.olat.modules.curriculum.model.CurriculumElementRefImpl;
import org.olat.resource.OLATResource;
import org.olat.user.HomePageConfig;
import org.olat.user.HomePageDisplayController;
......@@ -89,6 +91,8 @@ public class PFCoachController extends FormBasicController implements Controller
protected static final String USER_PROPS_ID = PFCoachController.class.getCanonicalName();
protected static final int USER_PROPS_OFFSET = 500;
private static final String CURRICULUM_EL_PREFIX = "curriculumelement-";
private static final String BUSINESS_GROUP_PREFIX = "businessgroup-";
private PFCourseNode pfNode;
......@@ -293,26 +297,35 @@ public class PFCoachController extends FormBasicController implements Controller
}
private void initFilters() {
List<FlexiTableFilter> groupFilters = new ArrayList<>();
List<FlexiTableFilter> filters = new ArrayList<>();
List<BusinessGroup> coachedGroups = userCourseEnv.isAdmin()
? courseEnv.getCourseGroupManager().getAllBusinessGroups() : userCourseEnv.getCoachedGroups();
List<CurriculumElement> coachedElements = userCourseEnv.isAdmin()
? courseEnv.getCourseGroupManager().getAllCurriculumElements() : userCourseEnv.getCoachedCurriculumElements();
List<BusinessGroup> coachedGroups = null;
if(userCourseEnv.isAdmin()) {
coachedGroups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
} else if(userCourseEnv instanceof UserCourseEnvironmentImpl) {
UserCourseEnvironmentImpl uce = (UserCourseEnvironmentImpl)userCourseEnv;
coachedGroups = uce.getCoachedGroups();
}
if(coachedGroups != null) {
for(BusinessGroup coachedGroup:coachedGroups) {
String groupName = StringHelper.escapeHtml(coachedGroup.getName());
groupFilters.add(new FlexiTableFilter(groupName, coachedGroup.getKey().toString(), "o_icon o_icon_group"));
filters.add(new FlexiTableFilter(groupName, BUSINESS_GROUP_PREFIX.concat(coachedGroup.getKey().toString()), "o_icon o_icon_group"));
}
}
if(!coachedElements.isEmpty()) {
if(!filters.isEmpty()) {
filters.add(FlexiTableFilter.SPACER);
}
for(CurriculumElement coachedElement: coachedElements) {
String groupName = StringHelper.escapeHtml(coachedElement.getDisplayName());
filters.add(new FlexiTableFilter(groupName, CURRICULUM_EL_PREFIX.concat(coachedElement.getKey().toString()), "o_icon o_icon_curriculum_element"));
}
}
if(!groupFilters.isEmpty()) {
groupFilters.add(FlexiTableFilter.SPACER);
groupFilters.add(new FlexiTableFilter(translate("show.all"), "", true));
dropboxTable.setExtendedFilterButton(translate("filter.groups"), groupFilters);
if(!filters.isEmpty()) {
filters.add(FlexiTableFilter.SPACER);
filters.add(new FlexiTableFilter(translate("show.all"), "", true));
dropboxTable.setExtendedFilterButton(translate("filter.groups"), filters);
}
}
......@@ -323,12 +336,18 @@ public class PFCoachController extends FormBasicController implements Controller
rows = pfManager.getParticipants(getIdentity(), pfNode, userPropertyHandlers, getLocale(), courseEnv, userCourseEnv.isAdmin());
} else {
List<BusinessGroupRef> businessGroups = new ArrayList<>(extendedFilters.size());
List<CurriculumElementRef> curriculumElements = new ArrayList<>(extendedFilters.size());
for(FlexiTableFilter extendedFilter:extendedFilters) {
if(StringHelper.isLong(extendedFilter.getFilter())) {
businessGroups.add(new BusinessGroupRefImpl(Long.parseLong(extendedFilter.getFilter())));
String filter = extendedFilter.getFilter();
if(filter.startsWith(BUSINESS_GROUP_PREFIX)) {
String key = filter.substring(BUSINESS_GROUP_PREFIX.length(), filter.length());
businessGroups.add(new BusinessGroupRefImpl(Long.valueOf(key)));
} else if(filter.startsWith(CURRICULUM_EL_PREFIX)) {
String key = filter.substring(CURRICULUM_EL_PREFIX.length(), filter.length());
curriculumElements.add(new CurriculumElementRefImpl(Long.valueOf(key)));
}
}
rows = pfManager.getParticipants(businessGroups, pfNode, userPropertyHandlers, getLocale(), courseEnv);
rows = pfManager.getParticipants(businessGroups, curriculumElements, pfNode, userPropertyHandlers, getLocale(), courseEnv);
}
tableModel.setObjects(rows);
......
......@@ -321,7 +321,7 @@ public class BusinessGroupRelationDAO {
}
public List<Identity> getMembers(List<? extends BusinessGroupRef> groups, String... roles) {
if(groups == null || groups.isEmpty()) return Collections.emptyList();
if(groups == null || groups.isEmpty()) return new ArrayList<>();
StringBuilder sb = new StringBuilder();
sb.append("select ident from businessgroup as bgroup ")
......@@ -345,7 +345,7 @@ public class BusinessGroupRelationDAO {
}
public List<Long> getMemberKeys(List<? extends BusinessGroupRef> groups, String... roles) {
if(groups == null || groups.isEmpty()) return Collections.emptyList();
if(groups == null || groups.isEmpty()) return new ArrayList<>();
StringBuilder sb = new StringBuilder();
sb.append("select membership.identity.key from businessgroup as bgroup ")
......
......@@ -765,6 +765,27 @@ public class CurriculumElementDAO {
.getResultList();
}
public List<Identity> getMembers(List<CurriculumElementRef> elements, String... roles) {
if(elements == null || elements.isEmpty()) return new ArrayList<>();
List<Long> elementKeys = elements.stream()
.map(CurriculumElementRef::getKey).collect(Collectors.toList());
List<String> roleList = CurriculumRoles.toList(roles);
StringBuilder sb = new StringBuilder(256);
sb.append("select ident from curriculumelement el")
.append(" inner join el.group baseGroup")
.append(" inner join baseGroup.members membership")
.append(" inner join membership.identity ident")
.append(" inner join fetch ident.user identUser")
.append(" where el.key in (:elementKeys) and membership.role in (:roles)");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Identity.class)
.setParameter("elementKeys", elementKeys)
.setParameter("roles", roleList)
.getResultList();
}
public List<CurriculumElementMembership> getMembershipInfos(List<CurriculumRef> curriculums, Collection<CurriculumElement> elements, Identity... identities) {
StringBuilder sb = new StringBuilder(256);
sb.append("select el.key, membership from curriculumelement el")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment