Skip to content

Commit

Permalink
SAK-49150 Gradebook: TA not in group, but with permission to grade a …
Browse files Browse the repository at this point in the history
…group, cannot actually grade
  • Loading branch information
kunaljaykam committed May 11, 2024
1 parent 8dbbfc9 commit e8d9a02
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1795,21 +1795,17 @@ 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<>();

GbRole role;
try {
role = this.getUserRole(siteId);
} catch (final GbAccessDeniedException e) {
log.warn("Could not fetch the users role in site [{}], {}", siteId, e.toString());
return rval;
}

// 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);

final Collection<Group> groups = !perms.isEmpty() ? site.getGroups() : site.getGroupsWithMember(userDirectoryService.getCurrentUser().getId());

for (final Group group : groups) {
rval.add(new GbGroup(group.getId(), group.getTitle(), group.getReference(), GbGroup.Type.GROUP));
Expand All @@ -1820,6 +1816,13 @@ public List<GbGroup> getSiteSectionsAndGroups() {
log.error("Error retrieving groups", e);
}

GbRole role;
try {
role = this.getUserRole(siteId);
} catch (final GbAccessDeniedException e) {
log.warn("Could not fetch the users role in site [{}], {}", siteId, e.toString());
return rval;
}

// if user is a TA, get the groups they can see and filter the GbGroup
// list to keep just those
Expand Down

0 comments on commit e8d9a02

Please sign in to comment.