Skip to content

Commit

Permalink
SAK-33999 display maximum possible points (sakaiproject#6140)
Browse files Browse the repository at this point in the history
* #3432 Make sure mapped grades are not null when they are collected.

Mapped grades will be null if the student doesn't have a course grade yet.

* Changed display of ungraded work to include maximum possible points

Always display the maximum possible points, no longer dependent on there being a grade.
Added a helper method to format an empty grade to instead return a dash.
Bonus code improvements thanks to my preferences file.

Issue: SAK-33999

* SAK-33999 Removed preferences file changes

* SAK-33999 Simplified helper method for empty grade display
  • Loading branch information
amiedavis authored and steveswinsburg committed Oct 16, 2018
1 parent 40415d3 commit 6b3b233
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ public static String formatGradeForDisplay(final String grade) {
return StringUtils.removeEnd(s, ".0");
}

/**
* Convert an empty grade to a dash for display purposes
*
* @param grade
* @return a dash if the grade is empty, the original grade if not
*/
public static String convertEmptyGradeToDash(final String grade) {
return StringUtils.defaultIfBlank(grade, " - ");
}

/**
* Format a grade using the locale
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.sakaiproject.gradebookng.tool.model.GradebookUiSettings;
import org.sakaiproject.gradebookng.tool.pages.BasePage;
import org.sakaiproject.gradebookng.tool.pages.GradebookPage;
import org.sakaiproject.rubrics.logic.model.ToolItemRubricAssociation;
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.GradingType;
Expand Down Expand Up @@ -284,27 +284,24 @@ public boolean isVisible() {
rubricIcon.setVisible(false);
gradeScore.add(rubricIcon);
} else {
gradeScore.add(new Label("grade", FormatHelper.formatGradeForDisplay(rawGrade)));
gradeScore.add(
new Label("grade", FormatHelper.convertEmptyGradeToDash(FormatHelper.formatGradeForDisplay(rawGrade))));
gradeScore.add(new Label("outOf",
new StringResourceModel("label.studentsummary.outof", null, new Object[] { assignment.getPoints() })) {
new StringResourceModel("label.studentsummary.outof", null, assignment.getPoints())));
final GbAjaxLink rubricIcon = new GbAjaxLink("rubricIcon") {
@Override
public boolean isVisible() {
return StringUtils.isNotBlank(rawGrade);
}
});
GbAjaxLink rubricIcon = new GbAjaxLink("rubricIcon") {
public void onClick(final AjaxRequestTarget target) {
final GbModalWindow window = GradeSummaryTablePanel.this.getRubricStudentWindow();

window.setTitle(new ResourceModel("rubrics.option.graderubric"));
RubricStudentPanel rubricStudentPanel = new RubricStudentPanel(window.getContentId(), null, window);
final RubricStudentPanel rubricStudentPanel = new RubricStudentPanel(window.getContentId(), null, window);
if(assignment.isExternallyMaintained()){//this only works for Assignments atm
rubricStudentPanel.setToolId(RubricsConstants.RBCS_TOOL_ASSIGNMENT);
String[] bits = assignment.getExternalId().split("/");
String assignmentId = bits[bits.length-1];
String submissionId = rubricsService.getRubricEvaluationObjectId(assignmentId, studentUuid, 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)){
this.setVisible(false);
setVisible(false);
}
rubricStudentPanel.setAssignmentId(assignmentId);
rubricStudentPanel.setStudentUuid(submissionId);
Expand All @@ -326,17 +323,17 @@ public void onClick(final AjaxRequestTarget target) {
String assignmentId = assignment.getId().toString();
if(assignment.isExternallyMaintained()){//this only works for Assignments atm
tool = RubricsConstants.RBCS_TOOL_ASSIGNMENT;
String[] bits = assignment.getExternalId().split("/");
final String[] bits = assignment.getExternalId().split("/");
assignmentId = bits[bits.length-1];
}
Optional<ToolItemRubricAssociation> rubricAssociation = rubricsService.getRubricAssociation(tool, assignmentId);
final Optional<ToolItemRubricAssociation> rubricAssociation = GradeSummaryTablePanel.this.rubricsService.getRubricAssociation(tool, assignmentId);
if (rubricAssociation.isPresent()) {
boolean hidePreview = rubricAssociation.get().getParameter("hideStudentPreview") == null ? false : rubricAssociation.get().getParameter("hideStudentPreview");
rubricIcon.setVisible(!hidePreview);
} else {
rubricIcon.setVisible(false);
}
} catch (Exception ex) {
} catch (final Exception ex) {
rubricIcon.setVisible(false);
}
}
Expand Down

0 comments on commit 6b3b233

Please sign in to comment.