Source Code Cross Referenced for Assignment.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » gradebook » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.tool.gradebook 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         *
003:         * $Id: Assignment.java 21443 2007-02-14 22:22:44Z 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.util.Collection;
024:        import java.util.Comparator;
025:        import java.util.Date;
026:
027:        /**
028:         * An Assignment is the basic unit that composes a gradebook.  It represents a
029:         * single unit that, when aggregated in a gradebook, can be used as the
030:         * denomenator in calculating a CourseGradeRecord.
031:         *
032:         * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
033:         */
034:        public class Assignment extends GradableObject {
035:
036:            public static String SORT_BY_DATE = "dueDate";
037:            public static String SORT_BY_NAME = "name";
038:            public static String SORT_BY_MEAN = "mean";
039:            public static String SORT_BY_POINTS = "pointsPossible";
040:            public static String SORT_BY_RELEASED = "released";
041:            public static String DEFAULT_SORT = SORT_BY_DATE;
042:
043:            public static Comparator dateComparator;
044:            public static Comparator nameComparator;
045:            public static Comparator pointsComparator;
046:            public static Comparator meanComparator;
047:            public static Comparator releasedComparator;
048:
049:            private Double pointsPossible;
050:            private Date dueDate;
051:            private boolean notCounted;
052:            private boolean externallyMaintained;
053:            private String externalStudentLink;
054:            private String externalInstructorLink;
055:            private String externalId;
056:            private String externalAppName;
057:            private boolean released;
058:
059:            static {
060:                dateComparator = new Comparator() {
061:                    public int compare(Object o1, Object o2) {
062:                        if (log.isDebugEnabled())
063:                            log.debug("Comparing assignment + " + o1 + " to "
064:                                    + o2 + " by date");
065:                        Assignment one = (Assignment) o1;
066:                        Assignment two = (Assignment) o2;
067:
068:                        // Sort by name if no date on either
069:                        if (one.getDueDate() == null
070:                                && two.getDueDate() == null) {
071:                            return one.getName().compareTo(two.getName());
072:                        }
073:
074:                        // Null dates are last
075:                        if (one.getDueDate() == null) {
076:                            return 1;
077:                        }
078:                        if (two.getDueDate() == null) {
079:                            return -1;
080:                        }
081:
082:                        // Sort by name if both assignments have the same date
083:                        int comp = (one.getDueDate()
084:                                .compareTo(two.getDueDate()));
085:                        if (comp == 0) {
086:                            return one.getName().compareTo(two.getName());
087:                        } else {
088:                            return comp;
089:                        }
090:                    }
091:                };
092:                nameComparator = new Comparator() {
093:                    public int compare(Object o1, Object o2) {
094:                        return ((Assignment) o1).getName().toLowerCase()
095:                                .compareTo(
096:                                        ((Assignment) o2).getName()
097:                                                .toLowerCase());
098:                    }
099:                };
100:                pointsComparator = new Comparator() {
101:                    public int compare(Object o1, Object o2) {
102:                        if (log.isDebugEnabled())
103:                            log.debug("Comparing assignment + " + o1 + " to "
104:                                    + o2 + " by points");
105:                        Assignment one = (Assignment) o1;
106:                        Assignment two = (Assignment) o2;
107:
108:                        int comp = one.getPointsPossible().compareTo(
109:                                two.getPointsPossible());
110:                        if (comp == 0) {
111:                            return one.getName().compareTo(two.getName());
112:                        } else {
113:                            return comp;
114:                        }
115:                    }
116:                };
117:                meanComparator = new Comparator() {
118:                    public int compare(Object o1, Object o2) {
119:                        if (log.isDebugEnabled())
120:                            log.debug("Comparing assignment + " + o1 + " to "
121:                                    + o2 + " by mean");
122:                        Assignment one = (Assignment) o1;
123:                        Assignment two = (Assignment) o2;
124:
125:                        Double mean1 = one.getMean();
126:                        Double mean2 = two.getMean();
127:                        if (mean1 == null && mean2 == null) {
128:                            return 0;
129:                        }
130:                        if (mean1 != null && mean2 == null) {
131:                            return 1;
132:                        }
133:                        if (mean1 == null && mean2 != null) {
134:                            return -1;
135:                        }
136:                        int comp = mean1.compareTo(mean2);
137:                        if (comp == 0) {
138:                            return one.getName().compareTo(two.getName());
139:                        } else {
140:                            return comp;
141:                        }
142:                    }
143:                };
144:
145:                releasedComparator = new Comparator() {
146:                    public int compare(Object o1, Object o2) {
147:                        if (log.isDebugEnabled())
148:                            log.debug("Comparing assignment + " + o1 + " to "
149:                                    + o2 + " by release");
150:                        Assignment one = (Assignment) o1;
151:                        Assignment two = (Assignment) o2;
152:
153:                        int comp = String.valueOf(one.isReleased()).compareTo(
154:                                String.valueOf(two.isReleased()));
155:                        if (comp == 0) {
156:                            return one.getName().compareTo(two.getName());
157:                        } else {
158:                            return comp;
159:                        }
160:                    }
161:                };
162:            }
163:
164:            public Assignment(Gradebook gradebook, String name,
165:                    Double pointsPossible, Date dueDate) {
166:                this .gradebook = gradebook;
167:                this .name = name;
168:                this .pointsPossible = pointsPossible;
169:                this .dueDate = dueDate;
170:                this .released = true;
171:            }
172:
173:            /**
174:             * constructor to support selective release
175:             * @param gradebook
176:             * @param name
177:             * @param pointsPossible
178:             * @param dueDate
179:             * @param released
180:             */
181:            public Assignment(Gradebook gradebook, String name,
182:                    Double pointsPossible, Date dueDate, boolean released) {
183:                this .gradebook = gradebook;
184:                this .name = name;
185:                this .pointsPossible = pointsPossible;
186:                this .dueDate = dueDate;
187:                this .released = released;
188:            }
189:
190:            public Assignment() {
191:                super ();
192:            }
193:
194:            /**
195:             */
196:            public boolean isCourseGrade() {
197:                return false;
198:            }
199:
200:            /**
201:             */
202:            public Date getDateForDisplay() {
203:                return dueDate;
204:            }
205:
206:            /**
207:             * @return Returns the dueDate.
208:             */
209:            public Date getDueDate() {
210:                return dueDate;
211:            }
212:
213:            /**
214:             * @param dueDate The dueDate to set.
215:             */
216:            public void setDueDate(Date dueDate) {
217:                this .dueDate = dueDate;
218:            }
219:
220:            /**
221:             */
222:            public boolean isNotCounted() {
223:                return notCounted;
224:            }
225:
226:            /**
227:             */
228:            public void setNotCounted(boolean notCounted) {
229:                this .notCounted = notCounted;
230:            }
231:
232:            /**
233:             */
234:            public boolean isCounted() {
235:                return !isNotCounted();
236:            }
237:
238:            /**
239:             * This cover is for the benefit of JSF checkboxes.
240:             */
241:            public void setCounted(boolean counted) {
242:                setNotCounted(!counted);
243:            }
244:
245:            /**
246:             * @return Returns the externalInstructorLink.
247:             */
248:            public String getExternalInstructorLink() {
249:                return externalInstructorLink;
250:            }
251:
252:            /**
253:             * @param externalInstructorLink The externalInstructorLink to set.
254:             */
255:            public void setExternalInstructorLink(String externalInstructorLink) {
256:                this .externalInstructorLink = externalInstructorLink;
257:            }
258:
259:            /**
260:             * @return Returns the externallyMaintained.
261:             */
262:            public boolean isExternallyMaintained() {
263:                return externallyMaintained;
264:            }
265:
266:            /**
267:             * @param externallyMaintained The externallyMaintained to set.
268:             */
269:            public void setExternallyMaintained(boolean externallyMaintained) {
270:                this .externallyMaintained = externallyMaintained;
271:            }
272:
273:            /**
274:             * @return Returns the externalStudentLink.
275:             */
276:            public String getExternalStudentLink() {
277:                return externalStudentLink;
278:            }
279:
280:            /**
281:             * @param externalStudentLink The externalStudentLink to set.
282:             */
283:            public void setExternalStudentLink(String externalStudentLink) {
284:                this .externalStudentLink = externalStudentLink;
285:            }
286:
287:            /**
288:             * @return Returns the pointsPossible.
289:             */
290:            public Double getPointsPossible() {
291:                return pointsPossible;
292:            }
293:
294:            /**
295:             * @param pointsPossible The pointsPossible to set.
296:             */
297:            public void setPointsPossible(Double pointsPossible) {
298:                this .pointsPossible = pointsPossible;
299:            }
300:
301:            /**
302:             * @return Returns the externalId.
303:             */
304:            public String getExternalId() {
305:                return externalId;
306:            }
307:
308:            /**
309:             * @param externalId The externalId to set.
310:             */
311:            public void setExternalId(String externalId) {
312:                this .externalId = externalId;
313:            }
314:
315:            /**
316:             * @return Returns the externalAppName.
317:             */
318:            public String getExternalAppName() {
319:                return externalAppName;
320:            }
321:
322:            /**
323:             * @param externalAppName The externalAppName to set.
324:             */
325:            public void setExternalAppName(String externalAppName) {
326:                this .externalAppName = externalAppName;
327:            }
328:
329:            /**
330:             *
331:             * @return selective release true or false
332:             */
333:
334:            public boolean isReleased() {
335:                return released;
336:            }
337:
338:            /**
339:             *
340:             * @param released returns wther the assignment has been released to users
341:             */
342:            public void setReleased(boolean released) {
343:                this .released = released;
344:            }
345:
346:            /**
347:             * Calculate the mean score for students with entered grades.
348:             */
349:            public void calculateStatistics(
350:                    Collection<AssignmentGradeRecord> gradeRecords) {
351:                int numScored = 0;
352:                double total = 0;
353:                for (AssignmentGradeRecord record : gradeRecords) {
354:                    // Skip grade records that don't apply to this gradable object
355:                    if (!record.getGradableObject().equals(this )) {
356:                        continue;
357:                    }
358:                    Double score = record.getGradeAsPercentage();
359:                    if (score == null) {
360:                        continue;
361:                    } else {
362:                        total += score.doubleValue();
363:                        numScored++;
364:                    }
365:                }
366:                if (numScored == 0) {
367:                    mean = null;
368:                } else {
369:                    mean = new Double(total / numScored);
370:                }
371:            }
372:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.