Skip to content

Commit

Permalink
Merge pull request sakaiproject#2699 from steveswinsburg/bugfix/2698
Browse files Browse the repository at this point in the history
#2698 If TA has access to a 'group' and 'all', group filter is not sh…
  • Loading branch information
payten committed Jun 1, 2016
2 parents b25228d + c2cfd6e commit 180b4c0
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Map;
import java.util.Random;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.StopWatch;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -63,6 +64,7 @@
import org.sakaiproject.gradebookng.tool.panels.ToggleGradeItemsToolbarPanel;
import org.sakaiproject.service.gradebook.shared.Assignment;
import org.sakaiproject.service.gradebook.shared.CategoryDefinition;
import org.sakaiproject.service.gradebook.shared.GraderPermission;
import org.sakaiproject.service.gradebook.shared.PermissionDefinition;
import org.sakaiproject.service.gradebook.shared.SortType;
import org.sakaiproject.tool.gradebook.Gradebook;
Expand Down Expand Up @@ -95,6 +97,9 @@ public class GradebookPage extends BasePage {
Label liveGradingFeedback;

Form<Void> form;

List<PermissionDefinition> permissions = new ArrayList<>();
boolean showGroupFilter = true;

@SuppressWarnings({ "rawtypes", "unchecked", "serial" })
public GradebookPage() {
Expand All @@ -116,7 +121,7 @@ public GradebookPage() {
}

// no perms
List<PermissionDefinition> permissions = this.businessService.getPermissionsForUser(this.currentUserUuid);
permissions = this.businessService.getPermissionsForUser(this.currentUserUuid);
if(permissions.isEmpty()) {
PageParameters params = new PageParameters();
params.add("message", getString("ta.nopermission"));
Expand Down Expand Up @@ -564,7 +569,23 @@ public boolean isVisible() {

// if only one group, just show the title
// otherwise add the 'all groups' option
if (this.role == GbRole.TA && groups.size() == 1) {
// cater for the case where there is only one group visible to TA but they can see everyone.
if (this.role == GbRole.TA) {

//if only one group, hide the filter
if (groups.size() == 1) {
showGroupFilter = false;

// but need to double check permissions to see if we have any permissions with no group reference
permissions.forEach(p -> {
if (!StringUtils.equalsIgnoreCase(p.getFunction(),GraderPermission.VIEW_COURSE_GRADE.toString()) && StringUtils.isBlank(p.getGroupReference())) {
showGroupFilter = true;
}
});
}
}

if(!showGroupFilter) {
toolbar.add(new Label("groupFilterOnlyOne", Model.of(groups.get(0).getTitle())));
} else {
toolbar.add(new EmptyPanel("groupFilterOnlyOne").setVisible(false));
Expand All @@ -575,12 +596,11 @@ public boolean isVisible() {

// does the TA have any permissions set?
// we can assume that if they have any then there is probably some sort of group restriction so we can change the label
if (!this.businessService.getPermissionsForUser(this.currentUserUuid).isEmpty()) {
if (!this.permissions.isEmpty()) {
allGroupsTitle = getString("groups.available");
}
}
groups.add(0, new GbGroup(null, allGroupsTitle, null, GbGroup.Type.ALL));

}

final DropDownChoice<GbGroup> groupFilter = new DropDownChoice<GbGroup>("groupFilter", new Model<GbGroup>(),
Expand Down

0 comments on commit 180b4c0

Please sign in to comment.