Skip to content

Commit

Permalink
Merge pull request sakaiproject#65 from juanjmerono/SAK-28055
Browse files Browse the repository at this point in the history
SAK-28055 In assignment with submission for groups the assign grade
  • Loading branch information
ottenhoff committed Jan 21, 2015
2 parents f08dc53 + 83a2f5f commit 4d1d1c7
Showing 1 changed file with 21 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4731,9 +4731,16 @@ public Map<User, AssignmentSubmission> getSubmitterMap(String searchFilterOnly,
{
List allowAddSubmissionUsers = allowAddSubmissionUsers(aRef);

List allowAddAssignmentUsers = allowAddAssignmentUsers(contextString);
// SAK-25555 need to take away those users who can add assignment
allowAddSubmissionUsers.removeAll(allowAddAssignmentUsers);
// SAK-28055 need to take away those users who have the permissions defined in sakai.properties
String resourceString = getContextReference(a.getContext());
String[] permissions = m_serverConfigurationService.getStrings("assignment.submitter.remove.permission");
if (permissions!=null) {
for (String permission:permissions) {
allowAddSubmissionUsers.removeAll(securityService.unlockUsers(permission, resourceString));
}
} else {
allowAddSubmissionUsers.removeAll(securityService.unlockUsers(SECURE_ADD_ASSIGNMENT, resourceString));
}

// Step 1: get group if any that is selected
rvUsers = getSelectedGroupUsers(allOrOneGroup, contextString, a, allowAddSubmissionUsers);
Expand Down Expand Up @@ -11536,46 +11543,17 @@ public String getGradeForUser(String id) {
* @return Array of User objects.
*/
public User[] getSubmitters() {
List retVal = new ArrayList();
Assignment a = getAssignment();
if (a.isGroup()) {
try {
Site site = SiteService.getSite(a.getContext());
Group _g = site.getGroup(m_submitterId);
if (_g != null) {
Iterator<Member> _members = _g.getMembers().iterator();
while (_members.hasNext()) {
Member _member = _members.next();
try
{
retVal.add(UserDirectoryService.getUser(_member.getUserId()));
}
catch (Exception e)
{
M_log.warn(" BaseAssignmentSubmission Group getSubmitters" + e.getMessage() + _member.getUserId());
}
}
}
} catch (IdUnusedException _iue) {
throw new IllegalStateException("Site ("+a.getContext()+") not found: "+_iue, _iue);
}
} else {
for (int x = 0; x < m_submitters.size(); x++)
{
String userId = (String) m_submitters.get(x);
try
{
List<User> retVal = new ArrayList();
for (String userId:(List<String>) getSubmitterIds()) {
try {
retVal.add(UserDirectoryService.getUser(userId));
}
catch (Exception e)
{
} catch (Exception e) {
M_log.warn(" BaseAssignmentSubmission getSubmitters" + e.getMessage() + userId);
}
}
}
// compare users on sortname
java.util.Collections.sort(retVal, new UserComparator());

// compare users on sortname
java.util.Collections.sort(retVal, new UserComparator());

// get the User[] array
int size = retVal.size();
User[] rv = new User[size];
Expand All @@ -11596,19 +11574,11 @@ public List getSubmitterIds()
{
Assignment a = getAssignment();
if (a.isGroup()) {
List retVal = new ArrayList();
try {
Site site = SiteService.getSite(a.getContext());
try {
Site site = SiteService.getSite(a.getContext());
Group _g = site.getGroup(m_submitterId);
if (_g != null) {
Iterator<Member> _members = _g.getMembers().iterator();
while (_members.hasNext()) {
Member _member = _members.next();
retVal.add(_member.getUserId());
}
}
return retVal;
} catch (IdUnusedException _iue) {
return getSubmitterIdList("false", _g.getId(), null, a.getReference(), a.getContext());
} catch (IdUnusedException _iue) {
return null;
}
} else {
Expand Down

0 comments on commit 4d1d1c7

Please sign in to comment.