Skip to content

Commit

Permalink
SAK-47987 grader. Add peer review information to submission
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish committed Oct 20, 2023
1 parent 2ea87c8 commit 180ad2e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.commons.fileupload.FileItem;

import org.sakaiproject.assignment.api.AssignmentConstants;
import org.sakaiproject.assignment.api.AssignmentPeerAssessmentService;
import org.sakaiproject.assignment.api.AssignmentReferenceReckoner;
import org.sakaiproject.assignment.api.AssignmentService;
import org.sakaiproject.assignment.api.ContentReviewResult;
Expand Down Expand Up @@ -74,6 +75,7 @@
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.timesheet.api.TimeSheetEntry;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.tool.api.ToolManager;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.lti.api.LTIService;
Expand All @@ -91,6 +93,7 @@ public class AssignmentEntityProvider extends AbstractEntityProvider implements

private static ResourceLoader rb = new ResourceLoader("assignment");

private AssignmentPeerAssessmentService assignmentPeerAssessmentService;
private AssignmentService assignmentService;
private AssignmentToolUtils assignmentToolUtils;
private ContentHostingService contentHostingService;
Expand All @@ -99,6 +102,7 @@ public class AssignmentEntityProvider extends AbstractEntityProvider implements
private SecurityService securityService;
private SessionManager sessionManager;
private SiteService siteService;
private ToolManager toolManager;
private AssignmentSupplementItemService assignmentSupplementItemService;
private GradingService gradingService;
private ServerConfigurationService serverConfigurationService;
Expand Down Expand Up @@ -763,6 +767,61 @@ private Map<String, Object> submissionToMap(Set<String> activeSubmitters, Assign
submission.put("previewableAttachments", previewableAttachments);
}
}

//peer review
if (assignment.getAllowPeerAssessment()
&& assignment.getPeerAssessmentStudentReview()
&& assignmentService.isPeerAssessmentClosed(assignment)) {
List<PeerAssessmentItem> reviews = assignmentPeerAssessmentService.getPeerAssessmentItems(as.getId(), assignment.getScaleFactor());
if (reviews != null) {
List<PeerAssessmentItem> completedReviews = new ArrayList<>();
for (PeerAssessmentItem review : reviews) {
if (!review.getRemoved() && (review.getScore() != null || (StringUtils.isNotBlank(review.getComment())))) {
//only show peer reviews that have either a score or a comment saved
if (assignment.getPeerAssessmentAnonEval()) {
//annonymous eval
review.setAssessorDisplayName(rb.getFormattedMessage("gen.reviewer.countReview", completedReviews.size() + 1));
} else {
//need to set the assessor's display name
try {
if (assignment.getIsGroup()) {
String siteId = toolManager.getCurrentPlacement().getContext();
Site site = siteService.getSite(siteId);
review.setAssessorDisplayName(site.getGroup(review.getId().getAssessorUserId()).getTitle());
} else {
review.setAssessorDisplayName(userDirectoryService.getUser(review.getId().getAssessorUserId()).getDisplayName());
}
} catch (IdUnusedException | UserNotDefinedException e) {
//reviewer doesn't exist or one of userId/groupId/siteId is wrong
log.error(e.getMessage(), e);
//set a default one:
review.setAssessorDisplayName(rb.getFormattedMessage("gen.reviewer.countReview", completedReviews.size() + 1));
}
}
// get attachments for peer review item
List<PeerAssessmentAttachment> attachments = assignmentPeerAssessmentService.getPeerAssessmentAttachments(review.getId().getSubmissionId(), review.getId().getAssessorUserId());
if (attachments != null && !attachments.isEmpty()) {
List<Reference> attachmentRefList = new ArrayList<>();
for (PeerAssessmentAttachment attachment : attachments) {
try {
Reference ref = entityManager.newReference(contentHostingService.getReference(attachment.getResourceId()));
attachmentRefList.add(ref);
} catch (Exception e) {
log.warn(e.getMessage(), e);
}
}
if (!attachmentRefList.isEmpty())
review.setAttachmentRefList(attachmentRefList);
}
completedReviews.add(review);
}
}
if (completedReviews.size() > 0) {
submission.put("peerReviews", completedReviews);
}
}
}

}

List<Map<String, Object>> submitters
Expand Down
1 change: 1 addition & 0 deletions assignment/tool/src/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<bean
parent="org.sakaiproject.entitybroker.entityprovider.AbstractEntityProvider"
class="org.sakaiproject.assignment.entityproviders.AssignmentEntityProvider">
<property name="assignmentPeerAssessmentService" ref="org.sakaiproject.assignment.api.AssignmentPeerAssessmentService" />
<property name="assignmentService" ref="org.sakaiproject.assignment.api.AssignmentService" />
<property name="assignmentToolUtils" ref="org.sakaiproject.assignment.tool.AssignmentToolUtils" />
<property name="contentHostingService" ref="org.sakaiproject.content.api.ContentHostingService" />
Expand Down
5 changes: 5 additions & 0 deletions webcomponents/bundle/src/main/bundle/grader.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
attachment=Attachment
done=Done
grade=Grade:
no_submission=No submission
no_submission_for=No submission for
peer_reviews=Peer Reviews
reviewer_comments=Reviewer Comments
reviewer_attachments=Reviewer Attachments
grading_rubric_tooltip=Grade this submission using a rubric
rubric=Rubric
add_feedback_tooltip=Write, or record, some feedback for this student
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,35 @@ export const graderRenderingMixin = Base => class extends Base {
</div>
` : ""}
`}
${this.gradable.allowPeerAssessment && this.submission.peerReviews?.length > 0 ? html`
<div class="mt-4">
<h3 class="mb-3">${this.i18n.peer_reviews}</h3>
${this.submission.peerReviews.map(pr => html`
<div class="card mb-2">
<div class="card-header fw-bold">${pr.assessorDisplayName}</div>
<div class="card-body">
<div class="card-text">
<div>
<span class="fw-bold me-2">${this.i18n.grade}</span>
<span>${pr.scoreDisplay}</span>
</div>
<div class="mt-2 mb-2 fw-bold">${this.i18n.reviewer_comments}</div>
<div>${unsafeHTML(pr.comment)}</div>
${pr.attachmentRefList && pr.attachmentRefList.length > 0 ? html`
<div class="fw-bold mb-2">${this.i18n.reviewer_attachments}</div>
${pr.attachmentRefList.map((ref, i) => html`
<div class="feedback-attachment">
<a href="/access${ref.reference}" title="${this.i18n.feedback_attachment_tooltip}">${this.i18n.attachment} ${i + 1}</a>
</div>
`)}
` : ""}
</div>
</div>
</div>
`)}
</div>
` : "" }
` : ""}
</div>
`;
Expand Down
2 changes: 2 additions & 0 deletions webcomponents/tool/src/main/frontend/js/grader/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Submission {
this.hasHistory = this.history.grades || this.history.comments;
}

this.peerReviews = init.peerReviews;

this.hasRubricEvaluation = init.hasRubricEvaluation;
this.showExtension = true;

Expand Down

0 comments on commit 180ad2e

Please sign in to comment.