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


001:        /**********************************************************************************
002:         * $URL$
003:         * $Id$
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.helper;
021:
022:        import java.util.List;
023:        import java.util.StringTokenizer;
024:
025:        import org.sakaiproject.tool.assessment.qti.constants.AuthoringConstantStrings;
026:        import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentMetaDataIfc;
027:        import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemDataIfc;
028:        import org.sakaiproject.tool.assessment.facade.AssessmentFacade;
029:        import org.sakaiproject.tool.assessment.facade.ItemFacade;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.apache.commons.logging.Log;
032:
033:        /**
034:         * Contract: use List of special "|" delimited "KEY|VALUE" Strings!
035:         * @author Ed Smiley esmiley@stanford.edu
036:         */
037:        public class MetaDataList {
038:            private static Log log = LogFactory.getLog(ExtractionHelper.class);
039:
040:            /**
041:             * list of editable settings
042:             */
043:            private static final String[] editableKeys = {
044:                    "assessmentAuthor_isInstructorEditable",
045:                    "assessmentCreator_isInstructorEditable",
046:                    "description_isInstructorEditable",
047:                    "dueDate_isInstructorEditable",
048:                    "retractDate_isInstructorEditable",
049:                    "anonymousRelease_isInstructorEditable",
050:                    "authenticatedRelease_isInstructorEditable",
051:                    "ipAccessType_isInstructorEditable",
052:                    "passwordRequired_isInstructorEditable",
053:                    "timedAssessment_isInstructorEditable",
054:                    "timedAssessmentAutoSubmit_isInstructorEditable",
055:                    "itemAccessType_isInstructorEditable",
056:                    "displayChunking_isInstructorEditable",
057:                    "displayNumbering_isInstructorEditable",
058:                    "submissionModel_isInstructorEditable",
059:                    "lateHandling_isInstructorEditable",
060:                    "autoSave_isInstructorEditable",
061:                    "submissionMessage_isInstructorEditable",
062:                    "finalPageURL_isInstructorEditable",
063:                    "feedbackType_isInstructorEditable",
064:                    "feedbackAuthoring_isInstructorEditable",
065:                    "feedbackComponents_isInstructorEditable",
066:                    "testeeIdentity_isInstructorEditable",
067:                    "toGradebook_isInstructorEditable",
068:                    "recordedScore_isInstructorEditable",
069:                    "bgColor_isInstructorEditable",
070:                    "bgImage_isInstructorEditable",
071:                    "metadataAssess_isInstructorEditable",
072:                    "metadataParts_isInstructorEditable",
073:                    "metadataQuestions_isInstructorEditable", };
074:
075:            private List metadataList;
076:
077:            /**
078:             * Contract: use List of special "|" delimited "KEY|VALUE" Strings!
079:             * Uses special "|" delimited "KEY|VALUE" strings
080:             * @param metadataList
081:             */
082:            public MetaDataList(List metadataList) {
083:                this .setMetadataList(metadataList);
084:            }
085:
086:            /**
087:             * Adds extraction-created list of "|" key value pairs
088:             * to item metadata map, if there are any.
089:             * Example:<metadata type =" list " > TEXT_FORMAT| HTML </metadata > 
090:             * <metadata type =" list " > ITEM_OBJECTIVE| </ metadata > 
091:             * Becomes:
092:             * TEXT_FORMAT=>HTML 
093:             * @param metadataList extraction-created list of "|" key value pairs
094:             * @param item the item
095:             */
096:            public void addTo(ItemFacade item) {
097:                if (metadataList == null) {
098:                    return; // no metadata found
099:                }
100:
101:                for (int i = 0; i < metadataList.size(); i++) {
102:                    String meta = (String) metadataList.get(i);
103:                    StringTokenizer st = new StringTokenizer(meta, "|");
104:                    String key = null;
105:                    String value = null;
106:                    if (st.hasMoreTokens()) {
107:                        key = st.nextToken().trim();
108:                    }
109:                    if (st.hasMoreTokens()) {
110:                        value = st.nextToken().trim();
111:                        if (key.equalsIgnoreCase("TIMEALLOWED")) {
112:                            item.setDuration(new Integer(value));
113:                        } else if (key.equalsIgnoreCase("NUM_OF_ATTEMPTS")) {
114:                            item.setTriesAllowed(new Integer(value));
115:
116:                        }
117:                        /*
118:                        // these metadata names are different in QTI and Authoring, 
119:                        public static final String OBJECTIVE = "OBJECTIVE";
120:                        public static final String KEYWORD= "KEYWORD";
121:                        public static final String RUBRIC= "RUBRIC";
122:                         */
123:                        else if (key.equalsIgnoreCase("ITEM_KEYWORD")) {
124:                            item.addItemMetaData("KEYWORD", value);
125:                        } else if (key.equalsIgnoreCase("ITEM_OBJECTIVE")) {
126:                            item.addItemMetaData("OBJECTIVE", value);
127:                        } else if (key.equalsIgnoreCase("ITEM_RUBRIC")) {
128:                            item.addItemMetaData("RUBRIC", value);
129:                        } else if (key.equalsIgnoreCase("ATTACHMENT")) {
130:                            value = meta.substring(meta.indexOf("|") + 1);
131:                            item.addItemAttachmentMetaData(value);
132:                        } else {
133:                            log.debug("key now is " + key);
134:                            item.addItemMetaData(key, value);
135:                        }
136:                    }
137:                }
138:            }
139:
140:            public String getSubmissionMessage() {
141:                String submissionMsg = null;
142:                if (metadataList == null) {
143:                    return null; // no metadata found
144:                }
145:
146:                for (int i = 0; i < metadataList.size(); i++) {
147:                    String meta = (String) metadataList.get(i);
148:                    StringTokenizer st = new StringTokenizer(meta, "|");
149:                    String key = null;
150:                    String value = null;
151:
152:                    if (st.hasMoreTokens()) {
153:                        key = st.nextToken().trim();
154:                    }
155:
156:                    // SAK-6831: if it's submissionMessage, do not store in sam_assessmentmetadata_t, because the value is 255 char.
157:                    if ("SUBMISSION_MESSAGE".equalsIgnoreCase(key)) {
158:
159:                        if (st.hasMoreTokens()) {
160:                            value = st.nextToken().trim();
161:                            submissionMsg = value;
162:
163:                        }
164:                    }
165:                }
166:                return submissionMsg;
167:            }
168:
169:            /**
170:             * Adds extraction-created list of "|" key value pairs to assessment metadata map, if there are any. Example:
171:             * <metadata type =" list " > FEEDBACK_SHOW_CORRECT_RESPONSE|True </ metadata >
172:             * <metadata type =" list " > FEEDBACK_SHOW_STUDENT_SCORE|True </ metadata > 
173:             * Becomes:TEXT_FORMAT=>HTML etc.
174:             * 
175:             * @param metadataList
176:             *        extraction-created list of "|" key value pairs
177:             * @param assessment
178:             *        the assessment
179:             */
180:            public void addTo(AssessmentFacade assessment) {
181:                if (metadataList == null) {
182:                    return; // no metadata found
183:                }
184:
185:                for (int i = 0; i < metadataList.size(); i++) {
186:                    String meta = (String) metadataList.get(i);
187:                    //log.debug( "meta = "+ meta);
188:                    StringTokenizer st = new StringTokenizer(meta, "|");
189:                    String key = null;
190:                    String value = null;
191:                    if (st.hasMoreTokens()) {
192:                        key = st.nextToken().trim();
193:                    }
194:                    //log.debug( "key  = "+ key );
195:                    // translate XML metadata strings to assessment metadata strings here
196:                    // key to patch up the difference between Daisy's and earlier labels
197:                    // that are compatible with the earlier beta version of Samigo
198:                    if ("AUTHORS".equals(key)) {
199:                        key = AssessmentMetaDataIfc.AUTHORS;
200:                    } else if ("ASSESSMENT_KEYWORDS".equals(key)) {
201:                        key = AssessmentMetaDataIfc.KEYWORDS;
202:                    } else if ("ASSESSMENT_OBJECTIVES".equals(key)) {
203:                        key = AssessmentMetaDataIfc.OBJECTIVES;
204:                    } else if ("ASSESSMENT_RUBRICS".equals(key)) {
205:                        key = AssessmentMetaDataIfc.RUBRICS;
206:                    } else if ("BGCOLOR".equals(key)) {
207:                        key = AssessmentMetaDataIfc.BGCOLOR;
208:                    } else if ("BGIMG".equals(key)) {
209:                        key = AssessmentMetaDataIfc.BGIMAGE;
210:                    } else if ("COLLECT_ITEM_METADATA".equals(key)) {
211:                        key = "hasMetaDataForQuestions";
212:
213:                    }
214:
215:                    // for backwards compatibility with version 1.5 exports.
216:                    else if ("ASSESSMENT_RELEASED_TO".equals(key)
217:                            && value != null
218:                            && value.indexOf("Authenticated Users") > -1) {
219:                        log
220:                                .debug("Fixing obsolete reference to 'Authenticated Users', setting released to 'Anonymous Users'.");
221:                        value = AuthoringConstantStrings.ANONYMOUS;
222:                    }
223:
224:                    else if ("SUBMISSION_MESSAGE".equalsIgnoreCase(key)) {
225:                        //log.debug("key is submsg " + key);
226:                        // skip
227:                    }
228:
229:                    else if ("ATTACHMENT".equalsIgnoreCase(key)) {
230:                        value = meta.substring(meta.indexOf("|") + 1);
231:                        assessment.addAssessmentAttachmentMetaData(value);
232:                    }
233:
234:                    else if (st.hasMoreTokens()) {
235:                        value = st.nextToken().trim();
236:                        assessment.addAssessmentMetaData(key, value);
237:
238:                    }
239:                }
240:            }
241:
242:            /**
243:             * Turns on editability for everything (ecept template info),
244:             * since we don't know if this  metadata is in the assessment or not,
245:             * or may not want to follow it, even if it is.
246:             *
247:             * The importer of the assesment may also be different than the
248:             * exporter, and may be on a different system or have different
249:             * templates, or policies, even if using this softwware.
250:             *
251:             * @param assessment
252:             */
253:            public void setDefaults(AssessmentFacade assessment) {
254:                // turn this off specially, as template settings are meaningless on import
255:                assessment.addAssessmentMetaData(
256:                        "templateInfo_isInstructorEditable", "false");
257:
258:                for (int i = 0; i < editableKeys.length; i++) {
259:                    assessment.addAssessmentMetaData(editableKeys[i], "true");
260:                }
261:
262:            }
263:
264:            public List getMetadataList() {
265:                return metadataList;
266:            }
267:
268:            public void setMetadataList(List metadataList) {
269:                this.metadataList = metadataList;
270:            }
271:
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.