From 195543d8795dfdeb72992e0e253e3579fd5fa083 Mon Sep 17 00:00:00 2001 From: MRutea Date: Mon, 23 Nov 2020 09:38:46 +0100 Subject: [PATCH] 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 --- .../api/src/resources/assignment.properties | 5 ++ .../assignment/tool/AssignmentAction.java | 47 +++++++++++-- .../assignment/tool/AssignmentToolUtils.java | 15 +++++ assignment/tool/src/webapp/js/assignments.js | 4 ++ ...signments_instructor_grading_submission.vm | 16 +++++ ...assignments_instructor_list_submissions.vm | 7 ++ ..._assignments_student_confirm_submission.vm | 14 ++++ .../chef_assignments_student_review_edit.vm | 26 +++++++- .../chef_assignments_student_view_grade.vm | 10 +++ ...hef_assignments_student_view_submission.vm | 38 ++++++++++- .../instructor_new_edit/grading_section.vm | 4 +- .../rubrics/logic/RubricsConstants.java | 3 + .../repository/EvaluationRepository.java | 13 ++++ .../rubrics/logic/RubricsServiceImpl.java | 2 +- .../js/rubrics/sakai-rubric-association.js | 49 ++++++++++++-- .../js/rubrics/sakai-rubric-grading.js | 66 ++++++++++++------- 16 files changed, 283 insertions(+), 36 deletions(-) diff --git a/assignment/api/src/resources/assignment.properties b/assignment/api/src/resources/assignment.properties index 7fa295de0579..f72b832937ef 100644 --- a/assignment/api/src/resources/assignment.properties +++ b/assignment/api/src/resources/assignment.properties @@ -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 diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java index f9ffc19382bb..a8891caf7d54 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java @@ -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; @@ -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"; + /** + * submittee, the student who do a selfreport + */ + private static final String STUDENT_WITH_SELFREPORT = "submittee"; private static final String FLAG_ON = "on"; private static final String FLAG_TRUE = "true"; @@ -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) { @@ -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 submissionAttachmentReferences = new HashMap<>(); stripInvisibleAttachments(state.getAttribute(PREVIEW_SUBMISSION_ATTACHMENTS)).forEach(r -> submissionAttachmentReferences.put(r.getId(), r)); @@ -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) { @@ -3581,6 +3604,18 @@ 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.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())); + } + if (a.getAllowPeerAssessment()) { + List 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 @@ -3823,9 +3858,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)); } @@ -4809,6 +4841,9 @@ private String build_student_review_edit_context(VelocityPortlet portlet, Contex securityService.popAdvisor(secAdv); } } + + context.put(RubricsConstants.HAS_ASSOCIATED_RUBRIC, rubricsService.hasAssociatedRubric(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignment.getId())); + if (s != null) { submissionId = s.getId(); context.put("submission", s); @@ -4869,7 +4904,7 @@ private String build_student_review_edit_context(VelocityPortlet portlet, Contex } else { context.put("view_only", false); } - + context.put(RubricsConstants.ASSESSOR_ID, peerAssessmentItem.getId().getAssessorUserId()); // get attachments for peer review item List attachments = assignmentPeerAssessmentService.getPeerAssessmentAttachments(peerAssessmentItem.getId().getSubmissionId(), peerAssessmentItem.getId().getAssessorUserId()); List attachmentRefList = new ArrayList<>(); @@ -6972,6 +7007,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")); } @@ -9221,7 +9258,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.ASSESSOR_ID); String assignmentId = StringUtils.trimToNull(data.getParameters().getString("assignmentId")); Assignment a = getAssignment(assignmentId, "doEdit_assignment", state); if (submissionId != null && !"".equals(submissionId) && a != null) { diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java index 624ac128ddef..dfdcbd870986 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java @@ -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; @@ -883,4 +885,17 @@ private void removeNonAssociatedExternalGradebookEntry(String context, String as } } + public boolean hasRubricSelfReview(Context context, String assignmentId) { + try { + Optional rubricAssociation = rubricsService.getRubricAssociation(RubricsConstants.RBCS_TOOL_ASSIGNMENT, assignmentId); + if (rubricAssociation.isPresent() && rubricAssociation.get().getParameter(RubricsConstants.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; + } + } diff --git a/assignment/tool/src/webapp/js/assignments.js b/assignment/tool/src/webapp/js/assignments.js index 17ee5225b4df..2d149218196a 100755 --- a/assignment/tool/src/webapp/js/assignments.js +++ b/assignment/tool/src/webapp/js/assignments.js @@ -979,4 +979,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); }); diff --git a/assignment/tool/src/webapp/vm/assignment/chef_assignments_instructor_grading_submission.vm b/assignment/tool/src/webapp/vm/assignment/chef_assignments_instructor_grading_submission.vm index b068aa2f9723..3702a7472635 100644 --- a/assignment/tool/src/webapp/vm/assignment/chef_assignments_instructor_grading_submission.vm +++ b/assignment/tool/src/webapp/vm/assignment/chef_assignments_instructor_grading_submission.vm @@ -337,6 +337,22 @@ #if ($!hasAssociatedRubric)
+ #if($assignment.getAllowPeerAssessment() || $!rubricSelfReport) + +

+ #if($assignment.getAllowPeerAssessment()) + $tlang.getString("peerrubric") + #elseif($!rubricSelfReport) + $tlang.getString("studentrubric") + #end +

+
+ #end + + #if($!item.getScoreDisplay().length() > 0 || ($!item.getComment() && $!item.getComment().trim().length() > 0)) #if($item.isDraft()) diff --git a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_confirm_submission.vm b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_confirm_submission.vm index 3af180094be5..49d88e361ec5 100644 --- a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_confirm_submission.vm +++ b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_confirm_submission.vm @@ -1,4 +1,5 @@ +#rubricsRequirements ###header_append("") +
#navBarOnClick( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "gradeForm" "" ) ## confirmation @@ -158,6 +161,27 @@ #end #if ($withGrade) + #if ($!hasAssociatedRubric) + #if ($!view_only) + + #else + + #end + #end
#set ($gradeType = $assignment.TypeOfGrade.ordinal())

@@ -319,7 +343,7 @@ #end #else - + #end diff --git a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_grade.vm b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_grade.vm index 3d22ab77a011..1c73a18f094d 100644 --- a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_grade.vm +++ b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_grade.vm @@ -286,6 +286,16 @@ entity-id="$assignment.Id" evaluated-item-id="$submission.Id" > + #elseif ($!rubricSelfReport) + +

+ $tlang.getString("reviewrubric") +

#end ## show instructor comment if the submission is (1) graded and release or (2) returned diff --git a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_submission.vm b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_submission.vm index c9ddf46d0455..0573fdc7619f 100644 --- a/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_submission.vm +++ b/assignment/tool/src/webapp/vm/assignment/chef_assignments_student_view_submission.vm @@ -20,7 +20,20 @@ $(document).ready(function(){ $('.cloned a').show(); ASN.resizeFrame('grow'); }); - + + $('body').on('rubrics-grading-loaded', e => { + if($('.sakai-rubric-criteria-grading').length) { + $('#confirm').attr('disabled','disabled'); + $('#preview').attr('disabled','disabled'); + $('#save').attr('disabled','disabled'); + $('body').on('rubric-ratings-changed', e => { + $('#confirm').removeAttr('disabled'); + $('#preview').removeAttr('disabled'); + $('#save').removeAttr('disabled'); + }); + } + }); + }); ## Include other javascript specific to this page @@ -329,10 +342,13 @@ $(document).ready(function(){ #supplementItems($!allowViewModelAnswer $!allowReadAssignmentNoteItem $!allowViewAllPurposeItem $!assignmentModelAnswerItem $!assignmentNoteItem $!assignmentAllPurposeItem) + #if (!$!rubricSelfReport) + entity-id="$assignment.Id"> + + #end #if ($submission.Graded && ($submission.GradeReleased || $returned)) + + #if ($!rubricSelfReport) +

+ $tlang.getString("youmustrubric") +

+ + #end #if ($!canSubmit) ## if a draft submission or the submission has been returned and has not yet submitted diff --git a/assignment/tool/src/webapp/vm/assignment/instructor_new_edit/grading_section.vm b/assignment/tool/src/webapp/vm/assignment/instructor_new_edit/grading_section.vm index 248ec7e47203..cbb8491d7e30 100644 --- a/assignment/tool/src/webapp/vm/assignment/instructor_new_edit/grading_section.vm +++ b/assignment/tool/src/webapp/vm/assignment/instructor_new_edit/grading_section.vm @@ -57,7 +57,9 @@ This section contains the options for grading this assignment, including rubrics dont-associate-value="0" associate-label="$tlang.getString("associate.label")" associate-value="1" tool-id="sakai.assignment" #if("$!assignment.Id" != "") entity-id="$assignment.Id" #end #if($rbcs-state-details && "$!rbcs-state-details" != "") state-details="$rbcs-state-details" #end - fine-tune-points="$tlang.getString("option.pointsoverride")" hide-student-preview="$tlang.getString("option.studentpreview")"> + fine-tune-points="$tlang.getString("option.pointsoverride")" hide-student-preview="$tlang.getString("option.studentpreview")" + student-self-report="$tlang.getString("option.selfreport")" + show-self-report-check="true">
diff --git a/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/RubricsConstants.java b/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/RubricsConstants.java index 3bc8aec26854..7f6fdf0a07b0 100644 --- a/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/RubricsConstants.java +++ b/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/RubricsConstants.java @@ -39,6 +39,9 @@ public interface RubricsConstants { public static final String RBCS_LIST_SUFFIX = "rubricslist"; public static final String RBCS_LIST = RBCS_PREFIX + RBCS_LIST_SUFFIX; public static final String RBCS_SOFT_DELETED = RBCS_PREFIX + "soft-deleted"; + public static final String STUDENT_SELF_REPORT = "studentSelfReport"; + public static final String HAS_ASSOCIATED_RUBRIC = "hasAssociatedRubric"; + public static final String ASSESSOR_ID = "assessorId"; //samigo custom props public static final String RBCS_PUBLISHED_ASSESSMENT_ENTITY_PREFIX = "pub."; diff --git a/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/repository/EvaluationRepository.java b/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/repository/EvaluationRepository.java index 5e0a4925249b..5f95c80072a1 100644 --- a/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/repository/EvaluationRepository.java +++ b/rubrics/api/src/main/java/org/sakaiproject/rubrics/logic/repository/EvaluationRepository.java @@ -46,6 +46,9 @@ public interface EvaluationRepository extends MetadataRepository findById(Long id); @@ -83,6 +86,16 @@ public interface EvaluationRepository extends MetadataRepository findByToolIdAndAssociationItemIdAndEvaluatedItemId(@Param("toolId") String toolId, @Param("itemId") String itemId, @Param("evaluatedItemId") String evaluatedItemId); + @RestResource(path = "peer-by-tool-item-and-associated-item-and-evaluated-item-ids", rel = "peer-by-tool-item-and-associated-item-and-evaluated-item-ids") + @PreAuthorize("hasAnyRole('ROLE_EVALUEE')") + @Query("select resource from Evaluation resource where " + + "resource.evaluatedItemId = :evaluatedItemId " + + "and resource.toolItemRubricAssociation.toolId = :toolId " + + "and resource.toolItemRubricAssociation.itemId = :itemId " + + "and (" + SELF_EVALUATOR_CONSTRAINT + ")") + List peerFindByToolIdAndAssociationItemIdAndEvaluatedItemId(@Param("toolId") String toolId, + @Param("itemId") String itemId, @Param("evaluatedItemId") String evaluatedItemId); + @RestResource(path = "by-association-and-user", rel = "by-association-and-user") @PreAuthorize("hasAnyRole('ROLE_EVALUATOR', 'ROLE_EVALUEE')") @Query("select resource.evaluatedItemId from Evaluation resource where " + diff --git a/rubrics/impl/src/main/java/org/sakaiproject/rubrics/logic/RubricsServiceImpl.java b/rubrics/impl/src/main/java/org/sakaiproject/rubrics/logic/RubricsServiceImpl.java index ba0667c62555..570b4b35f9cc 100644 --- a/rubrics/impl/src/main/java/org/sakaiproject/rubrics/logic/RubricsServiceImpl.java +++ b/rubrics/impl/src/main/java/org/sakaiproject/rubrics/logic/RubricsServiceImpl.java @@ -557,7 +557,7 @@ public String getRubricEvaluationObjectId(String associationId, String userId, S * @return */ private String postRubricResource(String targetUri, String json, String toolId, String siteId) throws IOException { - log.debug(String.format("Post to URI '%s' body:", targetUri, json)); + log.debug("Post to URI {} body: {}", targetUri, json); HttpURLConnection conn = null; try { diff --git a/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-association.js b/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-association.js index a22d3d023f6a..ec7ad8716961 100644 --- a/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-association.js +++ b/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-association.js @@ -40,6 +40,8 @@ class SakaiRubricAssociation extends RubricsElement { associateValue: { attribute: "associate-value", type: Number }, fineTunePoints: { attribute: "fine-tune-points", type: String }, hideStudentPreview: { attribute: "hide-student-preview", type: String }, + studentSelfReport: { attribute: "student-self-report", type: String }, + showSelfReportCheck: { attribute: "show-self-report-check", type: String }, rubrics: { type: Array }, readOnly: { attribute: "read-only", type: Boolean }, }; @@ -66,13 +68,13 @@ class SakaiRubricAssociation extends RubricsElement { ${this.readOnly ? "" : html`
`} @@ -94,14 +96,25 @@ class SakaiRubricAssociation extends RubricsElement {
+ ${this.showSelfReportCheck === 'true' ? + html` +
+ +
+ ` + : + html`` + }
`}
@@ -160,6 +173,9 @@ class SakaiRubricAssociation extends RubricsElement { if (!this.isAssociated) { this.selectedRubric = this.rubrics[0].id; } + if (!this.stateDetails) { + this.handleAssociated(); + } } } @@ -186,9 +202,34 @@ class SakaiRubricAssociation extends RubricsElement { } } + handleAssociated() { + + if (this.isAssociated == 1) { + + this.enabledClass = "enabled" + setTimeout(function () { + if (this.showSelfReportCheck === 'true') { + + document.getElementById("new_assignment_peer_assessment_num_reviews").setAttribute('disabled', true); + document.getElementById("new_assignment_peer_assessment_num_reviews").value = 1; + } + }.bind(this)); + } else { + this.enabledClass = "disabled" + setTimeout(function () { + if (this.showSelfReportCheck === 'true') { + document.getElementById("new_assignment_peer_assessment_num_reviews").removeAttribute('disabled'); + } + }.bind(this)); + } + this.dispatchEvent(new CustomEvent('state-details')); + } + associate(e) { this.isAssociated = e.target.value == 1; + this.handleAssociated(); } + } customElements.define("sakai-rubric-association", SakaiRubricAssociation); diff --git a/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-grading.js b/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-grading.js index 8394f7e400fb..3aafaf4d0463 100644 --- a/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-grading.js +++ b/webcomponents/tool/src/main/frontend/js/rubrics/sakai-rubric-grading.js @@ -32,6 +32,7 @@ export class SakaiRubricGrading extends RubricsElement { // Non attribute evaluation: { type: Object }, + isPeerOrSelf: { type: Boolean }, totalPoints: Number, translatedTotalPoints: { type: Number }, selectedRatings: { type: Array }, @@ -345,36 +346,57 @@ export class SakaiRubricGrading extends RubricsElement { url: `/rubrics-service/rest/rubrics/${rubricId}?projection=inlineRubric`, headers: { "authorization": this.token } }).done(rubric => { + + if (!this.isPeerOrSelf) { + + $.ajax({ + url: `/rubrics-service/rest/evaluations/search/by-tool-item-and-associated-item-and-evaluated-item-ids?toolId=${this.toolId}&itemId=${this.entityId}&evaluatedItemId=${this.evaluatedItemId}`, + headers: { "authorization": this.token } + }).done(data => { + doCriteriaDecoration(data); + }).fail((jqXHR, textStatus, errorThrown) => { + console.log(textStatus);console.log(errorThrown); + }); - $.ajax({ - url: `/rubrics-service/rest/evaluations/search/by-tool-item-and-associated-item-and-evaluated-item-ids?toolId=${this.toolId}&itemId=${this.entityId}&evaluatedItemId=${this.evaluatedItemId}`, - headers: { "authorization": this.token } - }).done(data => { + } else { + + $.ajax({ + url: `/rubrics-service/rest/evaluations/search/peer-by-tool-item-and-associated-item-and-evaluated-item-ids?toolId=${this.toolId}&itemId=${this.entityId}&evaluatedItemId=${this.evaluatedItemId}`, + headers: { "authorization": this.token } + }).done(data => { + doCriteriaDecoration(data); + document.querySelectorAll('.rating-item.selected').length > 0 ? this.dispatchEvent(new CustomEvent('rubric-ratings-changed', {bubbles: true, composed: true})) : this.dispatchEvent(new CustomEvent('rubrics-grading-loaded', {bubbles: true, composed: true})); + }).fail((jqXHR, textStatus, errorThrown) => { + console.log(textStatus);console.log(errorThrown); + }); + } - this.evaluation = data._embedded.evaluations[0] || { criterionOutcomes: [] }; - this.selectedRatings = this.evaluation.criterionOutcomes.map(ed => ed.selectedRatingId); - if (this.criteria) this.decorateCriteria(); - this.existingEvaluation = true; + }).fail((jqXHR, textStatus, errorThrown) => { + console.log(textStatus);console.log(errorThrown); + }); + } - this.rubric = rubric; + doCriteriaDecoration(data) { - this.criteria = this.rubric.criterions; - this.criteria.forEach(c => { + this.evaluation = data._embedded.evaluations[0] || { criterionOutcomes: [] }; + this.selectedRatings = this.evaluation.criterionOutcomes.map(ed => ed.selectedRatingId); + if (this.criteria) this.decorateCriteria(); + this.existingEvaluation = true; - if (!c.selectedvalue) { - c.selectedvalue = 0; - } - c.pointrange = this.getHighLow(c.ratings, "points"); - }); + this.rubric = rubric; - this.decorateCriteria(); - }).fail((jqXHR, textStatus, errorThrown) => { - console.log(textStatus);console.log(errorThrown); - }); - }).fail((jqXHR, textStatus, errorThrown) => { - console.log(textStatus);console.log(errorThrown); + this.criteria = this.rubric.criterions; + this.criteria.forEach(c => { + + if (!c.selectedvalue) { + c.selectedvalue = 0; + } + c.pointrange = this.getHighLow(c.ratings, "points"); }); + + this.decorateCriteria(); } + } customElements.define("sakai-rubric-grading", SakaiRubricGrading);