Package org.sakaiproject.tool.gradebook
Class GradeMapping
- java.lang.Object
-
- org.sakaiproject.tool.gradebook.GradeMapping
-
- All Implemented Interfaces:
Serializable,Comparable<Object>
- Direct Known Subclasses:
GradePointsMapping,LetterGradeMapping,LetterGradePlusMinusMapping,PassNotPassMapping
public class GradeMapping extends Object implements Serializable, Comparable<Object>
A GradeMapping provides a means to convert between an arbitrary set of grades (letter grades, pass / not pass, 4,0 scale) and numeric percentages.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GradeMapping()GradeMapping(GradingScale gradingScale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(Object o)booleanequals(Object o)Map<String,Double>getDefaultBottomPercents()Backwards-compatible wrapper to get to grading scale.List<Double>getDefaultValues()Deprecated.GradebookgetGradebook()Map<String,Double>getGradeMap()Collection<String>getGrades()GradingScalegetGradingScale()LonggetId()StringgetMappedGrade(Double value)Get the mapped grade based on the persistent grade mappingsstatic StringgetMappedGrade(Map<String,Double> gradeMap, Double value)Get the mapped grade based on the passed in grade mappings.StringgetName()DoublegetValue(String grade)Gets the percentage mapped to a particular grade.intgetVersion()inthashCode()voidsetDefaultValues()Sets the percentage values for this GradeMapping to their default values.voidsetGradebook(Gradebook gradebook)voidsetGradeMap(Map<String,Double> gradeMap)voidsetGradingScale(GradingScale gradingScale)voidsetId(Long id)voidsetVersion(int version)static Map<String,Double>sortGradeMapping(Map<String,Double> gradeMap)Handles the sorting of the grade mapping.StringstandardizeInputGrade(String inputGrade)Enable any-case input of grades (typically lowercase input for uppercase grades).StringtoString()
-
-
-
Constructor Detail
-
GradeMapping
public GradeMapping()
-
GradeMapping
public GradeMapping(GradingScale gradingScale)
-
-
Method Detail
-
getName
public String getName()
-
setDefaultValues
public void setDefaultValues()
Sets the percentage values for this GradeMapping to their default values.
-
getDefaultBottomPercents
public Map<String,Double> getDefaultBottomPercents()
Backwards-compatible wrapper to get to grading scale.
-
getGrades
public Collection<String> getGrades()
- Returns:
- An (ordered) collection of the available grade values
-
getDefaultValues
@Deprecated public List<Double> getDefaultValues()
Deprecated.- Returns:
- A List of the default grade values. Only used for backward compatibility to pre-grading-scale mappings.
-
getMappedGrade
public String getMappedGrade(Double value)
Get the mapped grade based on the persistent grade mappings
-
getMappedGrade
public static String getMappedGrade(Map<String,Double> gradeMap, Double value)
Get the mapped grade based on the passed in grade mappings. NOTE: The gradeMap MUST be sorted!
-
sortGradeMapping
public static Map<String,Double> sortGradeMapping(Map<String,Double> gradeMap)
Handles the sorting of the grade mapping.- Parameters:
gradeMap-- Returns:
-
getId
public Long getId()
-
setId
public void setId(Long id)
-
getVersion
public int getVersion()
-
setVersion
public void setVersion(int version)
-
getGradebook
public Gradebook getGradebook()
-
setGradebook
public void setGradebook(Gradebook gradebook)
-
compareTo
public int compareTo(Object o)
- Specified by:
compareToin interfaceComparable<Object>
-
standardizeInputGrade
public String standardizeInputGrade(String inputGrade)
Enable any-case input of grades (typically lowercase input for uppercase grades). Look for a case-insensitive match to the input text and if it's found, return the official version.- Returns:
- The normalized version of the grade, or null if not found.
-
getGradingScale
public GradingScale getGradingScale()
- Returns:
- the GradingScale used to define this mapping, or null if this is an old Gradebook which uses hard-coded scales
-
setGradingScale
public void setGradingScale(GradingScale gradingScale)
-
-