Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
$Id: AssignmentGradeRecord.java 105077 2012-02-24 22:54:29Z ottenhoff@longsight.com $ Copyright (c) 2005, 2006, 2007, 2008 The Sakai Foundation, The MIT Corporation 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://www.opensource.org/licenses/ECL-2.0 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.tool.gradebook;
 
 
An AssignmentGradeRecord is a grade record that can be associated with an Assignment.

Author(s):
Josh Holtzman
 
 public class AssignmentGradeRecord extends AbstractGradeRecord implements Cloneable {
    
 
 	private static final long serialVersionUID = 8259092798479256962L;
 	
 	private Double pointsEarned;
     private String letterEarned;
     private String userEnteredGrade;
     private Double percentEarned;
     private boolean userAbleToView;
     private Boolean excludedFromGrade;
     private transient BigDecimal earnedWeightedPercentage;
     private transient BigDecimal overallWeight;
     private transient Boolean isDropped;
     // used for drop highest/lowest score functionality
     private Boolean droppedFromGrade;
 
 
     static{
             public int compare(AssignmentGradeRecord agr1AssignmentGradeRecord agr2) {
                 if(agr1 == null && agr2 == null) {
                     return 0;
                 }
                 if(agr1 == null) {
                     return -1;
                 }
                 if(agr2 == null) {
                     return 1;
                 }
                 Double agr1Points = agr1.getPointsEarned();
                 Double agr2Points = agr2.getPointsEarned();
                 
                 if (agr1Points == null && agr2Points == null) {
                     return 0;
                 }
                 if (agr1Points == null && agr2Points != null) {
                     return -1;
                 }
                 if (agr1Points != null && agr2Points == null) {
                     return 1;
                 }
                 try {
                     return agr1Points.compareTo(agr2Points);
                 } catch(NumberFormatException e) {
                     return agr1Points.compareTo(agr2Points); // if not number, default to calcComparator functionality
                 }
             }
         };
     }
 
     public AssignmentGradeRecord() {
         super();
     }

    
The graderId and dateRecorded properties will be set explicitly by the grade manager before the database is updated.

Parameters:
assignment The assignment this grade record is associated with
studentId The student id for whom this grade record belongs
grade The grade, or points earned
 
	public AssignmentGradeRecord(Assignment assignmentString studentIdDouble grade) {
        super();
        this. = assignment;
        this. = studentId;
        this. = grade;
	}
    static {
         = new Comparator<AssignmentGradeRecord>() {
            public int compare(AssignmentGradeRecord agr1AssignmentGradeRecord agr2) {
                if(agr1 == null && agr2 == null) {
                    return 0;
                }
                if(agr1 == null) {
                    return -1;
                }
                if(agr2 == null) {
                    return 1;
                }
                Double agr1Points = agr1.getPointsEarned();
                Double agr2Points = agr2.getPointsEarned();
                
                if (agr1Points == null && agr2Points == null) {
                	return 0;
                }
                if (agr1Points == null && agr2Points != null) {
                	return -1;
                }
                if (agr1Points != null && agr2Points == null) {
                	return 1;
                }
                return agr1Points.compareTo(agr2Points);
            }
        };
    }

    

Returns:
Returns the pointsEarned
    public Double getPointsEarned() {
        return ;
    }

Parameters:
pointsEarned The pointsEarned to set.
	public void setPointsEarned(Double pointsEarned) {
		this. = pointsEarned;
	}

    
Returns null if the points earned is null. Otherwise, returns earned / points possible * 100.

    public Double getGradeAsPercentage() {
        if ( == null) {
            return null;
        }
        BigDecimal bdPointsEarned = new BigDecimal(.toString());
        BigDecimal bdPossible = new BigDecimal(((Assignment)getGradableObject()).getPointsPossible().toString());
        BigDecimal bdPercent = bdPointsEarned.divide(bdPossible.).multiply(new BigDecimal("100"));
        return Double.valueOf(bdPercent.doubleValue());
    }

	public boolean isCourseGradeRecord() {
		return false;
	}
    public Assignment getAssignment() {
    	return (Assignment)getGradableObject();
    }
    
    public Double getPercentEarned() {
    	return ;
    }
    
    public void setPercentEarned(Double percentEarned) {
    	this. = percentEarned;
    }
    public String getLetterEarned()
    {
    	return ;
    }
    public void setLetterEarned(String letterEarned)
    {
    	this. = letterEarned;
    }
    
    public boolean isUserAbleToView() {
    	return ;
    }
    public void setUserAbleToView(boolean userAbleToView) {
    	this. = userAbleToView;
    }
    public AssignmentGradeRecord clone()
    {
    	agr.setGraderId();
    	agr.setStudentId();
    	return agr;
    }
	}
	public void setExcludedFromGrade(Boolean isExcludedFromGrade) {
		this. = isExcludedFromGrade;
	}
	}
	public void setEarnedWeightedPercentage(BigDecimal earnedWeightedPercentage) {
		this. = earnedWeightedPercentage;
	}
	public Boolean isDropped() {
		return ;
	}
	public void setDropped(Boolean isDropped) {
		this. = isDropped;
	}
	}
	public void setOverallWeight(BigDecimal overallWeight) {
		this. = overallWeight;
	}
	}
	public void setUserEnteredGrade(String userEnteredGrade) {
		this. = userEnteredGrade;
	}
        return this. == null ? false : this.;
    }
    public void setDroppedFromGrade(Boolean droppedFromGrade) {
        this. = droppedFromGrade;
    }
New to GrepCode? Check out our FAQ X