From 23bef6112f3470d3e7b2825ab8d69f408f4cd71d Mon Sep 17 00:00:00 2001 From: Adrian Fish Date: Thu, 23 Dec 2021 17:51:32 +0000 Subject: [PATCH] SAK-45987 Fix cancel behaviour with rubric evaluations (#10111) https://sakaiproject.atlassian.net/browse/SAK-45987 --- .../tool/panels/RubricGradePanel.html | 3 +- .../tool/panels/RubricGradePanel.java | 1 + .../webapp/scripts/gradebook-cancelrubric.js | 5 + .../scripts/gradebook-savecancelrubric.js | 11 +++ .../webapp/scripts/gradebook-saverubric.js | 5 - .../samigo-app/src/webapp/js/samigo-global.js | 21 ++++- .../jsf/evaluation/gradeStudentResult.jsp | 2 +- .../webapp/jsf/evaluation/questionScore.jsp | 4 +- .../main/frontend/js/grader/sakai-grader.js | 9 ++ .../frontend/js/rubrics/rubrics-element.js | 3 +- .../js/rubrics/sakai-rubric-grading.js | 92 +++++++++++++++++-- .../main/frontend/js/sakai-portal-utils.js | 3 + .../frontend/test/sakai-portal-utils.test.js | 19 ++++ 13 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 gradebookng/tool/src/webapp/scripts/gradebook-cancelrubric.js create mode 100644 gradebookng/tool/src/webapp/scripts/gradebook-savecancelrubric.js delete mode 100644 gradebookng/tool/src/webapp/scripts/gradebook-saverubric.js create mode 100644 webcomponents/tool/src/main/frontend/js/sakai-portal-utils.js create mode 100644 webcomponents/tool/src/main/frontend/test/sakai-portal-utils.test.js diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.html index fd8261bb8718..029f5cef33ca 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.html +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.html @@ -7,13 +7,12 @@
-
- + diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.java index 3ec3f82a3d74..529dc8fe22bc 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/RubricGradePanel.java @@ -94,6 +94,7 @@ public void onSubmit(final AjaxRequestTarget target, final Form form) { RubricGradePanel.this.window.close(target); } }; + cancel.setOutputMarkupId(true).setMarkupId("cancelrubric"); cancel.setDefaultFormProcessing(false); form.add(cancel); diff --git a/gradebookng/tool/src/webapp/scripts/gradebook-cancelrubric.js b/gradebookng/tool/src/webapp/scripts/gradebook-cancelrubric.js new file mode 100644 index 000000000000..41c518030631 --- /dev/null +++ b/gradebookng/tool/src/webapp/scripts/gradebook-cancelrubric.js @@ -0,0 +1,5 @@ +document.getElementById("cancelrubric").addEventListener("click", e => { + + const rubricGrading = document.getElementsByTagName("sakai-rubric-grading").item(0); + rubricGrading && rubricGrading.cancel(); +}); diff --git a/gradebookng/tool/src/webapp/scripts/gradebook-savecancelrubric.js b/gradebookng/tool/src/webapp/scripts/gradebook-savecancelrubric.js new file mode 100644 index 000000000000..019ac9c14173 --- /dev/null +++ b/gradebookng/tool/src/webapp/scripts/gradebook-savecancelrubric.js @@ -0,0 +1,11 @@ +document.getElementById("saverubric").addEventListener("click", e => { + + const rubricGrading = document.getElementsByTagName("sakai-rubric-grading").item(0); + rubricGrading && rubricGrading.release(); +}); + +document.getElementById("cancelrubric").addEventListener("click", e => { + + const rubricGrading = document.getElementsByTagName("sakai-rubric-grading").item(0); + rubricGrading && rubricGrading.cancel(); +}); diff --git a/gradebookng/tool/src/webapp/scripts/gradebook-saverubric.js b/gradebookng/tool/src/webapp/scripts/gradebook-saverubric.js deleted file mode 100644 index c795af15e665..000000000000 --- a/gradebookng/tool/src/webapp/scripts/gradebook-saverubric.js +++ /dev/null @@ -1,5 +0,0 @@ -document.getElementById("saverubric").addEventListener("click", e => { - - const rubricGrading = document.getElementsByTagName("sakai-rubric-grading").item(0); - rubricGrading && rubricGrading.release(); -}); diff --git a/samigo/samigo-app/src/webapp/js/samigo-global.js b/samigo/samigo-app/src/webapp/js/samigo-global.js index ef03eaadb9e7..d478354d89c7 100644 --- a/samigo/samigo-app/src/webapp/js/samigo-global.js +++ b/samigo/samigo-app/src/webapp/js/samigo-global.js @@ -103,7 +103,7 @@ function returnToHostUrl(url) { } } -function initRubricDialog(gradingId, saveText, cancelText, titleText) { +function initRubricDialog(gradingId, doneText, cancelText, titleText) { var modalId = "modal" + gradingId; var previousScore = $('.adjustedScore' + gradingId).val(); @@ -111,13 +111,18 @@ function initRubricDialog(gradingId, saveText, cancelText, titleText) { modal: true, buttons: [ { - text: saveText, - click: function () { $(this).dialog("close"); } + text: doneText, + click: function () { + $(this).dialog("close"); + } }, { text: cancelText, click: function () { + const rubric = this.querySelector(`sakai-rubric-grading`); + rubric.cancel(); + $(this).dialog("close"); $('.adjustedScore' + gradingId).val(previousScore); } @@ -162,6 +167,16 @@ $(function () { saveButton = document.getElementById("editTotalResults:save"); saveButton && saveButton.addEventListener("click", save); + const cancel = e => { + [...document.getElementsByTagName("sakai-rubric-grading")].forEach(srb => srb.cancel()); + }; + + let cancelButton = document.getElementById("editStudentResults:cancel"); + cancelButton && cancelButton.addEventListener("click", cancel); + + cancelButton = document.getElementById("editTotalResults:cancel"); + cancelButton && cancelButton.addEventListener("click", cancel); + if ( $("#selectIndexForm\\:selectTable").length ) { $("#selectIndexForm\\:selectTable").tablesorter({ sortList: [[2,0]], diff --git a/samigo/samigo-app/src/webapp/jsf/evaluation/gradeStudentResult.jsp b/samigo/samigo-app/src/webapp/jsf/evaluation/gradeStudentResult.jsp index 76697995201b..40dcc9db936d 100755 --- a/samigo/samigo-app/src/webapp/jsf/evaluation/gradeStudentResult.jsp +++ b/samigo/samigo-app/src/webapp/jsf/evaluation/gradeStudentResult.jsp @@ -359,7 +359,7 @@ function toPoint(id) - + diff --git a/samigo/samigo-app/src/webapp/jsf/evaluation/questionScore.jsp b/samigo/samigo-app/src/webapp/jsf/evaluation/questionScore.jsp index da3458a6eb62..d636b74f2be6 100755 --- a/samigo/samigo-app/src/webapp/jsf/evaluation/questionScore.jsp +++ b/samigo/samigo-app/src/webapp/jsf/evaluation/questionScore.jsp @@ -64,7 +64,7 @@ $Id$ function initRubricDialogWrapper(gradingId) { initRubricDialog(gradingId - , + , , , ); } @@ -1224,7 +1224,7 @@ $Id$ - +

diff --git a/webcomponents/tool/src/main/frontend/js/grader/sakai-grader.js b/webcomponents/tool/src/main/frontend/js/grader/sakai-grader.js index ed15d9751b48..c733b23ad2c5 100644 --- a/webcomponents/tool/src/main/frontend/js/grader/sakai-grader.js +++ b/webcomponents/tool/src/main/frontend/js/grader/sakai-grader.js @@ -369,6 +369,7 @@ export class SakaiGrader extends gradableDataMixin(SakaiElement) { +