Skip to content

Commit

Permalink
SAK-46586 Show groups for each user in "Participants" tab on Roster2 …
Browse files Browse the repository at this point in the history
…"Export" (sakaiproject#10036)
  • Loading branch information
josecebe authored Nov 25, 2021
1 parent 3b0362d commit 341ef51
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ private Workbook getExportData(final String currentUserId, final RosterSite site
createSpreadsheetTitle(rosterRows, site, groupId, viewType);

final String siteID = site.getId();
List<String> header = createColumnHeader(viewType, siteID, false);
List<String> header = createColumnHeader(viewType, siteID, true);
List<RosterMember> rosterMembers = Collections.EMPTY_LIST;

if (VIEW_OVERVIEW.equals(viewType)) {

rosterMembers = getMembership(currentUserId, siteID, groupId, roleId);

if (CollectionUtils.isNotEmpty(rosterMembers)) {
addOverviewRows(rosterRows, rosterMembers, header, siteID);
addOverviewRows(rosterRows, rosterMembers, header, siteID, true);
}
} else if (VIEW_ENROLLMENT_STATUS.equals(viewType)) {

Expand Down Expand Up @@ -453,7 +453,7 @@ private List<RosterMember> getEnrolledMembership(final String currentUserId, fin
}

private void addOverviewRows(final List<List<String>> dataInRows,
final List<RosterMember> rosterMembers, final List<String> header, final String siteId) {
final List<RosterMember> rosterMembers, final List<String> header, final String siteId, final boolean isGroupsSheetHeader) {

final String userId = this.developerHelperService.getCurrentUserId();

Expand Down Expand Up @@ -486,6 +486,14 @@ private void addOverviewRows(final List<List<String>> dataInRows,

row.add(member.getRole());

if (isGroupsSheetHeader && this.sakaiProxy.hasUserSitePermission(userId, RosterFunctions.ROSTER_FUNCTION_VIEWGROUP, siteId)) {
List<String> groups = member.getGroups().entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.map(e -> e.getValue())
.collect(Collectors.toList());
row.add(String.join(",", groups));
}

dataInRows.add(row);
}
}
Expand Down

0 comments on commit 341ef51

Please sign in to comment.