Source Code Cross Referenced for ItemBean.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) 


0001:        /**********************************************************************************
0002:         * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/author/ItemBean.java $
0003:         * $Id: ItemBean.java 28716 2007-04-12 00:31:23Z ajpoland@iupui.edu $
0004:         ***********************************************************************************
0005:         *
0006:         * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
0007:         *
0008:         * Licensed under the Educational Community License, Version 1.0 (the"License");
0009:         * you may not use this file except in compliance with the License.
0010:         * You may obtain a copy of the License at
0011:         *
0012:         *      http://www.opensource.org/licenses/ecl1.php
0013:         *
0014:         * Unless required by applicable law or agreed to in writing, software
0015:         * distributed under the License is distributed on an "AS IS" BASIS,
0016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017:         * See the License for the specific language governing permissions and
0018:         * limitations under the License.
0019:         *
0020:         **********************************************************************************/package org.sakaiproject.tool.assessment.ui.bean.author;
0021:
0022:        import java.io.Serializable;
0023:        import java.util.ArrayList;
0024:        import java.util.Iterator;
0025:        import org.sakaiproject.util.ResourceLoader;
0026:
0027:        import javax.faces.application.FacesMessage;
0028:        import javax.faces.context.FacesContext;
0029:        import javax.faces.event.ValueChangeEvent;
0030:
0031:        import org.sakaiproject.tool.assessment.facade.TypeFacade;
0032:        import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
0033:
0034:        /**
0035:         * UI bean for authoring an Item
0036:         * $Id: ItemBean.java 28716 2007-04-12 00:31:23Z ajpoland@iupui.edu $
0037:         */
0038:        public class ItemBean implements  Serializable {
0039:            //private static Log log = LogFactory.getLog(ItemBean.class);
0040:
0041:            // internal use
0042:            private static final String answerNumbers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
0043:            /** Use serialVersionUID for interoperability. */
0044:            private final static long serialVersionUID = 8266438770394956874L;
0045:
0046:            // for item editing
0047:            private String itemText;
0048:            private String itemId;
0049:            private String itemType;
0050:            private String itemScore = "0";
0051:            private String[] answers;
0052:            private String[] answerLabels; //  such as A, B, C
0053:            private String[] corrAnswers; // store checkbox values(labels) for multiple correct answers, as in mcmc type
0054:            private String corrAnswer; // store text value for single correct answer, as in true/false , mcsc, also used for essay's model answer
0055:            private ArrayList multipleChoiceAnswers; // store List of answers multiple choice items, ArrayList of AnswerBean
0056:            private String additionalChoices = "0"; // additonal multiple choice answers to be add. for the select menu
0057:
0058:            private boolean[] choiceCorrectArray;
0059:            private String maxRecordingTime;
0060:            private String maxNumberRecordings;
0061:            private String scaleName;
0062:            private boolean multipleCorrect = false;
0063:            private String multipleCorrectString;
0064:            private String randomized = "false";
0065:            private String rationale = "false";
0066:
0067:            // for matching only
0068:            private String instruction; // matching's question text
0069:            private ArrayList matchItemBeanList; // store List of MatchItemBean, used for Matching only
0070:            private MatchItemBean currentMatchPair; // do not need this ?   store List of MatchItemBeans, used for Matching only
0071:
0072:            // begin DELETEME
0073:            private String[] matches;
0074:            private String[] matchAnswers;
0075:            private String[] matchFeedbackList;
0076:
0077:            // end DELETEME
0078:
0079:            private String corrFeedback = "";
0080:            private String incorrFeedback = "";
0081:            private String generalFeedback = "";
0082:
0083:            private String objective;
0084:            private String keyword;
0085:            private String rubric;
0086:            private String timeAllowed;
0087:            private String numAttempts;
0088:
0089:            private String outcome;
0090:            private String poolOutcome;
0091:
0092:            private String selectedPool; // pool id for the item to be added to
0093:            private String origPool; // pool id for the item to be added to
0094:            private String origSection; // section id for the item to be added to
0095:            private String selectedSection = "0"; // section id for the item to be assigned to
0096:
0097:            private boolean caseSensitiveForFib = false;
0098:            private boolean mutuallyExclusiveForFib = false;
0099:            private boolean caseSensitiveForFin = false;
0100:            private boolean mutuallyExclusiveForFin = false;
0101:            //not used now. This is used to deteremine whether 
0102:            //we show the checkbox for mutually exclusive, 
0103:            //depending on the answers entered in the wysiwyg editor.   
0104:            private boolean showMutuallyExclusiveForFibCheckbox = false;
0105:            private boolean showMutuallyExclusiveForFinCheckbox = false;
0106:
0107:            /**
0108:             * Creates a new ItemBean object.
0109:             */
0110:            public ItemBean() {
0111:
0112:            }
0113:
0114:            /**
0115:             * @return
0116:             */
0117:
0118:            public String getOutcome() {
0119:                return outcome;
0120:            }
0121:
0122:            public void setOutcome(String outcome) {
0123:                this .outcome = outcome;
0124:            }
0125:
0126:            public String getPoolOutcome() {
0127:                return poolOutcome;
0128:            }
0129:
0130:            public void setPoolOutcome(String poolOutcome) {
0131:                this .poolOutcome = poolOutcome;
0132:            }
0133:
0134:            public String getItemId() {
0135:                return itemId;
0136:            }
0137:
0138:            /**
0139:             * @param string
0140:             */
0141:            public void setItemId(String string) {
0142:                itemId = string;
0143:            }
0144:
0145:            public String getItemType() {
0146:                return itemType;
0147:            }
0148:
0149:            public void setItemType(String param) {
0150:                this .itemType = param;
0151:            }
0152:
0153:            public String getItemText() {
0154:                return itemText;
0155:            }
0156:
0157:            public void setItemText(String itemText) {
0158:                this .itemText = itemText;
0159:            }
0160:
0161:            /**
0162:             * value of question
0163:             * @return score it is worth
0164:             */
0165:            public String getItemScore() {
0166:                return itemScore;
0167:            }
0168:
0169:            /**
0170:             * value of question
0171:             * @param score
0172:             */
0173:            public void setItemScore(String score) {
0174:                this .itemScore = score;
0175:            }
0176:
0177:            /**
0178:             * value of question
0179:             * @return score it is worth
0180:             */
0181:            public String getAdditionalChoices() {
0182:                return additionalChoices;
0183:            }
0184:
0185:            /**
0186:             * value of question
0187:             * @param score
0188:             */
0189:            public void setAdditionalChoices(String size) {
0190:                this .additionalChoices = size;
0191:            }
0192:
0193:            /**
0194:             * ordered array of answers
0195:             * @return
0196:             */
0197:            public String[] getAnswerLabels() {
0198:                return answerLabels;
0199:            }
0200:
0201:            /**
0202:             * set ordered array of answers
0203:             * @param answers ordered array of answers
0204:             */
0205:            public void setAnswerLabels(String[] answers) {
0206:                this .answerLabels = answers;
0207:            }
0208:
0209:            /**
0210:             * ordered array of answers
0211:             * @return
0212:             */
0213:            public String[] getAnswers() {
0214:                return answers;
0215:            }
0216:
0217:            /**
0218:             * set ordered array of answers
0219:             * @param answers ordered array of answers
0220:             */
0221:            public void setAnswers(String[] answers) {
0222:                this .answers = answers;
0223:            }
0224:
0225:            /**
0226:             * ordered array of correct answers
0227:             * @return
0228:             */
0229:            public String getCorrAnswer() {
0230:                return corrAnswer;
0231:            }
0232:
0233:            /**
0234:             * set correct answer for True/False
0235:             * @param answers ordered array of correct answers
0236:             */
0237:            public void setCorrAnswer(String answer) {
0238:                this .corrAnswer = answer;
0239:            }
0240:
0241:            /**
0242:             * ordered array of correct answers
0243:             * @return
0244:             */
0245:            public String[] getCorrAnswers() {
0246:                return corrAnswers;
0247:            }
0248:
0249:            /**
0250:             * set ordered array of correct answers
0251:             * @param answers ordered array of correct answers
0252:             */
0253:            public void setCorrAnswers(String[] answers) {
0254:                this .corrAnswers = answers;
0255:            }
0256:
0257:            /**
0258:             * get 1, 2, 3... for each answer
0259:             * @param n
0260:             * @return
0261:             */
0262:            public int[] getAnswerCounter() {
0263:                int n = answers.length;
0264:                int count[] = new int[n];
0265:                for (int i = 0; i < n; i++) {
0266:                    count[i] = i;
0267:                }
0268:                return count;
0269:            }
0270:
0271:            /**
0272:             * get the nth answer
0273:             * @param n
0274:             * @return the nth answer
0275:             */
0276:            public String getAnswer(int n) {
0277:                return this .answers[n];
0278:            }
0279:
0280:            /**
0281:             * set the nth answer
0282:             * @param n
0283:             * @param answer the nth answer
0284:             */
0285:            public void setAnswer(int n, String answer) {
0286:                this .answers[n] = answer;
0287:            }
0288:
0289:            /**
0290:             * Return the nth answer number, "A", "B", "C" etc.
0291:             * @param n
0292:             * @return
0293:             */
0294:            public String getAnswerNumber(int n) {
0295:                String anum = "";
0296:                // this accomodates REALLY large numbers of answers
0297:                while (n > 25) {
0298:                    anum += "X";
0299:                    n -= 25;
0300:                }
0301:                anum += answerNumbers.substring(n);
0302:
0303:                return anum;
0304:            }
0305:
0306:            /**
0307:             * This is an array of correct/not correct flags
0308:             * @return the array of correct/not correct flags
0309:             */
0310:            public boolean[] getChoiceCorrectArray() {
0311:                return choiceCorrectArray;
0312:            }
0313:
0314:            /**
0315:             * set array of correct/not correct flags
0316:             * @param choiceCorrectArray of correct/not correct flags
0317:             */
0318:            public void setChoiceCorrectArray(boolean[] choiceCorrectArray) {
0319:                this .choiceCorrectArray = choiceCorrectArray;
0320:            }
0321:
0322:            public boolean isCorrectChoice(String label) {
0323:                boolean returnVal = false;
0324:                ArrayList corranswersList = ContextUtil
0325:                        .paramArrayValueLike("mccheckboxes");
0326:                Iterator iter = corranswersList.iterator();
0327:                while (iter.hasNext()) {
0328:
0329:                    String currentcorrect = (String) iter.next();
0330:                    if (currentcorrect.trim().equals(label)) {
0331:                        returnVal = true;
0332:                        break;
0333:                    } else {
0334:                        returnVal = false;
0335:                    }
0336:                }
0337:                return returnVal;
0338:            }
0339:
0340:            /**
0341:             * is  the nth choice correct?
0342:             * @param n
0343:             * @return
0344:             */
0345:            public boolean isCorrectChoice(int n) {
0346:                return choiceCorrectArray[n];
0347:            }
0348:
0349:            /**
0350:             * set the nth choice correct?
0351:             * @param n
0352:             * @param correctChoice true if it is
0353:             */
0354:            public void setCorrectChoice(int n, boolean correctChoice) {
0355:                this .choiceCorrectArray[n] = correctChoice;
0356:            }
0357:
0358:            /**
0359:             * for audio recording
0360:             * @return maximum time for recording
0361:             */
0362:            public String getMaxRecordingTime() {
0363:                return maxRecordingTime;
0364:            }
0365:
0366:            /**
0367:             * for audio recording
0368:             * @param maxRecordingTime maximum time for recording
0369:             */
0370:            public void setMaxRecordingTime(String maxRecordingTime) {
0371:                this .maxRecordingTime = maxRecordingTime;
0372:            }
0373:
0374:            /**
0375:             * for audio recording
0376:             * @return maximum attempts
0377:             */
0378:            public String getMaxNumberRecordings() {
0379:                return maxNumberRecordings;
0380:            }
0381:
0382:            /**
0383:             * set audio recording maximum attempts
0384:             * @param maxNumberRecordings
0385:             */
0386:            public void setMaxNumberRecordings(String maxNumberRecordings) {
0387:                this .maxNumberRecordings = maxNumberRecordings;
0388:            }
0389:
0390:            /**
0391:             * for survey
0392:             * @return the scale
0393:             */
0394:            public String getScaleName() {
0395:                return scaleName;
0396:            }
0397:
0398:            /**
0399:             * set the survey scale
0400:             * @param scaleName
0401:             */
0402:            public void setScaleName(String scaleName) {
0403:                this .scaleName = scaleName;
0404:            }
0405:
0406:            /**
0407:             * for incorrect feedback
0408:             * @return the incorrFeedback
0409:             */
0410:            public String getIncorrFeedback() {
0411:                return incorrFeedback;
0412:            }
0413:
0414:            /**
0415:             * set the incorrectfeedback
0416:             * @param incorrFeedback
0417:             */
0418:            public void setIncorrFeedback(String param) {
0419:                this .incorrFeedback = param;
0420:            }
0421:
0422:            /**
0423:             * for correct feedback
0424:             * @return the scale
0425:             */
0426:            public String getCorrFeedback() {
0427:                return corrFeedback;
0428:            }
0429:
0430:            /**
0431:             * set the corrfeedback
0432:             * @param corrfeedback
0433:             */
0434:            public void setCorrFeedback(String param) {
0435:                this .corrFeedback = param;
0436:            }
0437:
0438:            /**
0439:             * for general feedback
0440:             * @return the scale
0441:             */
0442:            public String getGeneralFeedback() {
0443:                return generalFeedback;
0444:            }
0445:
0446:            /**
0447:             * set the generalfeedback
0448:             * @param generalfeedback
0449:             */
0450:            public void setGeneralFeedback(String param) {
0451:                this .generalFeedback = param;
0452:            }
0453:
0454:            /**
0455:             * get keyword metadata
0456:             */
0457:            public String getKeyword() {
0458:                return keyword;
0459:            }
0460:
0461:            /**
0462:             * set metadata
0463:             * @param param
0464:             */
0465:            public void setKeyword(String param) {
0466:                this .keyword = param;
0467:            }
0468:
0469:            /**
0470:             * get objective metadata
0471:             */
0472:            public String getObjective() {
0473:                return objective;
0474:            }
0475:
0476:            /**
0477:             * set metadata
0478:             * @param param
0479:             */
0480:            public void setObjective(String param) {
0481:                this .objective = param;
0482:            }
0483:
0484:            /**
0485:             * get rubric metadata
0486:             */
0487:            public String getRubric() {
0488:                return rubric;
0489:            }
0490:
0491:            /**
0492:             * set metadata
0493:             * @param param
0494:             */
0495:            public void setRubric(String param) {
0496:                this .rubric = param;
0497:            }
0498:
0499:            public String getTimeAllowed() {
0500:                return timeAllowed;
0501:            }
0502:
0503:            public void setTimeAllowed(String param) {
0504:                this .timeAllowed = param;
0505:            }
0506:
0507:            public String getNumAttempts() {
0508:                return numAttempts;
0509:            }
0510:
0511:            public void setNumAttempts(String param) {
0512:                this .numAttempts = param;
0513:            }
0514:
0515:            /**
0516:             * for multiple choice questions, multiple correct?
0517:             * @return
0518:             */
0519:            public String getMultipleCorrectString() {
0520:                return multipleCorrectString;
0521:            }
0522:
0523:            /**
0524:             * for multiple choice questions
0525:             * @param multipleCorrectString  multiple correct?
0526:             */
0527:            public void setMultipleCorrectString(String multipleCorrect) {
0528:                this .multipleCorrectString = multipleCorrect;
0529:            }
0530:
0531:            public void setMultipleChoiceAnswers(ArrayList list) {
0532:                this .multipleChoiceAnswers = list;
0533:            }
0534:
0535:            public void setMatchItemBeanList(ArrayList list) {
0536:                this .matchItemBeanList = list;
0537:            }
0538:
0539:            public ArrayList getMatchItemBeanList() {
0540:                return matchItemBeanList;
0541:            }
0542:
0543:            public void setCurrentMatchPair(MatchItemBean param) {
0544:                this .currentMatchPair = param;
0545:            }
0546:
0547:            public MatchItemBean getCurrentMatchPair() {
0548:                return currentMatchPair;
0549:            }
0550:
0551:            /**
0552:             * for multiple choice questions, multiple correct?
0553:             * @return
0554:             */
0555:            public boolean getMultipleCorrect() {
0556:                return multipleCorrect;
0557:            }
0558:
0559:            /**
0560:             * for multiple choice questions
0561:             * @param multipleCorrect multiple correct?
0562:             */
0563:            public void setMultipleCorrect(boolean multipleCorrect) {
0564:                this .multipleCorrect = multipleCorrect;
0565:            }
0566:
0567:            /**
0568:             * Is question to be randomized?
0569:             * @return true or false
0570:             */
0571:            public String getRandomized() {
0572:                return randomized;
0573:            }
0574:
0575:            /**
0576:             * Is question to be randomized?
0577:             * @param randomized true if it is
0578:             */
0579:            public void setRandomized(String randomized) {
0580:                this .randomized = randomized;
0581:            }
0582:
0583:            public String getInstruction() {
0584:                return instruction;
0585:            }
0586:
0587:            public void setInstruction(String param) {
0588:                this .instruction = param;
0589:            }
0590:
0591:            /**
0592:             * has rationale ?
0593:             * @return true or false
0594:             */
0595:            public String getRationale() {
0596:                return rationale;
0597:            }
0598:
0599:            /**
0600:             * @param rationale true if it is
0601:             */
0602:            public void setRationale(String param) {
0603:                this .rationale = param;
0604:            }
0605:
0606:            /**
0607:             * Maching only.
0608:             * Get an array of match Strings.
0609:             * @return array of match Strings.
0610:             */
0611:            public String[] getMatches() {
0612:                return matches;
0613:            }
0614:
0615:            /**
0616:             * Maching only.
0617:             * Set array of match Strings.
0618:             * @param matches array of match Strings.
0619:             */
0620:            public void setMatches(String[] matches) {
0621:                this .matches = matches;
0622:            }
0623:
0624:            /**
0625:             * Maching only.
0626:             * Get the nth match String.
0627:             * @param n
0628:             * @return the nth match String
0629:             */
0630:            public String getMatch(int n) {
0631:                return matches[n];
0632:            }
0633:
0634:            /**
0635:             * Maching only.
0636:             * Set the nth match String.
0637:             * @param n
0638:             * @param match
0639:             */
0640:            public void setMatch(int n, String match) {
0641:                matches[n] = match;
0642:            }
0643:
0644:            /**
0645:             * get 1, 2, 3... for each match
0646:             * @param n
0647:             * @return
0648:             */
0649:            public int[] getMatchCounter() {
0650:                int n = matches.length;
0651:                int count[] = new int[n];
0652:                for (int i = 0; i < n; i++) {
0653:                    count[i] = i;
0654:                }
0655:                return count;
0656:            }
0657:
0658:            /*
0659:
0660:             public ArrayList getAnswerSelectList() {
0661:             ArrayList list = new ArrayList();
0662:
0663:             for (int i = 0; i < answers.length; i++) {
0664:             SelectItem selection = new SelectItem();
0665:             selection.setLabel(getAnswerNumber(i));
0666:             selection.setValue(answers[i]);
0667:             list.add(selection);
0668:             }
0669:
0670:             return list;
0671:             }
0672:             */
0673:
0674:            /**
0675:             * Corresponding answer number list ordered for match
0676:             * @return answer number
0677:             */
0678:            public String[] getMatchAnswers() {
0679:                return matchAnswers;
0680:            }
0681:
0682:            /**
0683:             * Corresponding answer number list ordered for match
0684:             * @param matchAnswers answer number list ordered for match
0685:             */
0686:            public void setMatchAnswers(String[] matchAnswers) {
0687:                this .matchAnswers = matchAnswers;
0688:            }
0689:
0690:            /**
0691:             * Corresponding answer number for nth match
0692:             * @param n
0693:             * @return
0694:             */
0695:            public String getMatchAnswer(int n) {
0696:                return matchAnswers[n];
0697:            }
0698:
0699:            /**
0700:             * set answer number for nth match
0701:             * @param n
0702:             * @param matchAnswer
0703:             */
0704:            public void setMatchAnswer(int n, String matchAnswer) {
0705:                matchAnswers[n] = matchAnswer;
0706:            }
0707:
0708:            /**
0709:             * feedback for nth match
0710:             * @param n
0711:             * @return     feedback for nth match
0712:
0713:             */
0714:            public String getMatchFeedback(int n) {
0715:                return matchFeedbackList[n];
0716:            }
0717:
0718:            /**
0719:             * set feedback for nth match
0720:             * @param n
0721:             * @param matchFeedback feedback for match
0722:             */
0723:            public void setMatchFeedback(int n, String matchFeedback) {
0724:                this .matchFeedbackList[n] = matchFeedback;
0725:            }
0726:
0727:            /**
0728:             * array of matching feeback
0729:             * @return array of matching feeback
0730:             */
0731:            public String[] getMatchFeedbackList() {
0732:                return matchFeedbackList;
0733:            }
0734:
0735:            /**
0736:             * set array of matching feeback
0737:             * @param matchFeedbackList array of matching feeback
0738:             */
0739:            public void setMatchFeedbackList(String[] matchFeedbackList) {
0740:                this .matchFeedbackList = matchFeedbackList;
0741:            }
0742:
0743:            /**
0744:             * String value of selected section id
0745:             * @return String value of selected section id
0746:             */
0747:            public String getSelectedSection() {
0748:                return selectedSection;
0749:            }
0750:
0751:            /**
0752:             * set the String value of selected section id
0753:             * @param selectedSection String value of selected section id
0754:             */
0755:            public void setSelectedSection(String selectedSection) {
0756:                this .selectedSection = selectedSection;
0757:            }
0758:
0759:            /**
0760:             * String value of selected pool id
0761:             * @return String value of selected pool id
0762:             */
0763:            public String getSelectedPool() {
0764:                return selectedPool;
0765:            }
0766:
0767:            /**
0768:             * set the String value of selected pool id
0769:             * @param selectedPool String value of selected pool id
0770:             */
0771:            public void setSelectedPool(String selectedPool) {
0772:                this .selectedPool = selectedPool;
0773:            }
0774:
0775:            /**
0776:             * String value of selected pool id
0777:             * @return String value of selected pool id
0778:             */
0779:            public String getOrigPool() {
0780:                return origPool;
0781:            }
0782:
0783:            /**
0784:             * set the String value of selected pool id
0785:             * @param selectedPool String value of selected pool id
0786:             */
0787:            public void setOrigPool(String param) {
0788:                this .origPool = param;
0789:
0790:            }
0791:
0792:            /**
0793:             * String value of selected pool id
0794:             * @return String value of selected pool id
0795:             */
0796:            public String getOrigSection() {
0797:                return origSection;
0798:            }
0799:
0800:            /**
0801:             * set the String value of selected pool id
0802:             * @param selectedSection String value of selected pool id
0803:             */
0804:            public void setOrigSection(String param) {
0805:                this .origSection = param;
0806:
0807:            }
0808:
0809:            public ArrayList getMultipleChoiceAnswers() {
0810:                ArrayList list = new ArrayList();
0811:                // build a default list of 4 choices, a, b, c, d,
0812:                if (multipleChoiceAnswers != null) {
0813:                    return multipleChoiceAnswers;
0814:                    // for modify
0815:                } else {
0816:                    int defaultlength = 4;
0817:                    for (int i = 0; i < defaultlength; i++) {
0818:                        AnswerBean answerbean = new AnswerBean();
0819:                        answerbean.setSequence(new Long(i + 1));
0820:                        answerbean.setLabel(AnswerBean.getChoiceLabels()[i]);
0821:
0822:                        list.add(answerbean);
0823:
0824:                    }
0825:
0826:                    setMultipleChoiceAnswers(list);
0827:                }// else
0828:
0829:                return list;
0830:            }
0831:
0832:            public void toggleChoiceTypes(ValueChangeEvent event) {
0833:
0834:                //FacesContext context = FacesContext.getCurrentInstance();
0835:                String type = (String) event.getNewValue();
0836:                if ((type == null)
0837:                        || type.equals(TypeFacade.MULTIPLE_CHOICE.toString())) {
0838:                    setMultipleCorrect(false);
0839:                    setMultipleCorrectString(TypeFacade.MULTIPLE_CHOICE
0840:                            .toString());
0841:                    setItemType(TypeFacade.MULTIPLE_CHOICE.toString());
0842:                } else {
0843:                    setMultipleCorrect(true);
0844:                    setMultipleCorrectString(TypeFacade.MULTIPLE_CORRECT
0845:                            .toString());
0846:                    setItemType(TypeFacade.MULTIPLE_CORRECT.toString());
0847:                }
0848:
0849:            }
0850:
0851:            /*  
0852:             //  this doesn't seem to be used
0853:             public void addChoices(ValueChangeEvent event) {
0854:             // build a default list of 4 choices, a, b, c, d,
0855:             FacesContext context = FacesContext.getCurrentInstance();
0856:             String newvalue = (String) event.getNewValue();
0857:             ArrayList list = getMultipleChoiceAnswers(); // get existing list
0858:             if (list!=null) {
0859:             // add additional answer bean
0860:             int currentsize = list.size();
0861:             int newlength = currentsize+ new Integer(newvalue).intValue();
0862:             for (int i=currentsize; i<newlength; i++){
0863:             AnswerBean answerbean = new AnswerBean();
0864:             answerbean.setSequence(new Long(i+1));
0865:             answerbean.setLabel(AnswerBean.choiceLabels[i]);
0866:             list.add(answerbean);
0867:
0868:             }
0869:             }
0870:             setMultipleChoiceAnswers(list);
0871:             setAdditionalChoices("0");
0872:
0873:
0874:
0875:             }
0876:             */
0877:
0878:            public String addChoicesAction() {
0879:                // build a default list of 4 choices, a, b, c, d,
0880:                //   FacesContext context = FacesContext.getCurrentInstance();
0881:                //   String newvalue = (String) event.getNewValue();
0882:                String newvalue = this .getAdditionalChoices();
0883:                ArrayList list = getMultipleChoiceAnswers(); // get existing list
0884:                if (list != null) {
0885:                    // add additional answer bean
0886:                    int currentsize = list.size();
0887:                    int newlength = currentsize
0888:                            + new Integer(newvalue).intValue();
0889:                    if (newlength <= 26) {
0890:                        for (int i = currentsize; i < newlength; i++) {
0891:                            AnswerBean answerbean = new AnswerBean();
0892:                            answerbean.setSequence(new Long(i + 1));
0893:                            answerbean
0894:                                    .setLabel(AnswerBean.getChoiceLabels()[i]);
0895:                            list.add(answerbean);
0896:
0897:                        }
0898:                        setMultipleChoiceAnswers(list);
0899:                        setAdditionalChoices("0");
0900:
0901:                        // if mcmc, need to set corrAnswers 
0902:                        if (getMultipleCorrect()) {
0903:                            ArrayList corranswersList = ContextUtil
0904:                                    .paramArrayValueLike("mccheckboxes");
0905:                            int corrsize = corranswersList.size();
0906:                            int counter = 0;
0907:                            String[] corrchoices = new String[corrsize];
0908:                            Iterator iter = corranswersList.iterator();
0909:                            while (iter.hasNext()) {
0910:
0911:                                String currentcorrect = (String) iter.next();
0912:                                corrchoices[counter] = currentcorrect;
0913:                                counter++;
0914:                            }
0915:                            this .setCorrAnswers(corrchoices);
0916:                        }
0917:                    } else {
0918:                        //print error
0919:                        FacesContext context = FacesContext
0920:                                .getCurrentInstance();
0921:                        ResourceLoader rb = new ResourceLoader(
0922:                                "org.sakaiproject.tool.assessment.bundle.AuthorMessages");
0923:                        context.addMessage(null, new FacesMessage(rb
0924:                                .getString("MCanswer_outofbound_error")));
0925:                    }
0926:
0927:                }
0928:                return "multipleChoiceItem";
0929:            }
0930:
0931:            public String removeChoices() {
0932:                String labelToRemove = ContextUtil.lookupParam("answerid");
0933:                ArrayList corranswersList = ContextUtil
0934:                        .paramArrayValueLike("mccheckboxes");
0935:                Object[] objArray = corranswersList.toArray();
0936:                String[] corrAnswers = new String[objArray.length];
0937:                ArrayList list = getMultipleChoiceAnswers(); // get existing list
0938:                Iterator iter = list.iterator();
0939:                int currentindex = 0;
0940:                int correctIndex = 0;
0941:                boolean delete = false;
0942:                if (list != null) {
0943:                    while (iter.hasNext()) {
0944:                        AnswerBean answerbean = (AnswerBean) iter.next();
0945:                        if (answerbean.getLabel().equals(labelToRemove)) {
0946:                            // delete selected choices
0947:                            iter.remove();
0948:                            delete = true;
0949:                        } else {
0950:                            currentindex = currentindex + 1;
0951:                            // reset sequence and labels , shift the seq/labels after a
0952:                            // choice is deleted
0953:                            answerbean.setSequence(new Long(currentindex));
0954:                            answerbean
0955:                                    .setLabel(AnswerBean.getChoiceLabels()[currentindex - 1]);
0956:                        }
0957:
0958:                        // reset correct answers
0959:                        for (int i = 0; i < objArray.length; i++) {
0960:                            if (!labelToRemove.equals(objArray[i])) {
0961:                                if ((delete && AnswerBean.getChoiceLabels()[currentindex]
0962:                                        .equals(objArray[i]))
0963:                                        || (!delete && AnswerBean
0964:                                                .getChoiceLabels()[currentindex - 1]
0965:                                                .equals(objArray[i]))) {
0966:                                    corrAnswers[correctIndex++] = AnswerBean
0967:                                            .getChoiceLabels()[currentindex - 1];
0968:                                }
0969:                            }
0970:                        }
0971:                    }
0972:                }
0973:                this .setCorrAnswers(corrAnswers);
0974:
0975:                return null;
0976:            }
0977:
0978:            // Huong added for matching
0979:
0980:            public boolean isMatchError() {
0981:                // need to trim, 'cuz in  mozilla, the field is printed as ^M , a new line char. 
0982:                String choice = (currentMatchPair.getChoice().replaceAll(
0983:                        "<^[^(img)(IMG)]*?>", "")).trim();
0984:                String match = (currentMatchPair.getMatch().replaceAll(
0985:                        "<^[^(img)(IMG)]*?>", "")).trim();
0986:
0987:                if (choice == null || choice.equals("") || match == null
0988:                        || match.equals("")) {
0989:                    FacesContext context = FacesContext.getCurrentInstance();
0990:                    ResourceLoader rb = new ResourceLoader(
0991:                            "org.sakaiproject.tool.assessment.bundle.AuthorMessages");
0992:                    context.addMessage(null, new FacesMessage(rb
0993:                            .getString("match_error")));
0994:                    return true;
0995:                }
0996:                return false;
0997:            }
0998:
0999:            public String addMatchPair() {
1000:                if (!isMatchError()) {
1001:
1002:                    /*
1003:                    Iterator biter = this.getMatchItemBeanList().iterator();
1004:                    while(biter.hasNext())
1005:                    {
1006:                      MatchItemBean apair = (MatchItemBean) biter.next();
1007:                    }
1008:                     */
1009:
1010:                    // get existing list
1011:                    ArrayList list = getMatchItemBeanList();
1012:                    MatchItemBean currpair = this .getCurrentMatchPair();
1013:                    if (!currpair.getSequence().equals(new Long(-1))) {
1014:                        // for modify
1015:                        int seqno = currpair.getSequence().intValue() - 1;
1016:                        MatchItemBean newpair = (MatchItemBean) this 
1017:                                .getMatchItemBeanList().get(seqno);
1018:                        newpair.setSequence(currpair.getSequence());
1019:                        newpair.setChoice(currpair.getChoice());
1020:                        newpair.setMatch(currpair.getMatch());
1021:                        newpair.setCorrMatchFeedback(currpair
1022:                                .getCorrMatchFeedback());
1023:                        newpair.setIncorrMatchFeedback(currpair
1024:                                .getIncorrMatchFeedback());
1025:                        newpair.setIsCorrect(Boolean.TRUE);
1026:                    } else {
1027:                        // for new pair
1028:                        MatchItemBean newpair = new MatchItemBean();
1029:                        newpair.setChoice(currpair.getChoice());
1030:                        newpair.setMatch(currpair.getMatch());
1031:                        newpair.setCorrMatchFeedback(currpair
1032:                                .getCorrMatchFeedback());
1033:                        newpair.setIncorrMatchFeedback(currpair
1034:                                .getIncorrMatchFeedback());
1035:                        newpair.setIsCorrect(Boolean.TRUE);
1036:                        newpair.setSequence(new Long(list.size() + 1));
1037:
1038:                        list.add(newpair);
1039:                    }
1040:
1041:                    this .setMatchItemBeanList(list); // get existing list
1042:
1043:                    //debugging
1044:                    /*
1045:                    Iterator iter = list.iterator();
1046:                    while(iter.hasNext())
1047:                    {
1048:                      MatchItemBean apair = (MatchItemBean) iter.next();
1049:                    }
1050:                     */
1051:
1052:                    MatchItemBean matchitem = new MatchItemBean();
1053:                    this .setCurrentMatchPair(matchitem);
1054:                }
1055:                return "matchingItem";
1056:            }
1057:
1058:            public String editMatchPair() {
1059:
1060:                String seqnostr = ContextUtil.lookupParam("sequence");
1061:                int seqno = new Integer(seqnostr).intValue() - 1;
1062:                // get currentmatchpair by sequence.
1063:
1064:                MatchItemBean pairForEdit = (MatchItemBean) this 
1065:                        .getMatchItemBeanList().get(seqno);
1066:                this .setCurrentMatchPair(pairForEdit);
1067:                return "matchingItem";
1068:            }
1069:
1070:            public String removeMatchPair() {
1071:
1072:                String seqnostr = ContextUtil.lookupParam("sequence");
1073:                int seqno = new Integer(seqnostr).intValue() - 1;
1074:                // get currentmatchpair by sequence.
1075:
1076:                this .getMatchItemBeanList().remove(seqno);
1077:                // shift seqno
1078:                Iterator iter = this .getMatchItemBeanList().iterator();
1079:                int i = 1;
1080:                while (iter.hasNext()) {
1081:                    MatchItemBean apair = (MatchItemBean) iter.next();
1082:                    apair.setSequence(new Long(i));
1083:                    i++;
1084:                }
1085:
1086:                // debugging
1087:                /*
1088:                iter = this.getMatchItemBeanList().iterator();
1089:                while(iter.hasNext())
1090:                {
1091:                  MatchItemBean apair = (MatchItemBean) iter.next();
1092:                }
1093:                 */
1094:
1095:                MatchItemBean matchitem = new MatchItemBean();
1096:                this .setCurrentMatchPair(matchitem);
1097:                return "matchingItem";
1098:            }
1099:
1100:            /* not used
1101:
1102:             public ArrayList getMultipleChoiceAnswerSelectList() {
1103:
1104:             ArrayList list = getMultipleChoiceAnswers();
1105:             Iterator iter = list.iterator();
1106:             while(iter.hasNext())
1107:             {
1108:             SelectItem selection = new SelectItem();
1109:             AnswerBean answerbean = (AnswerBean)iter.next();
1110:             selection.setLabel(answerbean.getLabel());
1111:             selection.setValue(answerbean.getLabel());
1112:             list.add(selection);
1113:             }
1114:
1115:             return list;
1116:             }
1117:
1118:             */
1119:
1120:            /**
1121:             * for fib, case sensitive for grading?
1122:             * @return
1123:             */
1124:            public boolean getCaseSensitiveForFib() {
1125:                return caseSensitiveForFib;
1126:            }
1127:
1128:            /**
1129:             * for fib questions
1130:             * @param case sensitive for grading?
1131:             */
1132:            public void setCaseSensitiveForFib(boolean param) {
1133:                this .caseSensitiveForFib = param;
1134:            }
1135:
1136:            /**
1137:             * for fib, Mutually exclusive for multiple answers,  for grading?
1138:             * @return
1139:             */
1140:            public boolean getMutuallyExclusiveForFib() {
1141:                return mutuallyExclusiveForFib;
1142:            }
1143:
1144:            /**
1145:             * for fib questions
1146:             * @param, Mutually exclusive for multiple answers,  for grading?
1147:             */
1148:            public void setMutuallyExclusiveForFib(boolean param) {
1149:                this .mutuallyExclusiveForFib = param;
1150:            }
1151:
1152:            /**
1153:             * for fib, Mutually exclusive for multiple answers,  for grading?
1154:             * @return
1155:             */
1156:            public boolean getShowMutuallyExclusiveForFibCheckbox() {
1157:                return showMutuallyExclusiveForFibCheckbox;
1158:            }
1159:
1160:            /**
1161:             * for fib questions
1162:             * @param, Mutually exclusive for multiple answers,  for grading?
1163:             */
1164:            public void setShowMutuallyExclusiveForFibCheckbox(boolean param) {
1165:                this .showMutuallyExclusiveForFibCheckbox = param;
1166:            }
1167:
1168:            /**
1169:             * for fin, case sensitive for grading?
1170:             * @return
1171:             */
1172:            public boolean getCaseSensitiveForFin() {
1173:                return caseSensitiveForFin;
1174:            }
1175:
1176:            /**
1177:             * for fin questions
1178:             * @param case sensitive for grading?
1179:             */
1180:            public void setCaseSensitiveForFin(boolean param) {
1181:                this .caseSensitiveForFin = param;
1182:            }
1183:
1184:            /**
1185:             * for fin, Mutually exclusive for multiple answers,  for grading?
1186:             * @return
1187:             */
1188:            public boolean getMutuallyExclusiveForFin() {
1189:                return mutuallyExclusiveForFin;
1190:            }
1191:
1192:            /**
1193:             * for fin questions
1194:             * @param, Mutually exclusive for multiple answers,  for grading?
1195:             */
1196:            public void setMutuallyExclusiveForFin(boolean param) {
1197:                this .mutuallyExclusiveForFin = param;
1198:            }
1199:
1200:            /**
1201:             * for fin, Mutually exclusive for multiple answers,  for grading?
1202:             * @return
1203:             */
1204:            public boolean getShowMutuallyExclusiveForFinCheckbox() {
1205:                return showMutuallyExclusiveForFinCheckbox;
1206:            }
1207:
1208:            /**
1209:             * for fin questions
1210:             * @param, Mutually exclusive for multiple answers,  for grading?
1211:             */
1212:            public void setShowMutuallyExclusiveForFinCheckbox(boolean param) {
1213:                this.showMutuallyExclusiveForFinCheckbox = param;
1214:            }
1215:
1216:        }
w_w__w___.___j__av___a2_s__.c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.