Skip to content

Commit

Permalink
SAK-40310 Adding rubric preview back in for students (sakaiproject#6669)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Mar 19, 2019
1 parent 6622c8d commit f489673
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ $(document).ready(function(){
</div>
#end

<sakai-rubric-student-preview-button
token="$!rbcs-token"
tool-id="sakai.assignment"
entity-id="$assignment.Id"></sakai-rubric-student-preview-button>

#if ($submission.Graded && ($submission.GradeReleased || $returned))
<sakai-rubric-student
token="$!rbcs-token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<a href="javascript:void(0);" class="gb-summary-collapse-all" wicket:id="collapseCategoriesLink" aria-controls="gradeSummaryTable"><wicket:message key="label.studentsummary.collapseall"></wicket:message></a>
</div>

<div wicket:id="rubricStudentWindow" />

<table id="gradeSummaryTable" class="table table-bordered table-striped table-hover table-condensed">
<caption class="sr-only"><wicket:message key="studentsummary.caption"/></caption>
<thead>
Expand Down Expand Up @@ -58,7 +56,9 @@
<td class="gb-summary-grade-score" wicket:id="gradeScore">
<span class="gb-summary-grade-score-raw" wicket:id="grade" wicket:message="aria-label:studentsummary.gradebookitem.score"></span>
<span class="gb-summary-grade-score-outof" wicket:id="outOf" wicket:message="aria-label:studentsummary.gradebookitem.outof"></span>
<span class="gb-summary-grade-score-rubric fa fa-fw fa-table" wicket:id="rubricIcon"></span>
<span style="float: right;">
<sakai-rubric-student-preview-button wicket:id="sakai-rubric-student-preview-button"></sakai-rubric-student-preview-button>
</span>
</td>
<td wicket:id="weight"><!-- empty --></td>
<td class="gb-summary-grade-duedate" wicket:id="dueDate"></td>
Expand All @@ -77,4 +77,4 @@
</wicket:panel>

</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,8 +51,6 @@ public class GradeSummaryTablePanel extends BasePanel {

private static final long serialVersionUID = 1L;

private GbModalWindow rubricStudentWindow;

private boolean isGroupedByCategory;
private boolean assignmentStatsEnabled;

Expand Down Expand Up @@ -91,8 +88,7 @@ public void onBeforeRender() {
final String studentUuid = (String) data.get("studentUuid");
this.isGroupedByCategory = (boolean) data.get("isGroupedByCategory");
final Map<String, CategoryDefinition> categoriesMap = (Map<String, CategoryDefinition>) data.get("categoriesMap");
final ModalWindow assignmentStatsWindow = new ModalWindow(
"assignmentStatsWindow");
final ModalWindow assignmentStatsWindow = new ModalWindow("assignmentStatsWindow");
add(assignmentStatsWindow);

if (getPage() instanceof GradebookPage) {
Expand All @@ -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);

Expand Down Expand Up @@ -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<ToolItemRubricAssociation> 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"));
Expand All @@ -408,7 +363,6 @@ public void onClick(final AjaxRequestTarget target) {
});
}
});

}

private final class DropInfoPair {
Expand All @@ -430,7 +384,4 @@ private DropInfoPair getDropInfo(final String categoryName, final Map<String, Ca

return pair;
}
public GbModalWindow getRubricStudentWindow() {
return this.rubricStudentWindow;
}
}
3 changes: 0 additions & 3 deletions gradebookng/tool/src/webapp/styles/gradebook-shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@
.btn-table {
height: 34px;
}
.gb-summary-grade-score-rubric {
cursor: pointer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<h:graphicImage url="/images/silk/date_delete.png" title="#{msgs.forum_restricted_message}" alt="#{msgs.forum_restricted_message}" rendered="#{ForumTool.selectedForum.forum.availability == 'false'}" style="margin-right:.5em"/>
<h:graphicImage url="/images/silk/lock.png" alt="#{msgs.cdfm_forum_locked}" rendered="#{ForumTool.selectedForum.forum.locked == 'true'}" style="margin-right:.5em"/>
<%-- Rubrics marker --%>
<h:panel rendered="#{ForumTool.selectedForum.hasRubric == 'true'}">
<sakai-rubric-student-preview-button
display="icon"
token="<h:outputText value="#{ForumTool.rbcsToken}" />"
tool-id="sakai.forums"
entity-id="<h:outputText value="top.#{ForumTool.selectedTopic.topic.id}" />">
</sakai-rubric-student-preview-button>
</h:panel>
<h:outputText styleClass="fa fa-table" id="rubrics-forum-icon" rendered="#{ForumTool.selectedForum.hasRubric == 'true'}" style="margin-right:.5em" title="#{msgs.cdfm_forum_rubric}"/>
<h:outputText value="#{ForumTool.selectedForum.forum.title}" styleClass="title"/>
<h:outputText value=" " styleClass="actionLinks"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@
<h:graphicImage url="/images/silk/date_delete.png" title="#{msgs.topic_restricted_message}" alt="#{msgs.topic_restricted_message}" rendered="#{ForumTool.selectedTopic.topic.availability == 'false'}" style="margin-right:.5em"/>
<h:graphicImage url="/images/silk/lock.png" alt="#{msgs.cdfm_forum_locked}" rendered="#{ForumTool.selectedForum.forum.locked == 'true' || ForumTool.selectedTopic.topic.locked == 'true'}" style="margin-right:.5em"/>
<%-- Rubrics marker --%>
<h:outputText styleClass="fa fa-table" id="rubrics-forum-icon" rendered="#{ForumTool.selectedTopic.hasRubric == 'true'}" style="margin-right:.5em" title="#{msgs.cdfm_forum_rubric}"/>
<h:panelGroup rendered="#{ForumTool.selectedForum.hasRubric == 'true'}" >
<sakai-rubric-student-preview-button
token="<h:outputText value="#{ForumTool.rbcsToken}" />"
display="icon"
tool-id="sakai.forums"
entity-id="<h:outputText value="top.#{ForumTool.selectedTopic.topic.id}" />">
</sakai-rubric-student-preview-button>
</h:panelGroup>
<h:outputText value="#{ForumTool.selectedTopic.topic.title}" styleClass="title"/>

<h:outputText id="topic_moderated" value=" #{msgs.cdfm_forum_moderated_flag}" styleClass="childrenNewZero" rendered="#{ForumTool.selectedTopic.moderated == 'true' }" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<script type="module" src="/rubrics-service/webcomponents/sakai-rubric-student.js$!{portalCDNQuery}"></script>
<script type="module" src="/rubrics-service/webcomponents/sakai-rubric-grading.js$!{portalCDNQuery}"></script>
<script type="module" src="/rubrics-service/webcomponents/sakai-rubric-association.js$!{portalCDNQuery}"></script>
<script type="module" src="/rubrics-service/webcomponents/sakai-rubric-student-preview-button.js$!{portalCDNQuery}"></script>

#if ( $tutorial && $loggedIn )
<script>$(document).ready(function(){startTutorial({'showTutorialLocationOnHide': 'true'});});</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -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`<h3><sr-lang key="grading_rubric" /></h3>
<button onclick="rubrics.previewRubric('${this.rubricId}'); return false;"><sr-lang key="preview_rubric" /></button>`
: html`<span class="fa fa-table" style="cursor: pointer;" title="${tr("preview_rubric")}" onclick="rubrics.previewRubric('${this.rubricId}')" />`
}
`;
}

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);
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<!-- ASSESSMENT ATTACHMENTS -->
<%@ include file="/jsf/delivery/assessment_attachment.jsp" %>


<div class="tier2">
<h:panelGrid columns="1" border="0">
<!-- Due Message -->
Expand Down Expand Up @@ -194,7 +195,6 @@
</h:panelGroup>
<h:outputText id="honorPledgeRequired" value="#{deliveryMessages.honor_required}" styleClass="alertMessage" style="display:none"/>


<p class="act">

<!-- BEGIN ASSESSMENT BUTTON -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ document.links[newindex].onclick();
</sakai-rubric-student>
</h:panelGroup>

<h:panelGroup rendered="#{delivery.actionString == 'takeAssessment'}">
<sakai-rubric-student-preview-button
token="<h:outputText value="#{delivery.rbcsToken}" />"
tool-id="sakai.samigo"
entity-id="<h:outputText value="pub.#{delivery.assessmentId}.#{question.itemData.itemId}" />"></sakai-rubric-student-preview-button>
</h:panelGroup>

<div class="samigo-question-callout">
<h:panelGroup rendered="#{question.itemData.typeId == 7}">
<f:subview id="deliverAudioRecording">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ should be included in file importing DeliveryMessages
**********************************************************************************/
--%>
-->

<h:outputText value="#{question.text}" escape="false"/>

<!-- ATTACHMENTS -->
Expand Down Expand Up @@ -68,6 +69,7 @@ should be included in file importing DeliveryMessages

<f:verbatim><br /></f:verbatim>


<h:panelGroup rendered="#{delivery.feedback eq 'true'}">
<h:panelGrid rendered="#{delivery.feedbackComponent.showCorrectResponse && !delivery.noFeedback=='true'&& question.modelAnswerIsNotEmpty}" >
<h:panelGroup>
Expand Down

0 comments on commit f489673

Please sign in to comment.