From f4896730cf3576ffec7b01b42f5790b72a9912a2 Mon Sep 17 00:00:00 2001 From: Adrian Fish Date: Tue, 19 Mar 2019 19:51:10 +0000 Subject: [PATCH] SAK-40310 Adding rubric preview back in for students (#6669) https://jira.sakaiproject.org/browse/SAK-40310 --- ...hef_assignments_student_view_submission.vm | 5 + .../tool/panels/GradeSummaryTablePanel.html | 8 +- .../tool/panels/GradeSummaryTablePanel.java | 93 +++++-------------- .../src/webapp/styles/gradebook-shared.css | 3 - .../discussionForum/forum/dfForumDetail.jsp | 8 ++ .../discussionForum/message/dfAllMessages.jsp | 9 +- .../impl/src/webapp/vm/morpheus/site.vm | 1 + .../sakai-rubric-student-preview-button.js | 72 ++++++++++++++ .../delivery/BeginDeliveryActionListener.java | 2 +- .../jsf/delivery/beginTakingAssessment.jsp | 2 +- .../webapp/jsf/delivery/deliverAssessment.jsp | 7 ++ .../jsf/delivery/item/deliverShortAnswer.jsp | 2 + 12 files changed, 131 insertions(+), 81 deletions(-) create mode 100644 rubrics/tool/src/main/frontend/webcomponents/sakai-rubric-student-preview-button.js 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 50f6f6740e53..8b75e78271c8 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 @@ -371,6 +371,11 @@ $(document).ready(function(){ #end + + #if ($submission.Graded && ($submission.GradeReleased || $returned)) -
- @@ -58,7 +56,9 @@ @@ -77,4 +77,4 @@ - \ No newline at end of file + diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeSummaryTablePanel.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeSummaryTablePanel.java index b3d053450100..9ba85b5de017 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeSummaryTablePanel.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeSummaryTablePanel.java @@ -42,7 +42,6 @@ import org.sakaiproject.gradebookng.tool.pages.BasePage; import org.sakaiproject.gradebookng.tool.pages.GradebookPage; import org.sakaiproject.rubrics.logic.RubricsConstants; -import org.sakaiproject.rubrics.logic.model.ToolItemRubricAssociation; import org.sakaiproject.service.gradebook.shared.Assignment; import org.sakaiproject.service.gradebook.shared.CategoryDefinition; import org.sakaiproject.service.gradebook.shared.GradebookInformation; @@ -52,8 +51,6 @@ public class GradeSummaryTablePanel extends BasePanel { private static final long serialVersionUID = 1L; - private GbModalWindow rubricStudentWindow; - private boolean isGroupedByCategory; private boolean assignmentStatsEnabled; @@ -91,8 +88,7 @@ public void onBeforeRender() { final String studentUuid = (String) data.get("studentUuid"); this.isGroupedByCategory = (boolean) data.get("isGroupedByCategory"); final Map categoriesMap = (Map) data.get("categoriesMap"); - final ModalWindow assignmentStatsWindow = new ModalWindow( - "assignmentStatsWindow"); + final ModalWindow assignmentStatsWindow = new ModalWindow("assignmentStatsWindow"); add(assignmentStatsWindow); if (getPage() instanceof GradebookPage) { @@ -101,9 +97,6 @@ public void onBeforeRender() { this.isGroupedByCategory = settings.isGradeSummaryGroupedByCategory(); } - this.rubricStudentWindow = new GbModalWindow("rubricStudentWindow"); - addOrReplace(this.rubricStudentWindow); - final WebMarkupContainer toggleActions = new WebMarkupContainer("toggleActions"); toggleActions.setVisible(categoriesEnabled); @@ -321,71 +314,33 @@ public boolean isVisible() { } }); gradeScore.add(new Label("outOf").setVisible(false)); - final Label rubricIcon = new Label("rubricIcon"); - rubricIcon.setVisible(false); - gradeScore.add(rubricIcon); + + final WebMarkupContainer sakaiRubricPreview = new WebMarkupContainer("sakai-rubric-student-preview-button"); + sakaiRubricPreview.add(AttributeModifier.append("display", "icon")); + sakaiRubricPreview.add(AttributeModifier.append("tool-id", RubricsConstants.RBCS_TOOL_GRADEBOOKNG)); + sakaiRubricPreview.add(AttributeModifier.append("token", rubricsService.generateJsonWebToken(RubricsConstants.RBCS_TOOL_GRADEBOOKNG))); + + if (assignment.getId() != null) { + sakaiRubricPreview.add(AttributeModifier.append("entity-id", assignment.getId())); + } + + gradeScore.add(sakaiRubricPreview); } else { gradeScore.add( new Label("grade", FormatHelper.convertEmptyGradeToDash(FormatHelper.formatGradeForDisplay(rawGrade)))); gradeScore.add(new Label("outOf", new StringResourceModel("label.studentsummary.outof", null, assignment.getPoints()))); - final GbAjaxLink rubricIcon = new GbAjaxLink("rubricIcon") { - @Override - public void onClick(final AjaxRequestTarget target) { - final GbModalWindow window = GradeSummaryTablePanel.this.getRubricStudentWindow(); - - window.setTitle(new ResourceModel("rubrics.option.graderubric")); - final RubricStudentPanel rubricStudentPanel = new RubricStudentPanel(window.getContentId(), null, window); - if(assignment.isExternallyMaintained()){//this only works for Assignments atm - rubricStudentPanel.setToolId(RubricsConstants.RBCS_TOOL_ASSIGNMENT); - final String[] bits = assignment.getExternalId().split("/"); - final String assignmentId = bits[bits.length-1]; - final String submissionId = GradeSummaryTablePanel.this.rubricsService.getRubricEvaluationObjectId(assignmentId, studentUuid, RubricsConstants.RBCS_TOOL_ASSIGNMENT); - if(StringUtils.isEmpty(submissionId)){ - setVisible(false); - } - rubricStudentPanel.setAssignmentId(assignmentId); - rubricStudentPanel.setStudentUuid(submissionId); - } else { - rubricStudentPanel.setToolId(RubricsConstants.RBCS_TOOL_GRADEBOOKNG); - rubricStudentPanel.setAssignmentId(String.valueOf(assignment.getId())); - rubricStudentPanel.setStudentUuid(assignment.getId() + "." + studentUuid); - } - if(GradeSummaryTablePanel.this.businessService.isUserAbleToEditAssessments()){ - rubricStudentPanel.setInstructor(true); - } - window.setContent(rubricStudentPanel); - window.setComponentToReturnFocusTo(this); - window.show(target); - } - }; - rubricIcon.setVisible(false); - rubricIcon.add(new AttributeModifier("title", new ResourceModel("rubrics.browse_grading_criteria"))); - if (StringUtils.isNotBlank(rawGrade)) { - try { - String tool = RubricsConstants.RBCS_TOOL_GRADEBOOKNG; - String assignmentId = assignment.getId().toString(); - if(assignment.isExternallyMaintained()){//this only works for Assignments atm - tool = RubricsConstants.RBCS_TOOL_ASSIGNMENT; - final String[] bits = assignment.getExternalId().split("/"); - assignmentId = bits[bits.length-1]; - } - final Optional rubricAssociation = GradeSummaryTablePanel.this.rubricsService.getRubricAssociation(tool, assignmentId); - if (rubricAssociation.isPresent()) { - if(showingStudentView || !GradeSummaryTablePanel.this.businessService.isUserAbleToEditAssessments()){ - final boolean hidePreview = rubricAssociation.get().getParameter("hideStudentPreview") == null ? false : rubricAssociation.get().getParameter("hideStudentPreview"); - rubricIcon.setVisible(!hidePreview); - } else { - rubricIcon.setVisible(true); - } - } else { - rubricIcon.setVisible(false); - } - } catch (final Exception ex) { - rubricIcon.setVisible(false); - } + + final WebMarkupContainer sakaiRubricPreview = new WebMarkupContainer("sakai-rubric-student-preview-button"); + sakaiRubricPreview.add(AttributeModifier.append("display", "icon")); + sakaiRubricPreview.add(AttributeModifier.append("tool-id", RubricsConstants.RBCS_TOOL_GRADEBOOKNG)); + sakaiRubricPreview.add(AttributeModifier.append("token", rubricsService.generateJsonWebToken(RubricsConstants.RBCS_TOOL_GRADEBOOKNG))); + + if (assignment.getId() != null) { + sakaiRubricPreview.add(AttributeModifier.append("entity-id", assignment.getId())); } - gradeScore.add(rubricIcon); + + gradeScore.add(sakaiRubricPreview); } if (gradeInfo != null && gradeInfo.isDroppedFromCategoryScore()) { gradeScore.add(AttributeModifier.append("class", "gb-summary-grade-score-dropped")); @@ -408,7 +363,6 @@ public void onClick(final AjaxRequestTarget target) { }); } }); - } private final class DropInfoPair { @@ -430,7 +384,4 @@ private DropInfoPair getDropInfo(final String categoryName, final Map <%-- Rubrics marker --%> + + " + tool-id="sakai.forums" + entity-id=""> + + diff --git a/msgcntr/messageforums-app/src/webapp/jsp/discussionForum/message/dfAllMessages.jsp b/msgcntr/messageforums-app/src/webapp/jsp/discussionForum/message/dfAllMessages.jsp index fcc51168966f..59884a37795e 100644 --- a/msgcntr/messageforums-app/src/webapp/jsp/discussionForum/message/dfAllMessages.jsp +++ b/msgcntr/messageforums-app/src/webapp/jsp/discussionForum/message/dfAllMessages.jsp @@ -190,7 +190,14 @@ <%-- Rubrics marker --%> - + + " + display="icon" + tool-id="sakai.forums" + entity-id=""> + + diff --git a/portal/portal-render-engine-impl/impl/src/webapp/vm/morpheus/site.vm b/portal/portal-render-engine-impl/impl/src/webapp/vm/morpheus/site.vm index 878a3a9b05ea..a9b6958280f2 100755 --- a/portal/portal-render-engine-impl/impl/src/webapp/vm/morpheus/site.vm +++ b/portal/portal-render-engine-impl/impl/src/webapp/vm/morpheus/site.vm @@ -150,6 +150,7 @@ + #if ( $tutorial && $loggedIn ) diff --git a/rubrics/tool/src/main/frontend/webcomponents/sakai-rubric-student-preview-button.js b/rubrics/tool/src/main/frontend/webcomponents/sakai-rubric-student-preview-button.js new file mode 100644 index 000000000000..054bf06a57a8 --- /dev/null +++ b/rubrics/tool/src/main/frontend/webcomponents/sakai-rubric-student-preview-button.js @@ -0,0 +1,72 @@ +import {SakaiElement} from "/webcomponents/sakai-element.js"; +import {html} from "/webcomponents/assets/lit-element/lit-element.js"; +import {SakaiRubricsLanguage, tr} from "./sakai-rubrics-language.js"; +import {SakaiRubricsHelpers} from "./sakai-rubrics-helpers.js"; + +export class SakaiRubricStudentPreviewButton extends SakaiElement { + + constructor() { + + super(); + + this.display = "button"; + + SakaiRubricsLanguage.loadTranslations().then(result => this.i18nLoaded = result ); + } + + static get properties() { + + return { + token: { type: String }, + display: { type: String }, + toolId: { attribute: "tool-id", type: String }, + entityId: { attribute: "entity-id", type: String }, + rubricId: { type: String }, + }; + } + + set token(newValue) { + + this._token = "Bearer " + newValue; + rubrics.initLightbox(this._token); + } + + get token() { return this._token; } + + attributeChangedCallback(name, oldValue, newValue) { + + super.attributeChangedCallback(name, oldValue, newValue); + + if (this.token && this.toolId && this.entityId) { + this.getRubricId(); + } + } + + shouldUpdate(changedProperties) { + return changedProperties.has("rubricId"); + } + + render() { + + return html` + ${this.display === "button" ? + html`

+ ` + : html`` + } + `; + } + + getRubricId() { + + SakaiRubricsHelpers.get("/rubrics-service/rest/rubric-associations/search/by-tool-item-ids", this.token, { params: {toolId: this.toolId, itemId: this.entityId }}) + .then(data => { + + const association = data._embedded["rubric-associations"][0]; + if (!association.parameters.hideStudentPreview) { + this.rubricId = association.rubricId}; + }); + } +} + +customElements.define("sakai-rubric-student-preview-button", SakaiRubricStudentPreviewButton); diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/BeginDeliveryActionListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/BeginDeliveryActionListener.java index 53c5b25cd794..b83da46b251e 100755 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/BeginDeliveryActionListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/BeginDeliveryActionListener.java @@ -103,7 +103,7 @@ public void processAction(ActionEvent ae) throws // e.g. take assessment via url, actionString is set by LoginServlet. // preview and take assessment is set by the parameter in the jsp pages delivery.setActionString(actionString); - if("reviewAssessment".equals(actionString)){ + if ("reviewAssessment".equals(actionString) || "takeAssessment".equals(actionString)) { delivery.setRbcsToken(rubricsService.generateJsonWebToken(RubricsConstants.RBCS_TOOL_SAMIGO)); } } diff --git a/samigo/samigo-app/src/webapp/jsf/delivery/beginTakingAssessment.jsp b/samigo/samigo-app/src/webapp/jsf/delivery/beginTakingAssessment.jsp index ca128966b2fb..95a80adeebc1 100755 --- a/samigo/samigo-app/src/webapp/jsf/delivery/beginTakingAssessment.jsp +++ b/samigo/samigo-app/src/webapp/jsf/delivery/beginTakingAssessment.jsp @@ -73,6 +73,7 @@ <%@ include file="/jsf/delivery/assessment_attachment.jsp" %> +
@@ -194,7 +195,6 @@
- + + +