|
20 | 20 | import java.util.Arrays;
|
21 | 21 | import java.util.List;
|
22 | 22 | import java.util.Map;
|
| 23 | +import java.util.Optional; |
23 | 24 |
|
24 | 25 | import org.apache.commons.lang3.StringUtils;
|
25 | 26 | import org.apache.wicket.AttributeModifier;
|
|
37 | 38 | import org.apache.wicket.model.IModel;
|
38 | 39 | import org.apache.wicket.model.Model;
|
39 | 40 | import org.apache.wicket.model.StringResourceModel;
|
| 41 | + |
| 42 | +import org.sakaiproject.authz.api.AuthzGroup; |
| 43 | +import org.sakaiproject.authz.api.GroupNotDefinedException; |
40 | 44 | import org.sakaiproject.gradebookng.business.GbRole;
|
41 | 45 | import org.sakaiproject.gradebookng.business.model.GbGradeInfo;
|
42 | 46 | import org.sakaiproject.gradebookng.business.util.FormatHelper;
|
@@ -382,7 +386,31 @@ public boolean isVisible() {
|
382 | 386 | String[] bits = assignment.getExternalId().split("/");
|
383 | 387 | if (bits != null && bits.length >= 1) {
|
384 | 388 | String assignmentId = bits[bits.length-1];
|
385 |
| - String submissionId = rubricsService.getRubricEvaluationObjectId(assignmentId, studentUuid, RubricsConstants.RBCS_TOOL_ASSIGNMENT); |
| 389 | + String ownerId = studentUuid; |
| 390 | + try { |
| 391 | + org.sakaiproject.assignment.api.model.Assignment assignmentsAssignment = assignmentService.getAssignment(assignmentId); |
| 392 | + if (assignmentsAssignment.getIsGroup()) { |
| 393 | + Optional<String> groupId = assignmentsAssignment.getGroups().stream().filter(g -> { |
| 394 | + |
| 395 | + try { |
| 396 | + AuthzGroup group = authzGroupService.getAuthzGroup(g); |
| 397 | + return group.getMember(studentUuid) != null; |
| 398 | + } catch (GroupNotDefinedException gnde) { |
| 399 | + return false; |
| 400 | + } |
| 401 | + }).findAny(); |
| 402 | + |
| 403 | + if (groupId.isPresent()) { |
| 404 | + ownerId = groupId.get(); |
| 405 | + } else { |
| 406 | + log.error("Assignment {} is a group assignment, but {} was not in any of the groups", assignmentId, studentUuid); |
| 407 | + } |
| 408 | + } |
| 409 | + } catch (Exception e) { |
| 410 | + log.error("Failed to determine ownerId for submission", e); |
| 411 | + } |
| 412 | + |
| 413 | + String submissionId = rubricsService.getRubricEvaluationObjectId(assignmentId, ownerId, RubricsConstants.RBCS_TOOL_ASSIGNMENT); |
386 | 414 | sakaiRubricButton.add(AttributeModifier.append("entity-id", assignmentId));
|
387 | 415 | sakaiRubricButton.add(AttributeModifier.append("evaluated-item-id", submissionId));
|
388 | 416 | } else {
|
|
0 commit comments