Source Code Cross Referenced for CourseGradesToSpreadsheetConverterSample.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » gradebooksample » 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.gradebooksample 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         *
003:         * $Id: CourseGradesToSpreadsheetConverterSample.java 22063 2007-03-01 23:07:02Z ray@media.berkeley.edu $
004:         *
005:         ***********************************************************************************
006:         *
007:         * Copyright (c) 2007 The Regents of the University of California
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.gradebooksample;
022:
023:        import java.util.ArrayList;
024:        import java.util.List;
025:        import java.util.Map;
026:
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:        import org.sakaiproject.coursemanagement.api.CourseManagementService;
030:        import org.sakaiproject.coursemanagement.api.Enrollment;
031:        import org.sakaiproject.coursemanagement.api.EnrollmentSet;
032:        import org.sakaiproject.coursemanagement.api.Section;
033:        import org.sakaiproject.section.api.coursemanagement.CourseSection;
034:        import org.sakaiproject.section.api.coursemanagement.EnrollmentRecord;
035:        import org.sakaiproject.section.api.coursemanagement.LearningContext;
036:        import org.sakaiproject.section.api.coursemanagement.User;
037:        import org.sakaiproject.tool.gradebook.CourseGrade;
038:        import org.sakaiproject.tool.gradebook.CourseGradeRecord;
039:        import org.sakaiproject.tool.gradebook.CourseGradesToSpreadsheetConverter;
040:
041:        /**
042:         * Sample customization of course grade spreadsheet downloads. This changes
043:         * the default behavior in the following ways:
044:         * 
045:         * <ul>
046:         * <li> The student name column is dropped.
047:         * <li> Another column is added to hold "Comments".
048:         * <li> The Course Management service is used to look up each student's
049:         * grading scheme.
050:         * <li> If the grading scheme is "Pass/Fail" or "Satisfactory/Unsatisfactory",
051:         * then the Gradebook's letter grade is converted to "P", "NP", "S", or "U"
052:         * based on a string translation table. The converted value is put into the 
053:         * "Grade" column and the original letter grade is put into the "Comments" column.
054:         * </ul>
055:         * 
056:         * Once this has been deployed as a Sakai component, it can be plugged into
057:         * the Gradebook application by adding the following line to "sakai.properties":
058:         * <p>
059:         * gradebook.coursegrades.converter=org.sakaiproject.gradebooksample.CourseGradesToSpreadsheetConverterSample
060:         */
061:        public class CourseGradesToSpreadsheetConverterSample implements 
062:                CourseGradesToSpreadsheetConverter {
063:            private static final Log log = LogFactory
064:                    .getLog(CourseGradesToSpreadsheetConverterSample.class);
065:
066:            private CourseManagementService courseManagementService;
067:            private String letterGradingSchemeName;
068:            private String passGradingSchemeName;
069:            private String satisfactoryGradingSchemeName;
070:            private Map<String, String> letterToPassMap;
071:            private Map<String, String> letterToSatisfactoryMap;
072:
073:            /**
074:             * @see org.sakaiproject.tool.gradebook.CourseGradesToSpreadsheetConverter#getSpreadsheetData(java.util.List,
075:             *      org.sakaiproject.tool.gradebook.CourseGrade, java.util.Map)
076:             */
077:            public List<List<Object>> getSpreadsheetData(
078:                    List<EnrollmentRecord> enrollments,
079:                    CourseGrade courseGrade,
080:                    Map<String, CourseGradeRecord> gradesMap) {
081:                List<List<Object>> spreadsheetData = new ArrayList<List<Object>>();
082:
083:                // Build column headers.
084:                List<Object> headerRow = new ArrayList<Object>();
085:                headerRow.add("STUDENT ID NUMBER");
086:                headerRow.add("GRADE");
087:                headerRow.add("COMMENTS");
088:                spreadsheetData.add(headerRow);
089:
090:                // Build student grade rows.
091:                for (EnrollmentRecord enrollment : enrollments) {
092:                    User student = enrollment.getUser();
093:                    String studentUid = student.getUserUid();
094:                    Map studentMap = (Map) gradesMap.get(studentUid);
095:                    List<Object> row = new ArrayList<Object>();
096:                    row.add(student.getDisplayId());
097:                    String grade = null;
098:                    if (studentMap != null) {
099:                        CourseGradeRecord gradeRecord = (CourseGradeRecord) studentMap
100:                                .get(courseGrade.getId());
101:                        if (gradeRecord != null) {
102:                            grade = gradeRecord.getDisplayGrade();
103:                            if (log.isDebugEnabled())
104:                                log.debug("student UID=" + studentUid
105:                                        + ", displayID="
106:                                        + student.getDisplayId()
107:                                        + ", displayGrade=" + grade);
108:                            addGradeColumns(row, enrollment, grade);
109:                        }
110:                    }
111:                    spreadsheetData.add(row);
112:                }
113:
114:                return spreadsheetData;
115:            }
116:
117:            private void addGradeColumns(List<Object> row,
118:                    EnrollmentRecord sectionAwarenessEnrollment,
119:                    String originalGrade) {
120:                String gradeColumn = originalGrade;
121:                String commentColumn = null;
122:                LearningContext lc = sectionAwarenessEnrollment
123:                        .getLearningContext();
124:                if (log.isDebugEnabled())
125:                    log.debug("lc=" + lc);
126:                if (lc instanceof  CourseSection) {
127:                    CourseSection courseSection = (CourseSection) lc;
128:                    String courseManagementEid = courseSection.getEid();
129:                    if (log.isDebugEnabled())
130:                        log.debug("courseManagementEid=" + courseManagementEid);
131:                    if (courseManagementEid != null) {
132:                        // Translate from Section Awareness view to Course Management data.
133:                        Section cmSection = courseManagementService
134:                                .getSection(courseManagementEid);
135:                        if (cmSection != null) {
136:                            EnrollmentSet enrollmentSet = cmSection
137:                                    .getEnrollmentSet();
138:                            if (log.isDebugEnabled())
139:                                log.debug("enrollmentSet=" + enrollmentSet);
140:                            if (enrollmentSet != null) {
141:                                Enrollment cmEnrollment = courseManagementService
142:                                        .findEnrollment(
143:                                                sectionAwarenessEnrollment
144:                                                        .getUser()
145:                                                        .getDisplayId(),
146:                                                enrollmentSet.getEid());
147:                                if (cmEnrollment != null) {
148:                                    String gradingScheme = cmEnrollment
149:                                            .getGradingScheme();
150:                                    if (log.isDebugEnabled())
151:                                        log.debug("gradingScheme="
152:                                                + gradingScheme);
153:                                    if ((gradingScheme != null)
154:                                            && (!gradingScheme
155:                                                    .equals(letterGradingSchemeName))) {
156:                                        if (gradingScheme
157:                                                .equals(passGradingSchemeName)) {
158:                                            gradeColumn = letterToPassMap
159:                                                    .get(originalGrade);
160:                                            commentColumn = originalGrade;
161:                                        } else if (gradingScheme
162:                                                .equals(satisfactoryGradingSchemeName)) {
163:                                            gradeColumn = letterToSatisfactoryMap
164:                                                    .get(originalGrade);
165:                                            commentColumn = originalGrade;
166:                                        }
167:                                    }
168:                                }
169:                            }
170:                        }
171:                    }
172:                }
173:                if (log.isDebugEnabled())
174:                    log.debug("gradeColumn=" + gradeColumn + ", commentColumn="
175:                            + commentColumn);
176:                row.add(gradeColumn);
177:                row.add(commentColumn);
178:            }
179:
180:            public CourseManagementService getCourseManagementService() {
181:                return courseManagementService;
182:            }
183:
184:            public void setCourseManagementService(
185:                    CourseManagementService courseManagementService) {
186:                this .courseManagementService = courseManagementService;
187:            }
188:
189:            public String getLetterGradingSchemeName() {
190:                return letterGradingSchemeName;
191:            }
192:
193:            public void setLetterGradingSchemeName(
194:                    String letterGradingSchemeName) {
195:                this .letterGradingSchemeName = letterGradingSchemeName;
196:            }
197:
198:            public Map<String, String> getLetterToPassMap() {
199:                return letterToPassMap;
200:            }
201:
202:            public void setLetterToPassMap(Map<String, String> letterToPassMap) {
203:                this .letterToPassMap = letterToPassMap;
204:            }
205:
206:            public Map<String, String> getLetterToSatisfactoryMap() {
207:                return letterToSatisfactoryMap;
208:            }
209:
210:            public void setLetterToSatisfactoryMap(
211:                    Map<String, String> letterToSatisfactoryMap) {
212:                this .letterToSatisfactoryMap = letterToSatisfactoryMap;
213:            }
214:
215:            public String getPassGradingSchemeName() {
216:                return passGradingSchemeName;
217:            }
218:
219:            public void setPassGradingSchemeName(String passGradingSchemeName) {
220:                this .passGradingSchemeName = passGradingSchemeName;
221:            }
222:
223:            public String getSatisfactoryGradingSchemeName() {
224:                return satisfactoryGradingSchemeName;
225:            }
226:
227:            public void setSatisfactoryGradingSchemeName(
228:                    String satisfactoryGradingSchemeName) {
229:                this.satisfactoryGradingSchemeName = satisfactoryGradingSchemeName;
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.