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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/qti/asi/Assessment.java $
003:         * $Id: Assessment.java 9274 2006-05-10 22:50:48Z daisyf@stanford.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 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.qti.asi;
021:
022:        import java.util.ArrayList;
023:        import java.util.Collection;
024:        import java.util.HashMap;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import javax.xml.parsers.DocumentBuilder;
029:        import javax.xml.parsers.DocumentBuilderFactory;
030:        import javax.xml.parsers.ParserConfigurationException;
031:
032:        import org.apache.commons.logging.Log;
033:        import org.apache.commons.logging.LogFactory;
034:        import org.w3c.dom.Document;
035:        import org.w3c.dom.Element;
036:
037:        import org.sakaiproject.tool.assessment.qti.constants.QTIConstantStrings;
038:
039:        /**
040:         * <p>Copyright: Copyright (c) 2003-5</p>
041:         * <p>Organization: Sakai Project</p>
042:         * @author casong
043:         * @author Ed Smiley esmiley@stanford.edu
044:         * @version $Id: Assessment.java 9274 2006-05-10 22:50:48Z daisyf@stanford.edu $
045:         */
046:        public class Assessment extends ASIBaseClass {
047:            private static Log log = LogFactory.getLog(Assessment.class);
048:            private String basePath;
049:            private Map sections;
050:            private Map items;
051:
052:            /**
053:             * Explicitly setting serialVersionUID insures future versions can be
054:             * successfully restored. It is essential this variable name not be changed
055:             * to SERIALVERSIONUID, as the default serialization methods expects this
056:             * exact name.
057:             */
058:            private static final long serialVersionUID = 1;
059:
060:            /**
061:             * Creates a new Assessment object.
062:             */
063:            protected Assessment() {
064:                super ();
065:                this .sections = new HashMap();
066:                this .items = new HashMap();
067:                this .basePath = QTIConstantStrings.QUESTESTINTEROP + "/"
068:                        + QTIConstantStrings.ASSESSMENT;
069:            }
070:
071:            /**
072:             * Creates a new Assessment object.
073:             *
074:             * @param document the Document containing the assessment.
075:             */
076:            public Assessment(Document document) {
077:                super (document);
078:                this .sections = new HashMap();
079:                this .items = new HashMap();
080:                this .basePath = QTIConstantStrings.QUESTESTINTEROP + "/"
081:                        + QTIConstantStrings.ASSESSMENT;
082:            }
083:
084:            /**
085:             * Method for meta data.
086:             *
087:             * @todo use QTIConstantStrings:
088:             *   //QTIMetaData
089:            public static String QTIMETADATAFIELD = "qtimetadatafield";
090:            public static String FIELDLABEL = "fieldlabel";
091:            public static String FIELDENTRY = "fieldentry";
092:
093:             *
094:             * @param fieldlabel the fieldlabel
095:             *
096:             * @return the entry
097:             */
098:            public String getFieldentry(String fieldlabel) {
099:                if (log.isDebugEnabled()) {
100:                    log.debug("getFieldentry(String " + fieldlabel + ")");
101:                }
102:
103:                String xpath = basePath
104:                        + "/qtimetadata/qtimetadatafield/fieldlabel[text()='"
105:                        + fieldlabel + "']/following-sibling::fieldentry";
106:
107:                return super .getFieldentry(xpath);
108:            }
109:
110:            /**
111:             *
112:             *
113:             * @param fieldlabel
114:             * @param setValue
115:             * @param noEscapeXML
116:             */
117:            public void setFieldentry(String fieldlabel, String setValue) {
118:                setFieldentry(fieldlabel, setValue, false);
119:            }
120:
121:            /**
122:             *
123:             *
124:             * @param fieldlabel
125:             * @param setValue
126:             */
127:            public void setFieldentry(String fieldlabel, String setValue,
128:                    boolean noEscapeXML) {
129:                if (log.isDebugEnabled()) {
130:                    log.debug("setFieldentry(String " + fieldlabel
131:                            + ", String " + setValue + ")");
132:                }
133:
134:                String xpath = "questestinterop/assessment/qtimetadata/qtimetadatafield/fieldlabel[text()='"
135:                        + fieldlabel + "']/following-sibling::fieldentry";
136:                super .setFieldentry(xpath, setValue, noEscapeXML);
137:            }
138:
139:            /**
140:             * Add a section ref with section Id sectionId.
141:             *
142:             * @param sectionId
143:             */
144:            public void addSectionRef(String sectionId) {
145:                if (log.isDebugEnabled()) {
146:                    log.debug("addSection(String " + sectionId + ")");
147:                }
148:
149:                try {
150:                    String xpath = basePath;
151:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
152:                            .newInstance();
153:                    DocumentBuilder db = dbf.newDocumentBuilder();
154:                    Document document = db.newDocument();
155:                    Element element = document
156:                            .createElement(QTIConstantStrings.SECTIONREF);
157:                    element.setAttribute(QTIConstantStrings.LINKREFID,
158:                            sectionId);
159:                    this .addElement(xpath, element);
160:                } catch (ParserConfigurationException pce) {
161:                    log.error("Exception thrown from addSectionRef() : "
162:                            + pce.getMessage());
163:                    pce.printStackTrace();
164:                }
165:            }
166:
167:            /**
168:             * Remove a section ref with section Id sectionId.
169:             *
170:             * @param sectionId
171:             */
172:            public void removeSectionRef(String sectionId) {
173:                if (log.isDebugEnabled()) {
174:                    log.debug("removeSectionRef(String " + sectionId + ")");
175:                }
176:
177:                String xpath = basePath + "/" + QTIConstantStrings.SECTIONREF
178:                        + "[@" + QTIConstantStrings.LINKREFID + "='"
179:                        + sectionId + "']";
180:                this .removeElement(xpath);
181:            }
182:
183:            /**
184:             * Remove all section refs.
185:             */
186:            public void removeSectionRefs() {
187:                log.debug("removeSectionRefs()");
188:                String xpath = basePath + "/" + QTIConstantStrings.SECTIONREF;
189:                this .removeElement(xpath);
190:            }
191:
192:            /**
193:             * Get a collection of section refs.
194:             *
195:             * @return
196:             */
197:            public List getSectionRefs() {
198:                log.debug("getSectionRefs()");
199:                String xpath = basePath + "/" + QTIConstantStrings.SECTIONREF;
200:
201:                return this .selectNodes(xpath);
202:            }
203:
204:            /**
205:             * Get a collection of sections.
206:             * @return the sections
207:             */
208:            public Collection getSections() {
209:                return this .sections.values();
210:            }
211:
212:            /**
213:             * Get a collection of items.
214:             * @return the items
215:             */
216:            public Collection getItems() {
217:                return this .items.values();
218:            }
219:
220:            /**
221:             *
222:             *
223:             * @return
224:             */
225:            public List getSectionRefIds() {
226:                log.debug("getSectionRefIds()");
227:                List refs = this .getSectionRefs();
228:                List ids = new ArrayList();
229:                int size = refs.size();
230:                for (int i = 0; i < size; i++) {
231:                    Element ref = (Element) refs.get(0);
232:                    String idString = ref
233:                            .getAttribute(QTIConstantStrings.LINKREFID);
234:                    ids.add(idString);
235:                }
236:
237:                return ids;
238:            }
239:
240:            /**
241:             * Assessment title.
242:             * @return title
243:             */
244:            public String getTitle() {
245:                String title = "";
246:                String xpath = basePath;
247:                List list = this .selectNodes(xpath);
248:                if (list.size() > 0) {
249:                    Element element = (Element) list.get(0);
250:                    title = element.getAttribute("title");
251:                }
252:                return title;
253:            }
254:
255:            /**
256:             * Assessment id (ident attribute)
257:             * @return ident
258:             */
259:            public String getIdent() {
260:                String ident = "";
261:                String xpath = basePath;
262:                List list = this .selectNodes(xpath);
263:                if (list.size() > 0) {
264:                    Element element = (Element) list.get(0);
265:                    ident = element.getAttribute("ident");
266:                }
267:                return ident;
268:            }
269:
270:            /**
271:             * Assessment id (ident attribute)
272:             * @param ident the ident
273:             */
274:            public void setIdent(String ident) {
275:                String xpath = basePath;
276:                List list = this .selectNodes(xpath);
277:                if (list.size() > 0) {
278:                    Element element = (Element) list.get(0);
279:                    element.setAttribute("ident", ident);
280:                }
281:            }
282:
283:            /**
284:             * Assessment title.
285:             * @param title
286:             */
287:            public void setTitle(String title) {
288:                String xpath = basePath;
289:                List list = this .selectNodes(xpath);
290:                if (list.size() > 0) {
291:                    Element element = (Element) list.get(0);
292:                    element.setAttribute("title", escapeXml(title));
293:                }
294:            }
295:
296:            /**
297:             * Base XPath for the assessment.
298:             * @return
299:             */
300:            public String getBasePath() {
301:                return basePath;
302:            }
303:
304:            /**
305:             * Base XPath for the assessment.
306:             * @param basePath
307:             */
308:            public void setBasePath(String basePath) {
309:                this.basePath = basePath;
310:            }
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.