Skip to content

Commit

Permalink
LSNBLDR-725; handle the "all groups" option (sakaiproject#3901)
Browse files Browse the repository at this point in the history
  • Loading branch information
clhedrick authored Feb 10, 2017
1 parent 94edbc7 commit 943eb7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,26 @@ public Set<String> getMyGroups() {
return ret;
}

// get actual groups that should submit to this student content item
// only called if the item has groups. If there are specified groups
// use them, otherwise get all groups
public Set<String> getOwnerGroups(SimplePageItem item) {
Set<String> ret = new HashSet<String>();
String ownerGroups = item.getOwnerGroups();
if (ownerGroups == null || ownerGroups.equals("")) {
List<GroupEntry> groupEntries = getCurrentGroups();
for (GroupEntry entry: groupEntries)
ret.add(entry.id);
} else {
String [] groups = ownerGroups.split(",");
for (String group: groups) {
if (group != null && !group.equals(""))
ret.add(group);
}
}
return ret;
}

// sort the list, since it will typically be presented
// to the user. This skips our access groups
public List<GroupEntry> getCurrentGroups() {
Expand Down Expand Up @@ -7415,8 +7435,14 @@ public String updateStudent() {
page.setOwnerGroups("");
else {
StringBuilder ownerGroups = new StringBuilder();
boolean first = true;
for (int i = 0; i < studentSelectedGroups.length; i++) {
if (i > 0)
// ignore groups that don't exist or aren't in this site
if (getCurrentSite().getGroup(studentSelectedGroups[i]) == null)
continue;
if (first)
first = false;
else
ownerGroups.append(",");
ownerGroups.append(studentSelectedGroups[i]);
}
Expand Down Expand Up @@ -7550,9 +7576,7 @@ public String missingStudentSetZero() {
// initialize notsubmitted to all userids or groupids
Set<String> notSubmitted = new HashSet<String>();
if (item.isGroupOwned()) {
String ownerGroups = item.getOwnerGroups();
if (ownerGroups != null)
notSubmitted = new HashSet(Arrays.asList(ownerGroups.split(",")));
notSubmitted = getOwnerGroups(item);
} else {
Set<Member> members = new HashSet<Member>();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2538,9 +2538,7 @@ public int compare(Target o1, Target o2) {
// should submit and remove as we see them
Set<String> notSubmitted = new HashSet<String>();
if (i.isGroupOwned()) {
String ownerGroups = i.getOwnerGroups();
if (ownerGroups != null)
notSubmitted = new HashSet(Arrays.asList(ownerGroups.split(",")));
notSubmitted = simplePageBean.getOwnerGroups(i);
} else {
String siteRef = simplePageBean.getCurrentSite().getReference();
// only check students
Expand Down

0 comments on commit 943eb7b

Please sign in to comment.