Skip to content

Commit

Permalink
SAK-34013 add course grade chart to course grade dropdown (sakaiproje…
Browse files Browse the repository at this point in the history
…ct#5396)

* SAK-34013 add chart as a modal window to the course grade dropdown
  • Loading branch information
steveswinsburg authored Mar 13, 2018
1 parent 0044d48 commit aac97dd
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ label.statistics.chart.xaxis = Percentage Scored
label.statistics.chart.yaxis = Number of Students
label.statistics.chart.tooltip = {2} score(s) in {1} range

label.statistics.coursegrade.title = Course Grade Statistics
label.statistics.coursegrade.averagegpa = Course Average GPA
label.statistics.coursegrade.average = Average grade
label.statistics.coursegrade.graded = Total graded students
Expand All @@ -523,6 +524,7 @@ label.statistics.coursegrade.deviation = Standard deviation
coursegrade.option.override = Course Grade Override
coursegrade.option.overridelog = Course Grade Override Log
coursegrade.option.setungraded = Set Zero Score For Empty Cells
coursegrade.option.viewcoursegradestatistics = View Course Grade Statistics
coursegrade.header.menulabel = Open menu for Course Grade column
coursegrade.cell.menulabel = Open menu for Course Grade cell

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.wicket.model.Model;
import org.sakaiproject.gradebookng.tool.model.GbModalWindow;
import org.sakaiproject.gradebookng.tool.pages.GradebookPage;
import org.sakaiproject.gradebookng.tool.panels.GradeStatisticsPanel;
import org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel;

import java.io.Serializable;

Expand All @@ -36,9 +36,9 @@ public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget
final String assignmentId = params.get("assignmentId").asText();

final GradebookPage gradebookPage = (GradebookPage) target.getPage();
final GbModalWindow window = gradebookPage.getGradeStatisticsWindow();
final GbModalWindow window = gradebookPage.getAssignmentStatisticsWindow();
window.setAssignmentToReturnFocusTo(assignmentId);
window.setContent(new GradeStatisticsPanel(window.getContentId(),
window.setContent(new AssignmentStatisticsPanel(window.getContentId(),
Model.of(Long.valueOf(assignmentId)),
window));
window.show(target);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2003-2018 The Apereo Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/ecl2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.gradebookng.tool.actions;

import java.io.Serializable;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.Model;
import org.sakaiproject.gradebookng.tool.model.GbModalWindow;
import org.sakaiproject.gradebookng.tool.pages.GradebookPage;
import org.sakaiproject.gradebookng.tool.panels.CourseGradeStatisticsPanel;

import com.fasterxml.jackson.databind.JsonNode;

public class ViewCourseGradeStatisticsAction extends InjectableAction implements Serializable {

private static final long serialVersionUID = 1L;

public ViewCourseGradeStatisticsAction() {
}

@Override
public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) {

final String siteId = params.get("siteId").asText();

final GradebookPage gradebookPage = (GradebookPage) target.getPage();
final GbModalWindow window = gradebookPage.getGradeLogWindow();

window.setContent(new CourseGradeStatisticsPanel(window.getContentId(), Model.of(siteId), window));
window.show(target);

return new EmptyOkResponse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ private String toJson(final Map<String, Double> schema) {
@Override
public void renderHead(final IHeaderResponse response) {
final String version = ServerConfigurationService.getString("portal.cdn.version", "");

// chart requires ChartJS
response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/chartjs/2.7.0/Chart.min.js?version=%s", version)));

// our chart functions
response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-coursegrade-chart.js?version=%s", version)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</a>
</li>
{/if}
<li><a href="javascript:void(0);" class="gb-view-course-grade-statistics" role="menuitem"><wicket:message key="coursegrade.option.viewcoursegradestatistics" /></a></li>
</ul>
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<div wicket:id="gradeStatisticsWindow" />
<div wicket:id="updateCourseGradeDisplayWindow" />
<div wicket:id="sortGradeItemsWindow" />
<div wicket:id="courseGradeStatisticsWindow" />

<div wicket:id="toolbar" id="gradebookGradesToolbar" class="btn-toolbar">
<ul class="gb-toolbar-left">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -59,6 +60,7 @@
import org.sakaiproject.gradebookng.tool.actions.ToggleCourseGradePoints;
import org.sakaiproject.gradebookng.tool.actions.ViewAssignmentStatisticsAction;
import org.sakaiproject.gradebookng.tool.actions.ViewCourseGradeLogAction;
import org.sakaiproject.gradebookng.tool.actions.ViewCourseGradeStatisticsAction;
import org.sakaiproject.gradebookng.tool.actions.ViewGradeLogAction;
import org.sakaiproject.gradebookng.tool.actions.ViewGradeSummaryAction;
import org.sakaiproject.gradebookng.tool.component.GbAjaxButton;
Expand Down Expand Up @@ -98,9 +100,10 @@ public class GradebookPage extends BasePage {
GbModalWindow gradeLogWindow;
GbModalWindow gradeCommentWindow;
GbModalWindow deleteItemWindow;
GbModalWindow gradeStatisticsWindow;
GbModalWindow assignmentStatisticsWindow;
GbModalWindow updateCourseGradeDisplayWindow;
GbModalWindow sortGradeItemsWindow;
GbModalWindow courseGradeStatisticsWindow;

Label liveGradingFeedback;
boolean hasAssignmentsAndGrades;
Expand Down Expand Up @@ -147,8 +150,8 @@ public GradebookPage() {
this.form = new Form<>("form");
add(this.form);

form.add(new AttributeModifier("data-siteid", businessService.getCurrentSiteId()));
form.add(new AttributeModifier("data-gradestimestamp", new Date().getTime()));
this.form.add(new AttributeModifier("data-siteid", this.businessService.getCurrentSiteId()));
this.form.add(new AttributeModifier("data-gradestimestamp", new Date().getTime()));

/**
* Note that SEMI_TRANSPARENT has a 100% black background and TRANSPARENT is overridden to 10% opacity
Expand Down Expand Up @@ -178,13 +181,17 @@ public GradebookPage() {
this.deleteItemWindow = new GbModalWindow("deleteItemWindow");
this.form.add(this.deleteItemWindow);

this.gradeStatisticsWindow = new GbModalWindow("gradeStatisticsWindow");
this.gradeStatisticsWindow.setPositionAtTop(true);
this.form.add(this.gradeStatisticsWindow);
this.assignmentStatisticsWindow = new GbModalWindow("gradeStatisticsWindow");
this.assignmentStatisticsWindow.setPositionAtTop(true);
this.form.add(this.assignmentStatisticsWindow);

this.updateCourseGradeDisplayWindow = new GbModalWindow("updateCourseGradeDisplayWindow");
this.form.add(this.updateCourseGradeDisplayWindow);

this.courseGradeStatisticsWindow = new GbModalWindow("courseGradeStatisticsWindow");
this.courseGradeStatisticsWindow.setPositionAtTop(true);
this.form.add(this.courseGradeStatisticsWindow);

final GbAjaxButton addGradeItem = new GbAjaxButton("addGradeItem") {
@Override
public void onSubmit(final AjaxRequestTarget target, final Form form) {
Expand Down Expand Up @@ -220,7 +227,7 @@ public boolean isVisible() {
final List<Assignment> assignments = this.businessService.getGradebookAssignments(sortBy);
final List<String> students = this.businessService.getGradeableUsers();

hasAssignmentsAndGrades = !assignments.isEmpty() && !students.isEmpty();
this.hasAssignmentsAndGrades = !assignments.isEmpty() && !students.isEmpty();

// categories enabled?
final boolean categoriesEnabled = this.businessService.categoriesAreEnabled();
Expand All @@ -243,31 +250,33 @@ public boolean isVisible() {
final WebMarkupContainer toggleGradeItemsToolbarItem = new WebMarkupContainer("toggleGradeItemsToolbarItem");
toolbar.add(toggleGradeItemsToolbarItem);

gradeTable = new GbGradeTable("gradeTable",
this.gradeTable = new GbGradeTable("gradeTable",
new LoadableDetachableModel() {
@Override
public GbGradeTableData load() {
return new GbGradeTableData(businessService, settings);
return new GbGradeTableData(GradebookPage.this.businessService, settings);
}
});
gradeTable.addEventListener("setScore", new GradeUpdateAction());
gradeTable.addEventListener("viewLog", new ViewGradeLogAction());
gradeTable.addEventListener("editAssignment", new EditAssignmentAction());
gradeTable.addEventListener("viewStatistics", new ViewAssignmentStatisticsAction());
gradeTable.addEventListener("overrideCourseGrade", new OverrideCourseGradeAction());
gradeTable.addEventListener("editComment", new EditCommentAction());
gradeTable.addEventListener("viewGradeSummary", new ViewGradeSummaryAction());
gradeTable.addEventListener("setZeroScore", new SetZeroScoreAction());
gradeTable.addEventListener("viewCourseGradeLog", new ViewCourseGradeLogAction());
gradeTable.addEventListener("deleteAssignment", new DeleteAssignmentAction());
gradeTable.addEventListener("setUngraded", new SetScoreForUngradedAction());
gradeTable.addEventListener("setStudentNameOrder", new SetStudentNameOrderAction());
gradeTable.addEventListener("toggleCourseGradePoints", new ToggleCourseGradePoints());
gradeTable.addEventListener("editSettings", new EditSettingsAction());
gradeTable.addEventListener("moveAssignmentLeft", new MoveAssignmentLeftAction());
gradeTable.addEventListener("moveAssignmentRight", new MoveAssignmentRightAction());

this.form.add(gradeTable);
this.gradeTable.addEventListener("setScore", new GradeUpdateAction());
this.gradeTable.addEventListener("viewLog", new ViewGradeLogAction());
this.gradeTable.addEventListener("editAssignment", new EditAssignmentAction());
this.gradeTable.addEventListener("viewStatistics", new ViewAssignmentStatisticsAction());
this.gradeTable.addEventListener("overrideCourseGrade", new OverrideCourseGradeAction());
this.gradeTable.addEventListener("editComment", new EditCommentAction());
this.gradeTable.addEventListener("viewGradeSummary", new ViewGradeSummaryAction());
this.gradeTable.addEventListener("setZeroScore", new SetZeroScoreAction());
this.gradeTable.addEventListener("viewCourseGradeLog", new ViewCourseGradeLogAction());
this.gradeTable.addEventListener("deleteAssignment", new DeleteAssignmentAction());
this.gradeTable.addEventListener("setUngraded", new SetScoreForUngradedAction());
this.gradeTable.addEventListener("setStudentNameOrder", new SetStudentNameOrderAction());
this.gradeTable.addEventListener("toggleCourseGradePoints", new ToggleCourseGradePoints());
this.gradeTable.addEventListener("editSettings", new EditSettingsAction());
this.gradeTable.addEventListener("moveAssignmentLeft", new MoveAssignmentLeftAction());
this.gradeTable.addEventListener("moveAssignmentRight", new MoveAssignmentRightAction());
this.gradeTable.addEventListener("viewCourseGradeStatistics", new ViewCourseGradeStatisticsAction());


this.form.add(this.gradeTable);

final Button toggleCategoriesToolbarItem = new Button("toggleCategoriesToolbarItem") {
@Override
Expand Down Expand Up @@ -297,10 +306,10 @@ public boolean isVisible() {

final GbAjaxLink sortGradeItemsToolbarItem = new GbAjaxLink("sortGradeItemsToolbarItem") {
@Override
public void onClick(AjaxRequestTarget target) {
GbModalWindow window = GradebookPage.this.getSortGradeItemsWindow();
public void onClick(final AjaxRequestTarget target) {
final GbModalWindow window = GradebookPage.this.getSortGradeItemsWindow();

Map<String, Object> model = new HashMap<>();
final Map<String, Object> model = new HashMap<>();
model.put("categoriesEnabled", categoriesEnabled);
model.put("settings", settings);

Expand Down Expand Up @@ -400,7 +409,7 @@ protected void onUpdate(final AjaxRequestTarget target) {
groupFilter.setVisible(false);
}

WebMarkupContainer studentFilter = new WebMarkupContainer("studentFilter");
final WebMarkupContainer studentFilter = new WebMarkupContainer("studentFilter");
studentFilter.setVisible(this.hasAssignmentsAndGrades);
toolbar.add(studentFilter);

Expand All @@ -425,7 +434,7 @@ protected void onUpdate(final AjaxRequestTarget target) {
toolbar.setVisible(!assignments.isEmpty());

// Show the table if there are grade items
gradeTable.setVisible(!assignments.isEmpty());
this.gradeTable.setVisible(!assignments.isEmpty());

stopwatch.time("Gradebook page done", stopwatch.getTime());
}
Expand Down Expand Up @@ -459,8 +468,8 @@ public GbModalWindow getDeleteItemWindow() {
return this.deleteItemWindow;
}

public GbModalWindow getGradeStatisticsWindow() {
return this.gradeStatisticsWindow;
public GbModalWindow getAssignmentStatisticsWindow() {
return this.assignmentStatisticsWindow;
}

public GbModalWindow getUpdateCourseGradeDisplayWindow() {
Expand All @@ -471,6 +480,10 @@ public GbModalWindow getSortGradeItemsWindow() {
return this.sortGradeItemsWindow;
}

public GbModalWindow getCourseGradeStatisticsWindow() {
return this.courseGradeStatisticsWindow;
}

/**
* Getter for the GradebookUiSettings. Used to store a few UI related settings for the current session only.
*
Expand Down Expand Up @@ -553,7 +566,7 @@ public void onBeforeRender() {
this.liveGradingFeedback = new Label("liveGradingFeedback", getString("feedback.saved"));
this.liveGradingFeedback.setVisible(this.hasAssignmentsAndGrades);
this.liveGradingFeedback.setOutputMarkupId(true);
liveGradingFeedback.add(DISPLAY_NONE);
this.liveGradingFeedback.add(DISPLAY_NONE);

// add the 'saving...' message to the DOM as the JavaScript will
// need to be the one that displays this message (Wicket will handle
Expand All @@ -564,8 +577,8 @@ public void onBeforeRender() {

public Component updateLiveGradingMessage(final String message) {
this.liveGradingFeedback.setDefaultModel(Model.of(message));
if (liveGradingFeedback.getBehaviors().contains(DISPLAY_NONE)) {
liveGradingFeedback.remove(DISPLAY_NONE);
if (this.liveGradingFeedback.getBehaviors().contains(DISPLAY_NONE)) {
this.liveGradingFeedback.remove(DISPLAY_NONE);
}
return this.liveGradingFeedback;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ public void renderHead(final IHeaderResponse response) {
response.render(
JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js?version=%s", version)));

// chart requires ChartJS
response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/chartjs/2.7.0/Chart.min.js?version=%s", version)));

response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-settings.css?version=%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-settings.js?version=%s", version)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
import org.sakaiproject.service.gradebook.shared.Assignment;
import org.sakaiproject.service.gradebook.shared.GradingType;

public class GradeStatisticsPanel extends BasePanel {
public class AssignmentStatisticsPanel extends BasePanel {

private static final long serialVersionUID = 1L;

private final ModalWindow window;
private final GradingType gradingType;

public GradeStatisticsPanel(final String id, final IModel<Long> model, final ModalWindow window) {
public AssignmentStatisticsPanel(final String id, final IModel<Long> model, final ModalWindow window) {
super(id, model);
this.window = window;
this.gradingType = GradingType.valueOf(this.businessService.getGradebook().getGrade_type());
Expand All @@ -68,7 +68,7 @@ public void onInitialize() {

final Assignment assignment = this.businessService.getAssignment(assignmentId.longValue());

GradeStatisticsPanel.this.window.setTitle(
AssignmentStatisticsPanel.this.window.setTitle(
(new StringResourceModel("label.statistics.title", null,
new Object[] { assignment.getName() }).getString()));

Expand Down Expand Up @@ -200,7 +200,7 @@ public void onInitialize() {

@Override
public void onClick(final AjaxRequestTarget target) {
GradeStatisticsPanel.this.window.close(target);
AssignmentStatisticsPanel.this.window.close(target);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">

<body>
<wicket:panel>

<canvas id="gradingSchemaChart"></canvas>

<div>
<input type="button" class="button_color" wicket:id="done" wicket:message="value:button.done" />
</div>
</wicket:panel>
</body>
</html>
Loading

0 comments on commit aac97dd

Please sign in to comment.