Source Code Cross Referenced for AssessmentBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » assessment » ui » bean » author » 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.assessment.ui.bean.author 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/author/AssessmentBean.java $
003:         * $Id: AssessmentBean.java 14496 2006-09-13 02:54:43Z daisyf@stanford.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the"License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.tool.assessment.ui.bean.author;
021:
022:        import java.io.Serializable;
023:        import java.util.ArrayList;
024:        import java.util.List;
025:        import javax.faces.context.FacesContext;
026:        import javax.faces.model.SelectItem;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:
031:        import org.sakaiproject.tool.assessment.data.ifc.assessment.SectionDataIfc;
032:        import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;
033:        import org.sakaiproject.tool.assessment.facade.AssessmentFacade;
034:        import org.sakaiproject.tool.assessment.services.shared.TypeService;
035:        import org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean;
036:        import org.sakaiproject.tool.assessment.ui.bean.delivery.SectionContentsBean;
037:
038:        /**
039:         * @author rshastri
040:         *
041:         * To change the template for this generated type comment go to
042:         * Window>Preferences>Java>Code Generation>Code and Comments
043:         *
044:         * Used to be org.navigoproject.ui.web.asi.author.assessment.AssessmentActionForm.java
045:         */
046:        public class AssessmentBean implements  Serializable {
047:            private static Log log = LogFactory.getLog(AssessmentBean.class);
048:
049:            /** Use serialVersionUID for interoperability. */
050:            private final static long serialVersionUID = -630950053380808339L;
051:            private AssessmentFacade assessment;
052:            private String assessmentId;
053:            private String title;
054:            // ArrayList of SectionContentsBean
055:            private ArrayList sections = new ArrayList(); // this contains list of SectionFacde
056:            private ArrayList sectionList = new ArrayList(); // this contains list of javax.faces.model.SelectItem
057:            private ArrayList otherSectionList = new ArrayList(); // contains SectionItem of section except the current section
058:            private ArrayList partNumbers = new ArrayList();
059:            private int questionSize = 0;
060:            private float totalScore = 0;
061:            private String newQuestionTypeId;
062:            private String firstSectionId;
063:            private boolean hasRandomDrawPart;
064:
065:            /*
066:             * Creates a new AssessmentBean object.
067:             */
068:            public AssessmentBean() {
069:            }
070:
071:            public AssessmentFacade getAssessment() {
072:                return assessment;
073:            }
074:
075:            public void setAssessment(AssessmentFacade assessment) {
076:                try {
077:                    this .assessment = assessment;
078:                    this .assessmentId = assessment.getAssessmentId().toString();
079:                    this .title = assessment.getTitle();
080:
081:                    // work out the question side & total point
082:                    this .sections = new ArrayList();
083:                    ArrayList sectionArray = assessment.getSectionArraySorted();
084:                    for (int i = 0; i < sectionArray.size(); i++) {
085:                        SectionDataIfc section = (SectionDataIfc) sectionArray
086:                                .get(i);
087:                        SectionContentsBean sectionBean = new SectionContentsBean(
088:                                section);
089:                        this .sections.add(sectionBean);
090:                    }
091:                    setPartNumbers();
092:                    setQuestionSizeAndTotalScore();
093:                    setSectionList(sectionArray);
094:                } catch (Exception ex) {
095:                    ex.printStackTrace();
096:                }
097:            }
098:
099:            // properties from Assessment
100:            public String getAssessmentId() {
101:                return this .assessmentId;
102:            }
103:
104:            public void setAssessmentId(String assessmentId) {
105:                this .assessmentId = assessmentId;
106:            }
107:
108:            public String getTitle() {
109:                return this .title;
110:            }
111:
112:            public void setTitle(String title) {
113:                this .title = title;
114:            }
115:
116:            public ArrayList getSections() {
117:                return sections;
118:            }
119:
120:            public void setSections(ArrayList sections) {
121:                this .sections = sections;
122:            }
123:
124:            public ArrayList getPartNumbers() {
125:                return partNumbers;
126:            }
127:
128:            public void setPartNumbers() {
129:                this .partNumbers = new ArrayList();
130:                for (int i = 1; i <= this .sections.size(); i++) {
131:                    this .partNumbers.add(new SelectItem(i + ""));
132:                }
133:            }
134:
135:            public int getQuestionSize() {
136:                return this .questionSize;
137:            }
138:
139:            public void setQuestionSizeAndTotalScore() {
140:                this .questionSize = 0;
141:                this .totalScore = 0;
142:                int randomPartCount = 0;
143:                for (int i = 0; i < this .sections.size(); i++) {
144:                    SectionContentsBean sectionBean = (SectionContentsBean) sections
145:                            .get(i);
146:                    ArrayList items = sectionBean.getItemContents();
147:
148:                    int itemsInThisSection = 0;
149:                    if (sectionBean.getSectionAuthorType().equals(
150:                            SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
151:                        // for random draw parts, add
152:                        randomPartCount++;
153:                        itemsInThisSection = sectionBean.getNumberToBeDrawn()
154:                                .intValue();
155:                    } else {
156:                        itemsInThisSection = items.size();
157:                    }
158:
159:                    this .questionSize += itemsInThisSection;
160:                    for (int j = 0; j < itemsInThisSection; j++) {
161:                        ItemContentsBean item = (ItemContentsBean) items.get(j);
162:                        if (item.getItemData().getScore() != null) {
163:                            this .totalScore += item.getItemData().getScore()
164:                                    .floatValue();
165:                        }
166:                    }
167:                }
168:                if (randomPartCount > 0) {
169:                    setHasRandomDrawPart(true);
170:                } else {
171:                    setHasRandomDrawPart(false);
172:                }
173:            }
174:
175:            public float getTotalScore() {
176:                return this .totalScore;
177:            }
178:
179:            public String getNewQuestionTypeId() {
180:                return this .newQuestionTypeId;
181:            }
182:
183:            public void setNewQuestionTypeId(String newQuestionTypeId) {
184:                this .newQuestionTypeId = newQuestionTypeId;
185:            }
186:
187:            public SelectItem[] getItemTypes() {
188:                // return list of TypeD
189:                TypeService service = new TypeService();
190:                List list = service.getFacadeItemTypes();
191:                SelectItem[] itemTypes = new SelectItem[list.size()];
192:                for (int i = 0; i < list.size(); i++) {
193:                    TypeIfc t = (TypeIfc) list.get(i);
194:                    itemTypes[i] = new SelectItem(t.getTypeId().toString(), t
195:                            .getKeyword());
196:                }
197:                return itemTypes;
198:            }
199:
200:            /**
201:             * This set a list of SelectItem (sectionId, title) for selection box
202:             * @param list
203:             */
204:            public void setSectionList(ArrayList list) {
205:                //this.assessmentTemplateIter = new AssessmentTemplateIteratorFacade(list);
206:                this .sectionList = new ArrayList();
207:                try {
208:                    for (int i = 0; i < list.size(); i++) {
209:                        SectionDataIfc f = (SectionDataIfc) list.get(i);
210:                        // sorry, cannot do f.getAssessmentTemplateId() 'cos such call requires
211:                        // "data" which we do not have in this case. The template list parsed
212:                        // to this method contains merely assesmentBaseId (in this case is the templateId)
213:                        //  & title (see constructor AssessmentTemplateFacade(id, title))
214:                        this .sectionList.add(new SelectItem(f.getSectionId()
215:                                .toString(), f.getTitle()));
216:                        if (i == 0) {
217:                            this .firstSectionId = f.getSectionId().toString();
218:                        }
219:                    }
220:                } catch (Exception e) {
221:                    log.warn(e.getMessage());
222:                }
223:            }
224:
225:            public ArrayList getSectionList() {
226:                return sectionList;
227:            }
228:
229:            public String getFirstSectionId() {
230:                return firstSectionId;
231:            }
232:
233:            /**
234:             * @param string the title
235:             */
236:            public void setFirstSectionId(String firstSectionId) {
237:                this .firstSectionId = firstSectionId;
238:            }
239:
240:            public ArrayList getOtherSectionList() {
241:                return otherSectionList;
242:            }
243:
244:            public void setOtherSectionList(ArrayList list) {
245:                this .otherSectionList = list; // list contains javax.faces.model.SelectItem
246:            }
247:
248:            public boolean getHasRandomDrawPart() {
249:                return this .hasRandomDrawPart;
250:            }
251:
252:            public void setHasRandomDrawPart(boolean param) {
253:                this.hasRandomDrawPart = param;
254:            }
255:
256:        }
www_.j_ava_2___s.co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.