Skip to content

Commit

Permalink
SAK-40851 Assignments: Allow Students to use Rubrics for the Peer
Browse files Browse the repository at this point in the history
SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer


SAK-40851 Assignments: Allow Students to use Rubrics for the Peer
  • Loading branch information
MRutea committed Nov 27, 2020
1 parent e3af228 commit 5451956
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 37 deletions.
5 changes: 5 additions & 0 deletions assignment/api/src/resources/assignment.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,13 @@ associate.label=Use the following rubric to grade this assignment
option.pointsoverride=Adjust individual student scores
option.hidepoints=Hide point values (feedback only)
option.studentpreview=Hide Rubric from student
option.selfreport=Allow students to self-report their work
grading_rubric=Grading Rubric
asn.list.userubric=This assignment could be graded using a Rubric
youmustrubric=This is a self-report assignment. You must use the following rubric to grade your work before submitting
studentrubric=This is a self-report assignment. You can check the self-report of submitter before grading.
reviewrubric=This is a self-report assignment. You can check your self-report before grading.
peerrubric=Before grading the student, you can check the peer gradings above.
rubrics.use=Use rubric

# table toolbar common messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
import org.sakaiproject.exception.ServerOverloadException;
import org.sakaiproject.javax.PagingPosition;
import org.sakaiproject.message.api.MessageHeader;
import org.sakaiproject.rubrics.logic.model.ToolItemRubricAssociation;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.rubrics.logic.RubricsService;
import org.sakaiproject.scoringservice.api.ScoringAgent;
Expand Down Expand Up @@ -1056,6 +1057,10 @@ public class AssignmentAction extends PagedResourceActionII {
* Site property for forcing anonymous grading in a site
*/
private static final String SAK_PROP_FORCE_ANON_GRADING = "assignment.anon.grading.forced";
/**
* submitter, the student who do a selfreport
*/
private static final String STUDENT_WITH_SELFREPORT = "submitter";

private static final String FLAG_ON = "on";
private static final String FLAG_TRUE = "true";
Expand Down Expand Up @@ -1761,6 +1766,8 @@ private String build_student_view_submission_context(VelocityPortlet portlet, Co
canViewAssignmentIntoContext(context, assignment, s);

addAdditionalNotesToContext(submitter, context, state);

assignmentToolUtils.hasRubricSelfReview(context, assignment.getId());
}

if (taggingManager.isTaggable() && assignment != null) {
Expand Down Expand Up @@ -2284,6 +2291,14 @@ protected String build_student_confirm_submission_context(VelocityPortlet portle
}
}

User submitter = (User) state.getAttribute("student");
if (submitter == null) {
submitter = user;
}
context.put(STUDENT_WITH_SELFREPORT, submitter);

assignmentToolUtils.hasRubricSelfReview(context, assignment.getId());

context.put("text", state.getAttribute(PREVIEW_SUBMISSION_TEXT));
Map<String, Reference> submissionAttachmentReferences = new HashMap<>();
stripInvisibleAttachments(state.getAttribute(PREVIEW_SUBMISSION_ATTACHMENTS)).forEach(r -> submissionAttachmentReferences.put(r.getId(), r));
Expand Down Expand Up @@ -2543,6 +2558,14 @@ protected String build_student_view_grade_context(VelocityPortlet portlet, Conte
}
}
context.put("NamePropContentReviewOptoutUrl", ContentReviewConstants.URKUND_OPTOUT_URL);

User submitter = (User) state.getAttribute("student");
if (submitter == null) {
submitter = userDirectoryService.getCurrentUser();
}
context.put(STUDENT_WITH_SELFREPORT, submitter);

assignmentToolUtils.hasRubricSelfReview(context, assignment.getId());
}

if (taggingManager.isTaggable() && submission != null) {
Expand Down Expand Up @@ -3581,6 +3604,19 @@ protected String build_instructor_grade_submission_context(VelocityPortlet portl
}
context.put("value_grades", grades);
}

// Check if the assignment has a rubric associated or not
context.put(RubricsConstants.RBCS_HAS_ASSOCIATED_RUBRIC, rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_ASSIGNMENT, a.getId()));
if (assignmentToolUtils.hasRubricSelfReview(context, a.getId())) {
s.getSubmitters().stream().findAny().ifPresent(u -> context.put(STUDENT_WITH_SELFREPORT, u.getSubmitter()));
}
// Only one peer review for an assignment submission per student.
if (a.getAllowPeerAssessment()) {
List<PeerAssessmentItem> reviews = assignmentPeerAssessmentService.getPeerAssessmentItems(s.getId(), a.getScaleFactor());
if(reviews.size() > 1) { log.warn("More than one peer review were found for Rubric assignment"); }
reviews.stream().findFirst().ifPresent(pai -> context.put(STUDENT_WITH_SELFREPORT, pai.getId().getAssessorUserId()));
}

}

// show alert if student is working on a draft
Expand Down Expand Up @@ -3823,9 +3859,6 @@ protected String build_instructor_grade_submission_context(VelocityPortlet portl
// letter grading
letterGradeOptionsIntoContext(context);

// Check if the assignment has a rubric associated or not
context.put("hasAssociatedRubric", assignment.isPresent() && rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignment.get().getId()));

if (state.getAttribute(RUBRIC_STATE_DETAILS) != null) {
context.put(RUBRIC_STATE_DETAILS, state.getAttribute(RUBRIC_STATE_DETAILS));
}
Expand Down Expand Up @@ -4809,6 +4842,9 @@ private String build_student_review_edit_context(VelocityPortlet portlet, Contex
securityService.popAdvisor(secAdv);
}
}

context.put(RubricsConstants.RBCS_HAS_ASSOCIATED_RUBRIC, rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignment.getId()));

if (s != null) {
submissionId = s.getId();
context.put("submission", s);
Expand Down Expand Up @@ -4869,7 +4905,7 @@ private String build_student_review_edit_context(VelocityPortlet portlet, Contex
} else {
context.put("view_only", false);
}

context.put(RubricsConstants.RBCS_ASSESSOR_ID, peerAssessmentItem.getId().getAssessorUserId());
// get attachments for peer review item
List<PeerAssessmentAttachment> attachments = assignmentPeerAssessmentService.getPeerAssessmentAttachments(peerAssessmentItem.getId().getSubmissionId(), peerAssessmentItem.getId().getAssessorUserId());
List<Reference> attachmentRefList = new ArrayList<>();
Expand Down Expand Up @@ -6972,6 +7008,8 @@ private void setNewAssignmentParameters(RunData data, boolean validify) {
} catch (Exception e) {
addAlert(state, rb.getString("peerassessment.invalidNumReview"));
}
} else if (params.get(RubricsConstants.RBCS_ASSOCIATE).equals("1")) {
state.setAttribute(NEW_ASSIGNMENT_PEER_ASSESSMENT_NUM_REVIEWS, 1);
} else {
addAlert(state, rb.getString("peerassessment.specifyNumReview"));
}
Expand Down Expand Up @@ -9221,7 +9259,7 @@ public void doView_assignment_as_student(RunData data) {
public void doView_submissionReviews(RunData data) {
String submissionId = data.getParameters().getString("submissionId");
SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
String assessorId = data.getParameters().getString("assessorId");
String assessorId = data.getParameters().getString(RubricsConstants.RBCS_ASSESSOR_ID);
String assignmentId = StringUtils.trimToNull(data.getParameters().getString("assignmentId"));
Assignment a = getAssignment(assignmentId, "doEdit_assignment", state);
if (submissionId != null && !"".equals(submissionId) && a != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
import org.sakaiproject.assignment.api.model.Assignment;
import org.sakaiproject.assignment.api.model.AssignmentSubmission;
import org.sakaiproject.assignment.api.model.AssignmentSubmissionSubmitter;
import org.sakaiproject.cheftool.Context;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.rubrics.logic.RubricsService;
import org.sakaiproject.rubrics.logic.model.ToolItemRubricAssociation;
import org.sakaiproject.service.gradebook.shared.AssignmentHasIllegalPointsException;
import org.sakaiproject.service.gradebook.shared.ConflictingAssignmentNameException;
import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService;
Expand Down Expand Up @@ -883,4 +885,17 @@ private void removeNonAssociatedExternalGradebookEntry(String context, String as
}
}

public boolean hasRubricSelfReview(Context context, String assignmentId) {
try {
Optional<ToolItemRubricAssociation> rubricAssociation = rubricsService.getRubricAssociation(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignmentId);
if (rubricAssociation.isPresent() && rubricAssociation.get().getParameter(RubricsConstants.RBCS_STUDENT_SELF_REPORT)) {
context.put("rubricSelfReport", true);
return true;
}
} catch (Exception e) {
log.warn("Error trying to retrieve rubrics association for assignment : {}", e.getMessage());
}
return false;
}

}
33 changes: 33 additions & 0 deletions assignment/tool/src/webapp/js/assignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,35 @@ $(document).ready(function() {
e.preventDefault(); // override # in href from popping to the top of the page
});
}

//peer-review and self-report
setTimeout(function () {
if (null!=document.getElementById("dont-associate-value")) {

const dontAssociateCheck = document.getElementById("dont-associate-value");
const doAssociateCheck = document.getElementById("do-associate-value");
const numberReviews = document.getElementById("new_assignment_peer_assessment_num_reviews");

//page-loading
if (dontAssociateCheck.checked) {
numberReviews.removeAttribute('disabled');
}

if (doAssociateCheck.checked) {
numberReviews.setAttribute('disabled', true);
numberReviews.value = 1;
}
//event manage
dontAssociateCheck.addEventListener("change", function() {
numberReviews.removeAttribute('disabled');
});
doAssociateCheck.addEventListener("change", function() {
numberReviews.setAttribute('disabled', true);
numberReviews.value = 1;
});

}
}, 1000);

const saveRubric = e => {
[...document.getElementsByTagName("sakai-rubric-grading")].forEach(r => r. save());
Expand All @@ -979,4 +1008,8 @@ $(document).ready(function() {
saveButton && saveButton.addEventListener("click", saveRubric);
const returnButton = document.getElementById("save-and-return");
returnButton && returnButton.addEventListener("click", saveRubric);
const confirmButton = document.getElementById("confirm");
confirmButton && confirmButton.addEventListener("click", saveRubric);
const postButton = document.getElementById("post");
postButton && postButton.addEventListener("click", saveRubric);
});
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@
#if ($!hasAssociatedRubric)
</div>
<div role="tabpanel" class="tab-pane" id="rubric">
#if($assignment.getAllowPeerAssessment() || $!rubricSelfReport)
<sakai-rubric-student
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"
evaluated-item-id="$submitter"
></sakai-rubric-student>
<p class="help-block">
#if($assignment.getAllowPeerAssessment())
$tlang.getString("peerrubric")
#elseif($!rubricSelfReport)
$tlang.getString("studentrubric")
#end
</p>
<hr class="itemSeparator" />
#end
<sakai-rubric-grading
## grade-field-id="grade"
token="$!rbcs-token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@ function printView(url) {
#end
</span>
</a>
<sakai-rubric-student-button
token="$!rbcs-token"
tool-id="sakai.assignment"
evaluated-item-id="$!item.getId().getAssessorUserId()"
entity-id="$assignment.Id"
instructor="true">
</sakai-rubric-student-button>
#if($!item.getScoreDisplay().length() > 0 || ($!item.getComment() && $!item.getComment().trim().length() > 0))
<span class="highlight" #if($item.Removed) style="text-decoration: line-through" #end>
#if($item.isDraft())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- start: chef_assignments_student_confirm_submission.vm -->
#rubricsRequirements
###header_append("<script type=${quote}text/javascript${quote}>includeWebjarLibrary(${quote}bootstrap${quote});</script>")

<script>
Expand Down Expand Up @@ -115,6 +116,19 @@
</tr>
#end
</table>

#if ($!rubricSelfReport)
<p class="instruction">
$tlang.getString("reviewrubric")
</p>
<sakai-rubric-student
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"
evaluated-item-id="$submitter.Id"
></sakai-rubric-student>
#end

<h4>
$tlang.getString("gen.submission")
</h4>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!-- start: check_assignments_instructor_grading_submission.vm -->
#rubricsRequirements
#module("/rubrics-service/webcomponents/rubric-association-requirements.js")
<script type="text/javascript">
focus_path = [ '$fField' ];
$(document).ready(function(){
ASN.setupPeerReviewAttachment();
});
</script>

<div class="portletBody">
#navBarOnClick( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "gradeForm" "" )
## confirmation
Expand Down Expand Up @@ -158,6 +161,27 @@
#end

#if ($withGrade)
#if ($!hasAssociatedRubric)
#if ($!view_only)
<sakai-rubric-student
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"
evaluated-item-id="$assessorId"
></sakai-rubric-student>
#else
<sakai-rubric-grading
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"
evaluated-item-id="$assessorId"
is-peer-or-self="true"
#if($rbcs-state-details && "$!rbcs-state-details" != "")
state-details="$rbcs-state-details"
#end
></sakai-rubric-grading>
#end
#end
<div class="highlightPanel" style="width:80%">
#set ($gradeType = $assignment.TypeOfGrade.ordinal())
<p class="shorttext">
Expand Down Expand Up @@ -319,7 +343,7 @@
<input type="button" accesskey="s" name="return" value="$tlang.getString('peerassessment.removereview')" onclick="SPNR.disableControlsAndSpin( this, null ); ASN.submitForm( 'gradeForm', 'toggleremove_review', '$formattedText.escapeUrl($submissionReference)', null ); return false;" title="$tlang.getString("peerassessment.removereview")" />
#end
#else
<input type="button" accesskey="s" name="return" value="$tlang.getString('gen.sav')" onclick="SPNR.disableControlsAndSpin( this, null ); ASN.submitForm( 'gradeForm', 'savegrade_review', '$formattedText.escapeUrl($submissionReference)', null ); return false;" title="$tlang.getString("gen.sav")" />
<input type="button" id="save" accesskey="s" name="return" value="$tlang.getString('gen.sav')" onclick="SPNR.disableControlsAndSpin( this, null ); ASN.submitForm( 'gradeForm', 'savegrade_review', '$formattedText.escapeUrl($submissionReference)', null ); return false;" title="$tlang.getString("gen.sav")" />
<input type="button" accesskey="x" name="cancel" value="$tlang.getString('cancel_changes')" onclick="SPNR.disableControlsAndSpin( this, null ); ASN.submitForm( 'gradeForm', 'cancelgrade_review', null, null ); return false;" />
<input type="button" id="post" name="returnSubmit" value="$tlang.getString('gen.subm3')" onclick="SPNR.disableControlsAndSpin( this, null ); ASN.submitForm( 'gradeForm', 'submitgrade_review', '$formattedText.escapeUrl($submissionReference)', null ); return false;" title="$tlang.getString("gen.subm3")" />
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@
entity-id="$assignment.Id"
evaluated-item-id="$submission.Id"
></sakai-rubric-student>
#elseif ($!rubricSelfReport)
<sakai-rubric-student
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"
evaluated-item-id="$submitter.Id"
></sakai-rubric-student>
<p class="instruction">
$tlang.getString("reviewrubric")
</p>
#end

## show instructor comment if the submission is (1) graded and release or (2) returned
Expand Down
Loading

0 comments on commit 5451956

Please sign in to comment.