Skip to content

Commit

Permalink
#3431 remove final grade mode (sakaiproject#4095)
Browse files Browse the repository at this point in the history
* Remove unused code and cleanup other compiler warnings

* #3431 move instructions about the course grade display to be after the options

* #3431 remove final grade mode
  • Loading branch information
steveswinsburg authored Mar 18, 2017
1 parent 7a7f031 commit 85ca404
Show file tree
Hide file tree
Showing 27 changed files with 60 additions and 312 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4701,11 +4701,6 @@
#Max size in bytes for all the files to zip - Default 0 bytes
#content.zip.download.maxtotalsize=0

# Gradebook final grade mode
# Enables the option in settings
# DEFAULT: false
#gradebook.enable.finalgrade=false

# Run the seed sites automatically on startup, this is mainly for the demo setup
# DEFAULT: false
#quartz.seedsites.autorun=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ public class GradebookInformation implements Serializable {
*/
private boolean courseAverageDisplayed;

/**
* If the gradebook has the 'final grade mode' enabled
*/
private boolean finalGradeMode;


public String getSelectedGradingScaleUid() {
return selectedGradingScaleUid;
}
Expand Down Expand Up @@ -165,12 +159,6 @@ public boolean isCourseAverageDisplayed() {
public void setCourseAverageDisplayed(boolean courseAverageDisplayed) {
this.courseAverageDisplayed = courseAverageDisplayed;
}
public boolean isFinalGradeMode() {
return finalGradeMode;
}
public void setFinalGradeMode(boolean finalGradeMode) {
this.finalGradeMode = finalGradeMode;
}

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public enum PointsPossibleValidation {
/**
* Array of chars that are not allowed in a gb item title
*/
public static final char[] INVALID_CHARS_IN_GB_ITEM_NAME = {'*', '#', '[', ']', '$'};
public static final char[] INVALID_CHARS_IN_GB_ITEM_NAME = {'*', '#', '[', ']'};

/**
* Comparator to ensure correct ordering of letter grades, catering for + and - in the grade
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,5 @@

<property name="courseLetterGradeDisplayed" column="COURSE_LETTER_GRADE_DISPLAYED" type="boolean" not-null="true"/>

<property name="finalGradeMode" column="FINAL_GRADE_MODE" type="boolean" not-null="true"/>

</class>
</hibernate-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

package org.sakaiproject.tool.gradebook;

import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
import java.util.Comparator;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import java.io.Serializable;
import java.util.Comparator;
import lombok.extern.slf4j.Slf4j;

/**
* A GradableObject is a component of a Gradebook for which students can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public class Gradebook implements Serializable {
private Boolean showRank;
private Boolean showItemStatistics;
private Boolean showStatisticsChart;
private boolean finalGradeMode;

/**
* Default no-arg constructor needed for persistence
Expand Down Expand Up @@ -384,14 +383,6 @@ public boolean isCourseLetterGradeDisplayed() {
public void setCourseLetterGradeDisplayed(boolean courseLetterGradeDisplayed) {
this.courseLetterGradeDisplayed = courseLetterGradeDisplayed;
}

public boolean isFinalGradeMode() {
return finalGradeMode;
}

public void setFinalGradeMode(boolean finalGradeMode) {
this.finalGradeMode = finalGradeMode;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,7 @@ public GradebookInformation getGradebookInformation(String gradebookUid) {
rval.setCourseLetterGradeDisplayed(gradebook.isCourseLetterGradeDisplayed());
rval.setCoursePointsDisplayed(gradebook.isCoursePointsDisplayed());
rval.setCourseAverageDisplayed(gradebook.isCourseAverageDisplayed());

rval.setFinalGradeMode(gradebook.isFinalGradeMode());


return rval;
}

Expand Down Expand Up @@ -3285,15 +3283,12 @@ public void updateGradebookSettings(String gradebookUid, GradebookInformation gb
Map<String,Double> bottomPercents = gbInfo.getSelectedGradingScaleBottomPercents();

//Before we do any work, check if any existing course grade overrides might be left in an unmappable state
// this is NOT done when in final grade mode as the course grade field is now arbitrary.
if(!gbInfo.isFinalGradeMode()) {
List<CourseGradeRecord> courseGradeOverrides = getHibernateTemplate().execute(session -> getCourseGradeOverrides(gradebook));
courseGradeOverrides.forEach(cgr -> {
if(!bottomPercents.containsKey(cgr.getEnteredGrade())) {
throw new UnmappableCourseGradeOverrideException("The grading schema could not be updated as it would leave some course grade overrides in an unmappable state.");
}
});
}
List<CourseGradeRecord> courseGradeOverrides = getHibernateTemplate().execute(session -> getCourseGradeOverrides(gradebook));
courseGradeOverrides.forEach(cgr -> {
if(!bottomPercents.containsKey(cgr.getEnteredGrade())) {
throw new UnmappableCourseGradeOverrideException("The grading schema could not be updated as it would leave some course grade overrides in an unmappable state.");
}
});

//iterate all available grademappings for this gradebook and set the one that we have the ID and bottomPercents for
Set<GradeMapping> gradeMappings = gradebook.getGradeMappings();
Expand All @@ -3320,9 +3315,7 @@ public void updateGradebookSettings(String gradebookUid, GradebookInformation gb
gradebook.setCourseLetterGradeDisplayed(gbInfo.isCourseLetterGradeDisplayed());
gradebook.setCoursePointsDisplayed(gbInfo.isCoursePointsDisplayed());
gradebook.setCourseAverageDisplayed(gbInfo.isCourseAverageDisplayed());

gradebook.setFinalGradeMode(gbInfo.isFinalGradeMode());


List<CategoryDefinition> newCategoryDefinitions = gbInfo.getCategories();

//if we have categories and they are weighted, check the weightings sum up to 100% (or 1 since it's a fraction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ importExport.instructions.1 = Student ID and Student Name are the first two colu
importExport.instructions.2 = Gradebook Items/Assignments may include points by wrapping the points in [ ] after the title, e.g. "Assignment 1 [50]".
importExport.instructions.3 = Comments can be imported by prefixing the column with a *, e.g. "* Assignment 1".
importExport.instructions.4 = Columns that cannot be re-imported are prefixed with #.
importExport.instructions.finalgrade = Final grades can be imported by prefixing the column with a $

importExport.import.heading = Import
importExport.import.description = Selectively import new grades/gradebook items into the Gradebook by uploading an edited .csv version of your Gradebook below.
Expand All @@ -208,7 +207,6 @@ importExport.selection.title = Title
importExport.selection.points = Points
importExport.selection.status = Status
importExport.selection.noneselected = You must select at least one item.
importExport.selection.coursegradeoverride.found = Course Grade override was found and will automatically be imported


importExport.createItem.heading = New Item Creation ({0} of {1})
Expand All @@ -218,7 +216,6 @@ importExport.confirmation.description = Upon clicking <strong>Finish</strong>, y
importExport.confirmation.update.heading = Updating data for existing Gradebook Item(s):
importExport.confirmation.create.heading = Creating new Gradebook Item(s):
importExport.confirmation.modify.heading = Modifying existing Gradebook Item(s):
importExport.confirmation.coursegradeoverride.heading = Updating Course Grade Overrides

importExport.confirmation.title = Title
importExport.confirmation.points = Points
Expand Down Expand Up @@ -340,9 +337,6 @@ settingspage.gradingschema.heading = Grading Schema
settingspage.gradeentry.instructions = How will graders enter grades into this gradebook?
settingspage.gradeentry.points = Points
settingspage.gradeentry.percentages = Percentages
settingspage.gradeentry.finalgrade.label = Enable final grade mode
settingspage.gradeentry.finalgrade.instructions = Final Grade Mode allows you to use the Course Grade column like a normal gradebook column and enter any score for the student. \
In addition, you will be able to use a special column to import grades directly. You can still optionally add other gradebook items as desired.

settingspage.graderelease.label = Display released Gradebook items to students
settingspage.graderelease.instructions = You can release a Gradebook item when creating or editing the Gradebook item.
Expand Down Expand Up @@ -493,7 +487,6 @@ error.addeditgradeitem.titlecharacters = Gradebook item names cannot contain *,

importExport.error.grade = An error occurred importing a grade. Please check the file.
importExport.error.comment = An error occurred importing a comment. Please check the file.
importExport.error.coursegradeoverride = An error occurred importing the course grade override. Please check the file.
importExport.commentname = + comments
importExport.error.incorrecttype = The file you uploaded was not recognised as a CSV or Excel file.
importExport.error.incorrectformat = The file you uploaded was not formatted correctly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class GradebookNgBusinessService {
public static final String ICON_SAKAI = "icon-sakai--";


private Collator collator = Collator.getInstance();
private final Collator collator = Collator.getInstance();

/**
* Get a list of all users in the current site that can have grades
Expand Down Expand Up @@ -1257,9 +1257,9 @@ private void updateAssignmentCategorizedOrder(final String gradebookId, final Lo
class LastNameComparator implements Comparator<User> {
@Override
public int compare(final User u1, final User u2) {
collator.setStrength(Collator.PRIMARY);
return new CompareToBuilder().append(u1.getLastName(), u2.getLastName(), collator)
.append(u1.getFirstName(), u2.getFirstName(), collator).toComparison();
GradebookNgBusinessService.this.collator.setStrength(Collator.PRIMARY);
return new CompareToBuilder().append(u1.getLastName(), u2.getLastName(), GradebookNgBusinessService.this.collator)
.append(u1.getFirstName(), u2.getFirstName(), GradebookNgBusinessService.this.collator).toComparison();
}
}

Expand All @@ -1270,9 +1270,9 @@ public int compare(final User u1, final User u2) {
class FirstNameComparator implements Comparator<User> {
@Override
public int compare(final User u1, final User u2) {
collator.setStrength(Collator.PRIMARY);
return new CompareToBuilder().append(u1.getFirstName(), u2.getFirstName(), collator)
.append(u1.getLastName(), u2.getLastName(), collator).toComparison();
GradebookNgBusinessService.this.collator.setStrength(Collator.PRIMARY);
return new CompareToBuilder().append(u1.getFirstName(), u2.getFirstName(), GradebookNgBusinessService.this.collator)
.append(u1.getLastName(), u2.getLastName(), GradebookNgBusinessService.this.collator).toComparison();
}
}

Expand Down Expand Up @@ -1986,18 +1986,6 @@ public String getIconClass(final Assignment assignment) {
return iconClass;
}

/**
* Is final grade mode enabled in sakai.properties? To control this set:
* <code>gradebook.enable.finalgrade=true<code> in sakai.properties.
*
* Note that this does not check the actual setting for <em>this</em> gradebook.
*
* @return true or false if enabled or not
*/
public boolean isFinalGradeModeEnabled() {
return this.serverConfigurationService.getBoolean("gradebook.enable.finalgrade", false);
}


/**
* Comparator class for sorting an assignment by the grades.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ImportedColumn implements Serializable {
public enum Type {
GB_ITEM_WITH_POINTS,
GB_ITEM_WITHOUT_POINTS,
COURSE_GRADE_OVERRIDE,
COMMENTS,
USER_ID,
USER_NAME,
Expand Down Expand Up @@ -74,17 +73,6 @@ public boolean isComment() {
return false;
}

/**
* Helper to determine if the type of column is a course grade override column - purely for convenience
* @return
*/
public boolean isCourseGradeOverride() {
if(this.type == Type.COURSE_GRADE_OVERRIDE) {
return true;
}
return false;
}

/**
* Column titles are the only thing we care about for comparisons so that we can filter out duplicates.
* Must also match type and exclude IGNORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public enum Type {
/**
* Comments attached to a gradebook item
*/
COMMENT,

/**
* If a course grade override is specified
*/
COURSE_GRADE_OVERRIDE
COMMENT
}

public enum Status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,29 @@ private String build(final CourseGrade courseGrade) {

// percentage
// not shown in final grade mode
if(!this.gradebook.isFinalGradeMode()) {
final String calculatedGrade;
if (this.showOverride && StringUtils.isNotBlank(courseGrade.getEnteredGrade())) {

// if mapping doesn't exist for this grade override (mapping may have been changed!), map it to 0.
// TODO this should probably inform the instructor
Double mappedGrade = this.gradebook.getSelectedGradeMapping().getGradeMap().get(courseGrade.getEnteredGrade());
if(mappedGrade == null) {
mappedGrade = new Double(0);
}
calculatedGrade = FormatHelper.formatDoubleAsPercentage(mappedGrade);
final String calculatedGrade;
if (this.showOverride && StringUtils.isNotBlank(courseGrade.getEnteredGrade())) {

} else {
calculatedGrade = FormatHelper.formatStringAsPercentage(courseGrade.getCalculatedGrade());
// if mapping doesn't exist for this grade override (mapping may have been changed!), map it to 0.
// TODO this should probably inform the instructor
Double mappedGrade = this.gradebook.getSelectedGradeMapping().getGradeMap().get(courseGrade.getEnteredGrade());
if(mappedGrade == null) {
mappedGrade = new Double(0);
}
calculatedGrade = FormatHelper.formatDoubleAsPercentage(mappedGrade);

if (StringUtils.isNotBlank(calculatedGrade)
&& (this.gradebook.isCourseAverageDisplayed() || this.currentUserRole == GbRole.INSTRUCTOR)) {
if (parts.isEmpty()) {
parts.add(new StringResourceModel("coursegrade.display.percentage-first", null,
new Object[] { calculatedGrade }).getString());
} else {
parts.add(new StringResourceModel("coursegrade.display.percentage-second", null,
new Object[] { calculatedGrade }).getString());
}
} else {
calculatedGrade = FormatHelper.formatStringAsPercentage(courseGrade.getCalculatedGrade());
}

if (StringUtils.isNotBlank(calculatedGrade)
&& (this.gradebook.isCourseAverageDisplayed() || this.currentUserRole == GbRole.INSTRUCTOR)) {
if (parts.isEmpty()) {
parts.add(new StringResourceModel("coursegrade.display.percentage-first", null,
new Object[] { calculatedGrade }).getString());
} else {
parts.add(new StringResourceModel("coursegrade.display.percentage-second", null,
new Object[] { calculatedGrade }).getString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class ImportGradesHelper {
final static Pattern STANDARD_HEADER_PATTERN = Pattern.compile("([^\\*\\#\\$\\[\\]\\*]+)");
final static Pattern POINTS_PATTERN = Pattern.compile("(\\d+)(?=]$)");
final static Pattern IGNORE_PATTERN = Pattern.compile("(\\#.+)");
final static Pattern COURSE_GRADE_OVERRIDE_PATTERN = Pattern.compile("(\\$.+)");

// list of mimetypes for each category. Must be compatible with the parser
private static final String[] XLS_MIME_TYPES = { "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" };
Expand Down Expand Up @@ -247,10 +246,6 @@ private static ImportedRow mapLine(final String[] line, final Map<Integer, Impor
cell.setComment(lineVal);
row.getCellMap().put(columnTitle, cell);
break;
case COURSE_GRADE_OVERRIDE:
cell.setScore(lineVal);
row.getCellMap().put(columnTitle, cell);
break;
case IGNORE:
// do nothing
break;
Expand Down Expand Up @@ -320,9 +315,6 @@ public static List<ProcessedGradeItem> processImportedGrades(final ImportedSprea
processedGradeItem.setType(ProcessedGradeItem.Type.COMMENT);
commentColumns.add(columnTitle);
break;
case COURSE_GRADE_OVERRIDE:
processedGradeItem.setType(ProcessedGradeItem.Type.COURSE_GRADE_OVERRIDE);
break;
case GB_ITEM_WITHOUT_POINTS:
processedGradeItem.setType(ProcessedGradeItem.Type.GB_ITEM);
break;
Expand Down Expand Up @@ -415,10 +407,6 @@ private static Status determineStatus(final ImportedColumn column, final Assignm
}
}

if(column.isCourseGradeOverride()) {
status = Status.UPDATE;
}

// for grade items, only need to check if we dont already have a status, as grade items are always imported for NEW and MODIFIED items
// for comments we always check unless external as we might have a NEW item but with no data which means SKIP
if((column.isGradeItem() && status == null) || (column.isComment() && status != Status.EXTERNAL)) {
Expand Down Expand Up @@ -617,22 +605,9 @@ private static ImportedColumn parseHeaderToColumn(final String headerValue) thro
return column;
}

final Matcher m4 = COURSE_GRADE_OVERRIDE_PATTERN.matcher(headerValue);
final Matcher m4 = STANDARD_HEADER_PATTERN.matcher(headerValue);
if (m4.matches()) {

// extract title
final Matcher titleMatcher = STANDARD_HEADER_PATTERN.matcher(headerValue);

if (titleMatcher.find()) {
column.setColumnTitle(trim(titleMatcher.group()));
}
column.setType(ImportedColumn.Type.COURSE_GRADE_OVERRIDE);
return column;
}

final Matcher m5 = STANDARD_HEADER_PATTERN.matcher(headerValue);
if (m5.matches()) {

column.setColumnTitle(headerValue);
column.setType(ImportedColumn.Type.GB_ITEM_WITHOUT_POINTS);

Expand Down
Loading

0 comments on commit 85ca404

Please sign in to comment.