org.sakaiproject.tool.gradebook
Class GradeMapping

java.lang.Object
  extended by org.sakaiproject.tool.gradebook.GradeMapping
All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
LetterGradeMapping, LetterGradePlusMinusMapping, PassNotPassMapping

public class GradeMapping
extends Object
implements Serializable, Comparable

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

Field Summary
protected  Gradebook gradebook
           
protected  Map<String,Double> gradeMap
           
protected  Long id
           
protected  org.apache.commons.logging.Log log
           
protected  int version
           
 
Constructor Summary
GradeMapping()
           
GradeMapping(GradingScale gradingScale)
           
 
Method Summary
 int compareTo(Object o)
           
 Map<String,Double> getDefaultBottomPercents()
          Backwards-compatible wrapper to get to grading scale.
 List<Double> getDefaultValues()
           
 String getGrade(Double value)
          This algorithm is slow, since it checks each grade option, starting from the "top" (in this case an 'A').
 Gradebook getGradebook()
           
 Map<String,Double> getGradeMap()
           
 Collection<String> getGrades()
           
 GradingScale getGradingScale()
           
 Long getId()
           
 String getName()
           
 Double getValue(String grade)
          Gets the percentage mapped to a particular grade.
 int getVersion()
           
 void setDefaultValues()
          Sets the percentage values for this GradeMapping to their default values.
 void setGradebook(Gradebook gradebook)
           
 void setGradeMap(Map<String,Double> gradeMap)
           
 void setGradingScale(GradingScale gradingScale)
           
 void setId(Long id)
           
 void setVersion(int version)
           
 String standardizeInputGrade(String inputGrade)
          Enable any-case input of grades (typically lowercase input for uppercase grades).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

id

protected Long id

version

protected int version

gradebook

protected Gradebook gradebook

gradeMap

protected Map<String,Double> gradeMap
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

public List<Double> getDefaultValues()
Returns:
A List of the default grade values. Only used for backward compatibility to pre-grading-scale mappings.

getValue

public Double getValue(String grade)
Gets the percentage mapped to a particular grade.


getGrade

public String getGrade(Double value)
This algorithm is slow, since it checks each grade option, starting from the "top" (in this case an 'A'). We can make it faster by starting in the middle (as in a bubble sort), but since there are so few grade options, I think I'll leave it for now.

See Also:
getGrade(Double)

getId

public Long getId()
Returns:
Returns the id.

setId

public void setId(Long id)
Parameters:
id - The id to set.

getVersion

public int getVersion()
Returns:
Returns the version.

setVersion

public void setVersion(int version)
Parameters:
version - The version to set.

getGradeMap

public Map<String,Double> getGradeMap()
Returns:
Returns the gradeMap.

setGradeMap

public void setGradeMap(Map<String,Double> gradeMap)
Parameters:
gradeMap - The gradeMap to set.

getGradebook

public Gradebook getGradebook()
Returns:
Returns the gradebook.

setGradebook

public void setGradebook(Gradebook gradebook)
Parameters:
gradebook - The gradebook to set.

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class 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)


Copyright © 2011 Sakai Project. All Rights Reserved.