01: /**********************************************************************************
02: *
03: * $Id: AssignmentGradeRecord.java 20001 2006-12-22 19:41:33Z ray@media.berkeley.edu $
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2005 The Regents of the University of California, The MIT Corporation
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.tool.gradebook;
22:
23: /**
24: * An AssignmentGradeRecord is a grade record that can be associated with an
25: * Assignment.
26: *
27: * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
28: */
29: public class AssignmentGradeRecord extends AbstractGradeRecord {
30: private Double pointsEarned;
31:
32: public AssignmentGradeRecord() {
33: super ();
34: }
35:
36: /**
37: * The graderId and dateRecorded properties will be set explicitly by the
38: * grade manager before the database is updated.
39: * @param assignment The assignment this grade record is associated with
40: * @param studentId The student id for whom this grade record belongs
41: * @param grade The grade, or points earned
42: */
43: public AssignmentGradeRecord(Assignment assignment,
44: String studentId, Double grade) {
45: super ();
46: this .gradableObject = assignment;
47: this .studentId = studentId;
48: this .pointsEarned = grade;
49: }
50:
51: /**
52: * @return Returns the pointsEarned
53: */
54: public Double getPointsEarned() {
55: return pointsEarned;
56: }
57:
58: /**
59: * @param pointsEarned The pointsEarned to set.
60: */
61: public void setPointsEarned(Double pointsEarned) {
62: this .pointsEarned = pointsEarned;
63: }
64:
65: /**
66: * Returns null if the points earned is null. Otherwise, returns earned / points possible * 100.
67: *
68: * @see org.sakaiproject.tool.gradebook.AbstractGradeRecord#getGradeAsPercentage()
69: */
70: public Double getGradeAsPercentage() {
71: if (pointsEarned == null) {
72: return null;
73: }
74: double earned = pointsEarned.doubleValue();
75: double possible = ((Assignment) getGradableObject())
76: .getPointsPossible().doubleValue();
77: return new Double(earned / possible * 100);
78: }
79:
80: /**
81: * @see org.sakaiproject.tool.gradebook.AbstractGradeRecord#isCourseGradeRecord()
82: */
83: public boolean isCourseGradeRecord() {
84: return false;
85: }
86:
87: public Assignment getAssignment() {
88: return (Assignment) getGradableObject();
89: }
90: }
|