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/TemplateBean.java $
003: * $Id: TemplateBean.java 16922 2006-10-09 21:56:09Z ktsao@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 org.navigoproject.osid.assessment.AssessmentServiceDelegate;
023: import java.io.Serializable;
024: import java.text.DateFormat;
025: import java.text.ParseException;
026: import java.text.SimpleDateFormat;
027: import java.util.Date;
028: import java.util.HashMap;
029:
030: import org.sakaiproject.tool.assessment.business.entity.RecordingData;
031:
032: /**
033: * <p> JSF backing bean for Template pages
034: * </p>
035: *
036: */
037: public class TemplateBean implements Serializable {
038: private static final long serialVersionUID = 7526471155622776147L;
039: private HashMap values = new HashMap();
040: private String newName;
041: private String templateName;
042: private String templateAuthor;
043: private String templateDescription;
044: private String itemAccessType = "2";
045: private String displayChunking = "1";
046: private String questionNumbering = "1";
047: private String submissionModel = "1";
048: private String submissionNumber;
049: private String lateHandling = "1";
050: private String autoSave = "1";
051: private String feedbackType = "1";
052: private String feedbackAuthoring = "1";
053: private Boolean feedbackComponent_QuestionText = Boolean.TRUE;
054: private Boolean feedbackComponent_StudentResp = Boolean.TRUE;
055: private Boolean feedbackComponent_CorrectResp = Boolean.TRUE;
056: private Boolean feedbackComponent_StudentScore = Boolean.TRUE;
057: private Boolean feedbackComponent_StudentQuestionScore = Boolean.TRUE;
058: private Boolean feedbackComponent_QuestionLevel = Boolean.TRUE;
059: private Boolean feedbackComponent_SelectionLevel = Boolean.FALSE;
060: private Boolean feedbackComponent_GraderComments = Boolean.TRUE;
061: private Boolean feedbackComponent_Statistics = Boolean.TRUE;
062: private HashMap feedbackTypes = new HashMap();
063: private String anonymousGrading = "1";
064: private String toGradebook = "1";
065: private String recordedScore = "1";
066: private RecordingData recordingData;
067: private String idString;
068: private String createdDate;
069: private String createdBy;
070: private String lastModified;
071: private String lastModifiedBy;
072: private Date modifiedDate;
073: private String outcome;
074:
075: /**
076: * This just sets some defaults.
077: */
078: public TemplateBean() {
079: // Set correct defaults
080: values.put("assessmentAuthor_isInstructorEditable",
081: Boolean.TRUE);
082: values.put("description_isInstructorEditable", Boolean.TRUE);
083: values.put("dueDate_isInstructorEditable", Boolean.TRUE);
084: values.put("releaseDate_isInstructorEditable", Boolean.TRUE);
085: values.put("lateHandling_isInstructorEditable", Boolean.TRUE);
086: values.put("feedbackType_isInstructorEditable", Boolean.TRUE);
087: values.put("feedbackAuthoring_isInstructorEditable",
088: Boolean.TRUE);
089: values.put("feedbackComponents_isInstructorEditable",
090: Boolean.TRUE);
091: values.put("anonymousRelease_isInstructorEditable",
092: Boolean.TRUE);
093: values.put("authenticatedRelease_isInstructorEditable",
094: Boolean.TRUE);
095: }
096:
097: public void setOutcome(String outcome) {
098: this .outcome = outcome;
099: }
100:
101: public String getOutcome() {
102: return outcome;
103: }
104:
105: /**
106: * set value
107: *
108: * @param key
109: * @param value
110: */
111: public void setValue(String key, Object value) {
112: values.put(key, value);
113: }
114:
115: /**
116: * get value
117: *
118: * @param key
119: *
120: * @return
121: */
122: public Object getValue(String key) {
123: if (values.get(key) == null) {
124: return Boolean.FALSE;
125: }
126:
127: return values.get(key);
128: }
129:
130: /**
131: * set value map
132: *
133: * @param newMap
134: */
135: public void setValueMap(HashMap newMap) {
136: values = newMap;
137: }
138:
139: /**
140: * get value map
141: *
142: * @return
143: */
144: public HashMap getValueMap() {
145: return values;
146: }
147:
148: /**
149: * feedback type
150: *
151: * @param key
152: * @param value
153: */
154: public void setFeedbackType(String key, Object value) {
155: values.put(key, value);
156: }
157:
158: /**
159: * feedback tye
160: *
161: * @param key
162: *
163: * @return
164: */
165: public String getFeedbackType(String value) {
166: if (value == null || value.trim().equals(""))
167: return "2";
168: return feedbackType;
169: }
170:
171: /*
172: * feedback Authoring
173: *
174: * @param key
175: * @param value
176:
177: public void setFeedbackAuthoring(String key, Object value)
178: {
179: values.put(key,value);
180: }
181: */
182:
183: /**
184: * feedback Authoring
185: *
186: * @param key
187: *
188: * @return
189:
190: public String getFeedbackAuthoring(String value)
191: {
192: if (value == null || value.trim().equals(""))
193: return "2";
194: return feedbackAuthoring;
195:
196: }
197: */
198:
199: /**
200: * set feedback type map
201: * @param newMap
202: */
203: public void setFeedbackTypeMap(String newType) {
204: feedbackType = newType;
205: }
206:
207: /**
208: * get feedback type mape
209: *
210: * @return
211: */
212: public HashMap getFeedbackTypeMap() {
213: return feedbackTypes;
214: }
215:
216: /**
217: * set feedback authoring map
218: * @param newMap
219:
220: public void setFeedbackAuthoringMap(String newAuthoring)
221: {
222: feedbackAuthoring = newAuthoring;
223: }
224: */
225:
226: /**
227: * get feedback authoring mape
228: *
229: * @return
230:
231: public HashMap getFeedbackAuthoringMap()
232: {
233: return feedbackAuthorings;
234: }
235: */
236:
237: /**
238: * template name
239: *
240: * @param newName the name
241: */
242: public void setNewName(String newName) {
243: this .newName = newName;
244: }
245:
246: /**
247: * tempalte name
248: *
249: * @return the name
250: */
251: public String getNewName() {
252: return checker(newName, "");
253: }
254:
255: /**
256: * template name
257: *
258: * @param newName the name
259: */
260: public void setTemplateName(String newName) {
261: templateName = newName;
262: }
263:
264: /**
265: * tempalte name
266: *
267: * @return the name
268: */
269: public String getTemplateName() {
270: return checker(templateName, "");
271: }
272:
273: /**
274: * suthor
275: *
276: * @param newAuthor aquthor
277: */
278: public void setTemplateAuthor(String newAuthor) {
279: templateAuthor = newAuthor;
280: }
281:
282: /**
283: * author
284: *
285: * @return author
286: */
287: public String getTemplateAuthor() {
288: return checker(templateAuthor, "");
289: }
290:
291: /**
292: * description
293: *
294: * @param newDescription description
295: */
296: public void setTemplateDescription(String newDescription) {
297: templateDescription = newDescription;
298: }
299:
300: /**
301: * description
302: *
303: * @return description
304: */
305: public String getTemplateDescription() {
306: return checker(templateDescription, "");
307: }
308:
309: /**
310: * item access type
311: *
312: * @param newItemAccessType item access type
313: */
314: public void setItemAccessType(String newItemAccessType) {
315: itemAccessType = newItemAccessType;
316: }
317:
318: /**
319: * item access type
320: *
321: * @return item access type
322: */
323: public String getItemAccessType() {
324: if (itemAccessType == null || itemAccessType.trim().equals("")
325: || itemAccessType.equals("0"))
326: return "2";
327: return itemAccessType;
328: }
329:
330: /**
331: * numbering
332: *
333: * @param newQuestionNumbering
334: */
335: public void setQuestionNumbering(String newQuestionNumbering) {
336: questionNumbering = newQuestionNumbering;
337: }
338:
339: /**
340: * numbering
341: *
342: * @return
343: */
344: public String getQuestionNumbering() {
345: if (questionNumbering.equals("0"))
346: return "1";
347: return checker(questionNumbering, "1");
348: }
349:
350: /**
351: * numbering
352: *
353: * @param newDisplayChunking
354: */
355: public void setDisplayChunking(String newDisplayChunking) {
356: displayChunking = newDisplayChunking;
357: }
358:
359: /**
360: * chunking
361: *
362: * @return
363: */
364: public String getDisplayChunking() {
365: if (displayChunking == null
366: || displayChunking.trim().equals("")
367: || displayChunking.equals("0"))
368: return "1";
369: return displayChunking;
370: }
371:
372: /**
373: * submission model
374: *
375: * @param newSubmissionModel submission model
376: */
377: public void setSubmissionModel(String newSubmissionModel) {
378: submissionModel = newSubmissionModel;
379: }
380:
381: /**
382: * submission model
383: *
384: * @return submission model
385: */
386: public String getSubmissionModel() {
387: return submissionModel;
388: }
389:
390: /**
391: * submission number
392: *
393: * @param newSubmissionNumber submission number
394: */
395: public void setSubmissionNumber(String newSubmissionNumber) {
396: submissionNumber = newSubmissionNumber;
397: }
398:
399: /**
400: * submission number
401: *
402: * @return submission number
403: */
404: public String getSubmissionNumber() {
405: return submissionNumber;
406: }
407:
408: /**
409: * autosave
410: *
411: * @param newAutoSave 3
412: */
413: public void setAutoSave(String newAutoSave) {
414: autoSave = newAutoSave;
415: }
416:
417: /**
418: * autosave
419: *
420: * @return
421: */
422: public String getAutoSave() {
423: if (autoSave.equals("0"))
424: return "1";
425: return checker(autoSave, "1");
426: }
427:
428: /**
429: * late handling
430: *
431: * @param newLateHandling late handling
432: */
433: public void setLateHandling(String newLateHandling) {
434: lateHandling = newLateHandling;
435: }
436:
437: /**
438: * late handling
439: *
440: * @return laqte handling
441: */
442: public String getLateHandling() {
443: if (lateHandling.equals("0"))
444: return "1";
445: return checker(lateHandling, "1");
446: }
447:
448: // Feedback
449: public void setFeedbackType(String newFeedbackType) {
450: feedbackType = newFeedbackType;
451: }
452:
453: /**
454: *
455: *
456: * @return feedback type
457: */
458: public String getFeedbackType() {
459: if (feedbackType.equals("0"))
460: return "1";
461: return checker(feedbackType, "1");
462: }
463:
464: // FeedAuthoring
465: public void setFeedbackAuthoring(String newFeedbackAuthoring) {
466: feedbackAuthoring = newFeedbackAuthoring;
467: }
468:
469: /**
470: *
471: *
472: * @return feedback authoring
473: */
474: public String getFeedbackAuthoring() {
475: if (feedbackAuthoring.equals("0"))
476: return "1";
477: return checker(feedbackAuthoring, "1");
478: }
479:
480: /**
481: * feedback component...
482: *
483: * @param newComponent
484: */
485: public void setFeedbackComponent_QuestionText(Boolean newComponent) {
486: feedbackComponent_QuestionText = newComponent;
487: }
488:
489: /**
490: * feedback component...
491: *
492: * @return feedback component...
493: */
494: public Boolean getFeedbackComponent_QuestionText() {
495: return bchecker(feedbackComponent_QuestionText, true);
496: }
497:
498: /**
499: * feedback component...
500: *
501: * @param newComponent feedback component...
502: */
503: public void setFeedbackComponent_StudentResp(Boolean newComponent) {
504: feedbackComponent_StudentResp = newComponent;
505: }
506:
507: /**
508: * feedback component...
509: *
510: * @return feedback component...
511: */
512: public Boolean getFeedbackComponent_StudentResp() {
513: return bchecker(feedbackComponent_StudentResp, true);
514: }
515:
516: /**
517: * feedback component...
518: *
519: * @param newComponent feedback component...
520: */
521: public void setFeedbackComponent_CorrectResp(Boolean newComponent) {
522: feedbackComponent_CorrectResp = newComponent;
523: }
524:
525: /**
526: * feedback component...
527: *
528: * @return feedback component...
529: */
530: public Boolean getFeedbackComponent_CorrectResp() {
531: return bchecker(feedbackComponent_CorrectResp, true);
532: }
533:
534: /**
535: * feedback component...
536: *
537: * @param newComponent feedback component...
538: */
539: public void setFeedbackComponent_StudentScore(Boolean newComponent) {
540: feedbackComponent_StudentScore = newComponent;
541: }
542:
543: /**
544: * feedback component...
545: *
546: * @return feedback component...
547: */
548: public Boolean getFeedbackComponent_StudentScore() {
549: return bchecker(feedbackComponent_StudentScore, true);
550: }
551:
552: /**
553: * feedback component...
554: *
555: * @param newComponent feedback component...
556: */
557: public void setFeedbackComponent_StudentQuestionScore(
558: Boolean newComponent) {
559: feedbackComponent_StudentQuestionScore = newComponent;
560: }
561:
562: /**
563: * feedback component...
564: *
565: * @return feedback component...
566: */
567: public Boolean getFeedbackComponent_StudentQuestionScore() {
568: return bchecker(feedbackComponent_StudentQuestionScore, true);
569: }
570:
571: /**
572: * feedback component...
573: *
574: * @param newComponent feedback component...
575: */
576: public void setFeedbackComponent_QuestionLevel(Boolean newComponent) {
577: feedbackComponent_QuestionLevel = newComponent;
578: }
579:
580: /**
581: * v
582: *
583: * @return feedback component...
584: */
585: public Boolean getFeedbackComponent_QuestionLevel() {
586: return bchecker(feedbackComponent_QuestionLevel, true);
587: }
588:
589: /**
590: * feedback component...
591: *
592: * @param newComponent feedback component...
593: */
594: public void setFeedbackComponent_SelectionLevel(Boolean newComponent) {
595: feedbackComponent_SelectionLevel = newComponent;
596: }
597:
598: /**
599: * feedback component...
600: *
601: * @return feedback component...
602: */
603: public Boolean getFeedbackComponent_SelectionLevel() {
604: return bchecker(feedbackComponent_SelectionLevel, false);
605: }
606:
607: /**
608: * feedback component...
609: *
610: * @param newComponent feedback component...
611: */
612: public void setFeedbackComponent_GraderComments(Boolean newComponent) {
613: feedbackComponent_GraderComments = newComponent;
614: }
615:
616: /**
617: * feedback component...
618: *
619: * @return feedback component...
620: */
621: public Boolean getFeedbackComponent_GraderComments() {
622: return bchecker(feedbackComponent_GraderComments, true);
623: }
624:
625: /**
626: * feedback component...
627: *
628: * @param newComponent feedback component...
629: */
630: public void setFeedbackComponent_Statistics(Boolean newComponent) {
631: feedbackComponent_Statistics = newComponent;
632: }
633:
634: /**
635: * feedback component...
636: *
637: * @return feedback component...
638: */
639: public Boolean getFeedbackComponent_Statistics() {
640: return bchecker(feedbackComponent_Statistics, true);
641: }
642:
643: /**
644: * anonymous grading
645: * @param newAnonymousGrading
646: */
647: public void setAnonymousGrading(String newAnonymousGrading) {
648: anonymousGrading = newAnonymousGrading;
649: }
650:
651: /**
652: * anonymous grading
653: * @return
654: */
655: public String getAnonymousGrading() {
656: if (anonymousGrading.equals("0"))
657: return "1";
658: return checker(anonymousGrading, "1");
659: }
660:
661: /**
662: *
663: *
664: * @param newToGradebook
665: */
666: public void setToGradebook(String newToGradebook) {
667: toGradebook = newToGradebook;
668: }
669:
670: /**
671: *
672: *
673: * @return to what gradebook
674: */
675: public String getToGradebook() {
676: if (toGradebook.equals("0"))
677: return "1";
678: return checker(toGradebook, "1");
679: }
680:
681: /**
682: *
683: *
684: * @param newRecordedScore
685: */
686: public void setRecordedScore(String newRecordedScore) {
687: recordedScore = newRecordedScore;
688: }
689:
690: /**
691: *
692: *
693: * @return the recorded score
694: */
695: public String getRecordedScore() {
696: if (recordedScore.equals("0"))
697: return "1";
698: return checker(recordedScore, "1");
699: }
700:
701: /**
702: * encapsulates audio recording info
703: * @return recording data
704: */
705: public RecordingData getRecordingData() {
706: return this .recordingData;
707: }
708:
709: /**
710: * encapsulates audio recording info
711: * @param rd
712: */
713: public void setRecordingData(RecordingData rd) {
714: this .recordingData = rd;
715: }
716:
717: /**
718: * get id string
719: * @return id
720: */
721: public String getIdString() {
722: return checker(this .idString, "0");
723: }
724:
725: /**
726: * set id string
727: * @param idString
728: */
729: public void setIdString(String idString) {
730: this .idString = idString;
731: }
732:
733: /**
734: * Get created date
735: */
736: public String getCreatedDate() {
737: return checker(createdDate, "N/A");
738: }
739:
740: /**
741: * Set created date
742: */
743: public void setCreatedDate(String newDate) {
744: createdDate = newDate;
745: }
746:
747: /**
748: * Get created by
749: */
750: public String getCreatedBy() {
751: return checker(createdBy, "N/A");
752: }
753:
754: /**
755: * Set created by
756: */
757: public void setCreatedBy(String agent) {
758: createdBy = agent;
759: }
760:
761: /**
762: * Get last modified date
763: */
764: public String getLastModified() {
765: return checker(lastModified, "N/A");
766: }
767:
768: public Date getModifiedDate() {
769:
770: DateFormat dateFm = new SimpleDateFormat(
771: "yyyy-MM-dd hh:ss:mm.SSS");
772: try {
773: modifiedDate = dateFm.parse(getLastModified());
774: } catch (ParseException e) {
775: e.printStackTrace();
776: }
777: return modifiedDate;
778:
779: }
780:
781: /**
782: * Set last modified date
783: */
784: public void setLastModified(String newDate) {
785: lastModified = newDate;
786: }
787:
788: /**
789: * Get last modified by
790: */
791: public String getLastModifiedBy() {
792: return checker(lastModifiedBy, "N/A");
793: }
794:
795: /**
796: * Set last modified by
797: */
798: public void setLastModifiedBy(String agent) {
799: lastModifiedBy = agent;
800: }
801:
802: private String checker(String mytest, String mydefault) {
803: if (mytest == null || mytest.trim().equals(""))
804: return mydefault;
805: return mytest;
806: }
807:
808: private Boolean bchecker(Boolean mytest, boolean mydefault) {
809: if (mytest == null)
810: return Boolean.valueOf(mydefault);
811: return mytest;
812: }
813:
814: private String typeId;
815:
816: public void setTypeId(String typeId) {
817: this .typeId = typeId;
818: }
819:
820: public String getTypeId() {
821: return typeId;
822: }
823:
824: }
|