Skip to content

Commit

Permalink
SAK-49150 Gradebook TA not in group, but with permission to grade a g…
Browse files Browse the repository at this point in the history
…roup, cannot actually grade (#12589)
  • Loading branch information
kunaljaykam authored May 20, 2024
1 parent 2675302 commit 30c295a
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,7 @@ public List<GbStudentGradeInfo> sortGradeMatrix(Map<String, GbStudentGradeInfo>
*/
public List<GbGroup> getSiteSectionsAndGroups() {
final String siteId = getCurrentSiteId();
final String userId = getCurrentUser().getId();

final List<GbGroup> rval = new ArrayList<>();

Expand All @@ -1809,7 +1810,22 @@ public List<GbGroup> getSiteSectionsAndGroups() {
// get groups (handles both groups and sections)
try {
final Site site = this.siteService.getSite(siteId);
final Collection<Group> groups = isSuperUser() || role == GbRole.INSTRUCTOR ? site.getGroups() : site.getGroupsWithMember(userDirectoryService.getCurrentUser().getId());

final List<PermissionDefinition> perms = getPermissionsForUser(userId, siteId);

List<String> groupReferences = perms.stream().map(PermissionDefinition::getGroupReference).filter(Objects::nonNull).collect(Collectors.toList());

final Collection<Group> groups;

if (GbRole.INSTRUCTOR.equals(role)) {
groups = site.getGroups();
} else {
if (!groupReferences.isEmpty()) {
groups = site.getGroups().stream().filter(group -> groupReferences.contains(group.getReference())).collect(Collectors.toList());
} else {
groups = site.getGroupsWithMember(userDirectoryService.getCurrentUser().getId());
}
}

for (final Group group : groups) {
rval.add(new GbGroup(group.getId(), group.getTitle(), group.getReference(), GbGroup.Type.GROUP));
Expand Down

0 comments on commit 30c295a

Please sign in to comment.