001: /**********************************************************************************
002: *
003: * $Id: Gradebook.java 20758 2007-01-29 18:07:03Z ray@media.berkeley.edu $
004: *
005: ***********************************************************************************
006: *
007: * Copyright (c) 2005 The Regents of the University of California, The MIT Corporation
008: *
009: * Licensed under the Educational Community License, Version 1.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.opensource.org/licenses/ecl1.php
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: *
021: **********************************************************************************/package org.sakaiproject.tool.gradebook;
022:
023: import java.io.Serializable;
024: import java.util.*;
025: import org.apache.commons.lang.builder.EqualsBuilder;
026: import org.apache.commons.lang.builder.HashCodeBuilder;
027: import org.apache.commons.lang.builder.ToStringBuilder;
028:
029: /**
030: * A Gradebook is the top-level object in the Sakai Gradebook tool. Only one
031: * Gradebook should be associated with any particular course (or site, as they
032: * exist in Sakai 1.5) for any given academic term. How courses and terms are
033: * determined will likely depend on the particular Sakai installation.
034: *
035: * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
036: */
037: public class Gradebook implements Serializable {
038: private Long id;
039: private String uid;
040: private int version;
041: private String name;
042: private GradeMapping selectedGradeMapping;
043: private Set<GradeMapping> gradeMappings;
044: private boolean assignmentsDisplayed;
045: private boolean courseGradeDisplayed;
046: private boolean allAssignmentsEntered;
047: private boolean locked;
048:
049: /**
050: * Default no-arg constructor needed for persistence
051: */
052: public Gradebook() {
053: }
054:
055: /**
056: * Creates a new gradebook with the given siteId and name
057: * @param name
058: */
059: public Gradebook(String name) {
060: this .name = name;
061: }
062:
063: /**
064: * Lists the grade mappings available to a gradebook. If an institution
065: * wishes to add or remove grade mappings, they will need to create a new
066: * java class, add the class to the GradeMapping hibernate configuration,
067: * and add the class here.
068: *
069: * This method will generally not be used, but can helpful when creating new
070: * gradebooks.
071: *
072: * @return A Set of available grade mappings
073: */
074: /*
075: public Set getAvailableGradeMappings() {
076: Set set = new HashSet();
077: set.add(new LetterGradeMapping());
078: set.add(new LetterGradePlusMinusMapping());
079: set.add(new PassNotPassMapping());
080: return set;
081: }
082: */
083:
084: /*
085: public Class getDefaultGradeMapping() {
086: return LetterGradePlusMinusMapping.class;
087: }
088: */
089:
090: /**
091: * @return Returns the allAssignmentsEntered.
092: */
093: public boolean isAllAssignmentsEntered() {
094: return allAssignmentsEntered;
095: }
096:
097: /**
098: * @param allAssignmentsEntered The allAssignmentsEntered to set.
099: */
100: public void setAllAssignmentsEntered(boolean allAssignmentsEntered) {
101: this .allAssignmentsEntered = allAssignmentsEntered;
102: }
103:
104: /**
105: * @return Returns the assignmentsDisplayed.
106: */
107: public boolean isAssignmentsDisplayed() {
108: return assignmentsDisplayed;
109: }
110:
111: /**
112: * @param assignmentsDisplayed The assignmentsDisplayed to set.
113: */
114: public void setAssignmentsDisplayed(boolean assignmentsDisplayed) {
115: this .assignmentsDisplayed = assignmentsDisplayed;
116: }
117:
118: /**
119: * @return Returns the gradeMappings.
120: */
121: public Set<GradeMapping> getGradeMappings() {
122: return gradeMappings;
123: }
124:
125: /**
126: * @param gradeMappings The gradeMappings to set.
127: */
128: public void setGradeMappings(Set<GradeMapping> gradeMappings) {
129: this .gradeMappings = gradeMappings;
130: }
131:
132: /**
133: * @return Returns the id.
134: */
135: public Long getId() {
136: return id;
137: }
138:
139: /**
140: * @param id The id to set.
141: */
142: public void setId(Long id) {
143: this .id = id;
144: }
145:
146: /**
147: * @return Returns the uid.
148: */
149: public String getUid() {
150: return uid;
151: }
152:
153: /**
154: * @param uid The uid to set.
155: */
156: public void setUid(String uid) {
157: this .uid = uid;
158: }
159:
160: /**
161: * @return Returns the name.
162: */
163: public String getName() {
164: return name;
165: }
166:
167: /**
168: * @param name The name to set.
169: */
170: public void setName(String name) {
171: this .name = name;
172: }
173:
174: /**
175: * @return Returns the locked.
176: */
177: public boolean isLocked() {
178: return locked;
179: }
180:
181: /**
182: * @param locked The locked to set.
183: */
184: public void setLocked(boolean locked) {
185: this .locked = locked;
186: }
187:
188: /**
189: * @return Returns the selectedGradeMapping.
190: */
191: public GradeMapping getSelectedGradeMapping() {
192: return selectedGradeMapping;
193: }
194:
195: /**
196: * @param selectedGradeMapping The selectedGradeMapping to set.
197: */
198: public void setSelectedGradeMapping(
199: GradeMapping selectedGradeMapping) {
200: this .selectedGradeMapping = selectedGradeMapping;
201: }
202:
203: /**
204: * @return Returns the version.
205: */
206: public int getVersion() {
207: return version;
208: }
209:
210: /**
211: * @param version The version to set.
212: */
213: public void setVersion(int version) {
214: this .version = version;
215: }
216:
217: /**
218: * @return Returns the courseGradeDisplayed.
219: */
220: public boolean isCourseGradeDisplayed() {
221: return courseGradeDisplayed;
222: }
223:
224: /**
225: * @param courseGradeDisplayed The courseGradeDisplayed to set.
226: */
227: public void setCourseGradeDisplayed(boolean courseGradeDisplayed) {
228: this .courseGradeDisplayed = courseGradeDisplayed;
229: }
230:
231: public String toString() {
232: return new ToStringBuilder(this ).append("id", id).append("uid",
233: uid).append("name", name).toString();
234: }
235:
236: public boolean equals(Object other) {
237: if (!(other instanceof Gradebook)) {
238: return false;
239: }
240: Gradebook gb = (Gradebook) other;
241: return new EqualsBuilder().append(uid, gb.getUid()).isEquals();
242: }
243:
244: public int hashCode() {
245: return new HashCodeBuilder().append(uid).toHashCode();
246: }
247: }
|