001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/delivery/ItemContentsBean.java $
003: * $Id: ItemContentsBean.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.delivery;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024: import java.util.List;
025: import java.util.Iterator;
026:
027: import org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingData;
028: import org.sakaiproject.tool.assessment.data.ifc.assessment.AnswerIfc;
029: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemDataIfc;
030: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemTextIfc; //import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemAttachmentIfc;
031: import org.sakaiproject.tool.assessment.data.ifc.grading.MediaIfc;
032: import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;
033: import org.sakaiproject.tool.assessment.ui.bean.util.Validator;
034: import org.sakaiproject.tool.assessment.services.GradingService;
035: import org.apache.commons.logging.Log;
036: import org.apache.commons.logging.LogFactory;
037: import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
038:
039: /**
040: * <p>
041: * This bean represents an item
042: * </p>
043: */
044:
045: public class ItemContentsBean implements Serializable {
046: /**
047: *
048: */
049: private static final long serialVersionUID = 6270034338280029897L;
050:
051: private static Log log = LogFactory.getLog(ItemContentsBean.class);
052:
053: // private static ContextUtil cu;
054:
055: private boolean review;
056:
057: private boolean unanswered;
058:
059: private ItemDataIfc itemData;
060:
061: private String gradingComment;
062:
063: private String feedback;
064:
065: private String responseId = "2";
066:
067: private String responseText = "";
068:
069: private String[] responseIds = null;
070:
071: private float points;
072:
073: private float maxPoints;
074:
075: private int number;
076:
077: private ArrayList itemGradingDataArray;
078:
079: private ArrayList answers;
080:
081: private String instruction;
082:
083: private String rationale;
084:
085: private ArrayList matchingArray;
086:
087: private ArrayList fibArray;
088:
089: private ArrayList finArray;
090:
091: private ArrayList selectionArray;
092:
093: private String key;
094:
095: private String sequence;
096:
097: private ArrayList shuffledAnswers;
098:
099: private ArrayList mediaArray;
100:
101: // for audio
102: private Integer duration;
103:
104: private Integer triesAllowed;
105:
106: private Integer attemptsRemaining;
107:
108: // for display/hide score
109: private boolean showStudentScore; // this is to show student assessment
110: // score
111:
112: private boolean showStudentQuestionScore;
113:
114: private String pointsDisplayString;
115:
116: public ItemContentsBean() {
117: }
118:
119: // added by daisyf on 11/22/04
120: public ItemContentsBean(ItemDataIfc itemData) {
121: this .itemData = itemData;
122: setInstruction(this .itemData.getInstruction());
123: Integer sequence = this .itemData.getSequence();
124: if (sequence != null) {
125: setNumber(sequence.intValue());
126: } else {
127: setNumber(1);
128: }
129: }
130:
131: /**
132: * In the case of an ordinary question, this will obtain the a set of text
133: * with one element and return it; in FIB return multiple elements separated
134: * by underscores.
135: *
136: * @return text of question
137: */
138: public String getText() {
139: String text = "";
140:
141: if (itemData != null) {
142: text = itemData.getText();
143: }
144:
145: return text;
146: }
147:
148: /**
149: * This strips text of tags for the table of contents.
150: */
151: public String getStrippedText() {
152: return strip(getText());
153:
154: }
155:
156: public boolean getModelAnswerIsNotEmpty() {
157: String k = getKey();
158: if (k != null)
159: return isNotEmpty(strip(ContextUtil.stringWYSIWYG(k)));
160: else
161: return false;
162: }
163:
164: public boolean getFeedbackIsNotEmpty() {
165: return isNotEmpty(strip(ContextUtil
166: .stringWYSIWYG(getFeedback())));
167: }
168:
169: public boolean getGradingCommentIsNotEmpty() {
170: return isNotEmpty(strip(getGradingComment()));
171: }
172:
173: public String getStrippedKey() {
174: return strip(getKey());
175: }
176:
177: /**
178: * String representation of the rounded points.
179: *
180: * @return String representation of the points.
181: */
182: public float getPoints() {
183: return SectionContentsBean.roundTo2Decimals(points);
184: }
185:
186: /**
187: * String representation of the exact points (unrounded points)
188: *
189: * @return String representation of the points.
190: */
191: public float getExactPoints() {
192: return points;
193: }
194:
195: /**
196: * String representation of the points.
197: *
198: * @param points
199: * String representation of the points.
200: */
201: public void setPoints(float points) {
202: this .points = points;
203: }
204:
205: /**
206: * Does this need review?
207: *
208: * @return true if it is marked for review
209: */
210:
211: /**
212: * String representation of the rounded points.
213: *
214: * @return String representation of the points.
215: */
216: public String getPointsForEdit() {
217: return Float.toString(getPoints());
218: }
219:
220: /**
221: * String representation of the points.
222: *
223: * @param points
224: * String representation of the points.
225: */
226: public void setPointsForEdit(String pointsForEdit) {
227: if (pointsForEdit == null || pointsForEdit.equals("")) {
228: pointsForEdit = "0";
229: }
230: setPoints(Float.parseFloat(pointsForEdit));
231: }
232:
233: public boolean getReview() {
234: if (getItemGradingDataArray().isEmpty()) {
235: return false;
236: }
237: ItemGradingData data = (ItemGradingData) getItemGradingDataArray()
238: .toArray()[0];
239: if (data.getReview() == null) {
240: return false;
241: }
242: return data.getReview().booleanValue();
243: }
244:
245: /**
246: * Does this need review?
247: *
248: * @param review
249: * if true mark for review
250: */
251: public void setReview(boolean preview) {
252: log.debug("setReview(): preview = " + preview);
253: if (getItemGradingDataArray().isEmpty()) {
254: log.debug("setReview(): isEmpty = " + preview);
255: ItemGradingData data = new ItemGradingData();
256: data.setPublishedItemId(itemData.getItemId());
257: if (itemData.getItemTextSet().size() > 0) {
258: ItemTextIfc itemText = (ItemTextIfc) itemData
259: .getItemTextSet().toArray()[0];
260: data.setPublishedItemTextId(itemText.getId());
261: }
262: ArrayList items = new ArrayList();
263: items.add(data);
264: setItemGradingDataArray(items);
265: }
266: Iterator iter = getItemGradingDataArray().iterator();
267: log.debug("setReview(): getItemGradingDataArray size = "
268: + getItemGradingDataArray().size());
269: while (iter.hasNext()) {
270: ItemGradingData data = (ItemGradingData) iter.next();
271: log
272: .debug("setReview(): setreview at the end = "
273: + preview);
274: data.setReview(Boolean.valueOf(preview));
275: }
276: }
277:
278: /**
279: * unanswered?
280: *
281: * @return
282: */
283: public boolean isUnanswered() {
284: if (getItemGradingDataArray().isEmpty()) {
285: return true;
286: }
287: Iterator iter = getItemGradingDataArray().iterator();
288: while (iter.hasNext()) {
289: ItemGradingData data = (ItemGradingData) iter.next();
290: if (getItemData().getTypeId().toString().equals("8")
291: || getItemData().getTypeId().toString()
292: .equals("11")) // fix
293: // for
294: // bug
295: // sam-330
296: {
297: if (data.getAnswerText() != null
298: && !data.getAnswerText().equals("")) {
299: return false;
300: }
301: } else {
302: if (data.getPublishedAnswerId() != null
303: || data.getAnswerText() != null) {
304: return false;
305: }
306: }
307: }
308: return true;
309: }
310:
311: /**
312: * unanswered?
313: *
314: * @param unanswered
315: */
316: public void setUnanswered(boolean unanswered) {
317: this .unanswered = unanswered;
318: }
319:
320: /**
321: * String representation of the max points available for this question.
322: *
323: * @return String representation of the max points.
324: */
325: public float getMaxPoints() {
326: return maxPoints;
327: }
328:
329: /**
330: * String representation of the max points available for this question.
331: *
332: * @return String representation of the max points.
333: */
334: public float getRoundedMaxPoints() {
335: return SectionContentsBean.roundTo2Decimals(maxPoints);
336: }
337:
338: /**
339: * String representation of the max points available for this question.
340: *
341: * @param maxPoints
342: * String representation of the max points available
343: */
344: public void setMaxPoints(float maxPoints) {
345: this .maxPoints = maxPoints;
346: }
347:
348: /**
349: * question number
350: *
351: * @return
352: */
353: public int getNumber() {
354: return number;
355: }
356:
357: /**
358: * question number
359: *
360: * @param number
361: */
362: public void setNumber(int number) {
363: this .number = number;
364: this .itemData.setSequence(new Integer(number));
365: }
366:
367: /**
368: * the item data itself
369: *
370: * @return
371: */
372: public ItemDataIfc getItemData() {
373: return itemData;
374: }
375:
376: /**
377: * the item data itself
378: *
379: * @param itemData
380: */
381: public void setItemData(ItemDataIfc itemData) {
382: this .itemData = itemData;
383: }
384:
385: /**
386: * grading comment
387: *
388: * @return grading comment
389: */
390: public String getGradingComment() {
391: if (gradingComment == null) {
392: return "";
393: }
394: return gradingComment;
395: }
396:
397: /**
398: * grading comment
399: *
400: * @param gradingComment
401: * grading comment
402: */
403: public void setGradingComment(String gradingComment) {
404: this .gradingComment = gradingComment;
405: }
406:
407: /**
408: * item level feedback
409: *
410: * @return the item level feedback
411: */
412: public String getFeedback() {
413: return feedback;
414: }
415:
416: /**
417: * item level feedback
418: *
419: * @param feedback
420: * the item level feedback
421: */
422: public void setFeedback(String feedback) {
423: this .feedback = feedback;
424: }
425:
426: /**
427: * If this is a true-false question return true if it is true, else false.
428: * If it is not a true-false question return false.
429: *
430: * @return true if this is a true true-false question
431: */
432: public boolean getIsTrue() {
433: if (itemData != null) {
434: return itemData.getIsTrue().booleanValue();
435: }
436: return false;
437: }
438:
439: public ArrayList getItemGradingDataArray() {
440: if (itemGradingDataArray == null) {
441: // log.debug("getReview : getitemgradingdataarray is null, size =0
442: // ");
443: return new ArrayList();
444: }
445: // log.debug("getReview: getitemgradingdataarray size " +
446: // itemGradingDataArray.size());
447: return itemGradingDataArray;
448: }
449:
450: public void setItemGradingDataArray(ArrayList newArray) {
451: itemGradingDataArray = newArray;
452: }
453:
454: /* These are helper methods to get data into the database */
455:
456: public String getResponseId() {
457: try {
458: if (selectionArray != null) {
459: Iterator iter = selectionArray.iterator();
460: while (iter.hasNext()) {
461: SelectionBean bean = (SelectionBean) iter.next();
462: if (bean.getResponse()) {
463: return bean.getAnswer().getId().toString();
464: }
465: }
466: return "";
467: }
468: } catch (Exception e) {
469: log.debug("get ResponseId(), okay with t/f. "
470: + e.getMessage());
471: // True/false
472: }
473:
474: try {
475: String response = "";
476: // String response = responseId; //For testing
477: Iterator iter = getItemGradingDataArray().iterator();
478: if (iter.hasNext()) {
479: ItemGradingData data = (ItemGradingData) iter.next();
480: if (data.getPublishedAnswerId() != null) {
481: response = data.getPublishedAnswerId().toString();
482: }
483: }
484: return response;
485: } catch (Exception e) {
486: log.debug("get ResponseId() , okay with t/f. "
487: + e.getMessage());
488: return responseId;
489: }
490: }
491:
492: public void setResponseId(String presponseId) {
493: try {
494: responseId = presponseId;
495:
496: if (selectionArray != null && presponseId != null
497: && !presponseId.trim().equals("")) {
498: Iterator iter = selectionArray.iterator();
499: while (iter.hasNext()) {
500: SelectionBean bean = (SelectionBean) iter.next(); // this
501: // line
502: // will
503: // throw
504: // ClassCastException
505: // for
506: // True/False.
507:
508: if (bean.getAnswer().getId().toString().equals(
509: presponseId)) {
510: bean.setResponse(true);
511: } else {
512: bean.setResponse(false);
513: }
514: }
515: }
516: return;
517: } catch (RuntimeException e) {
518: // True/false
519: log
520: .debug("ClassCastException is okay, the question might be true/false. ");
521: }
522:
523: try {
524: Iterator iter = getItemGradingDataArray().iterator();
525: if (!iter.hasNext()
526: && (presponseId == null || presponseId.equals(""))) {
527: return;
528: }
529: ItemGradingData data = null;
530: if (iter.hasNext()) {
531: data = (ItemGradingData) iter.next();
532: } else {
533: data = new ItemGradingData();
534: data.setPublishedItemId(itemData.getItemId());
535: ItemTextIfc itemText = (ItemTextIfc) itemData
536: .getItemTextSet().toArray()[0];
537: data.setPublishedItemTextId(itemText.getId());
538: ArrayList items = new ArrayList();
539: items.add(data);
540: setItemGradingDataArray(items);
541: }
542: iter = ((ItemTextIfc) itemData.getItemTextSet().toArray()[0])
543: .getAnswerSet().iterator();
544: while (iter.hasNext()) {
545: AnswerIfc answer = (AnswerIfc) iter.next();
546: if (answer.getId().toString().equals(responseId)) {
547: data.setPublishedAnswerId(answer.getId());
548: break;
549: }
550: }
551: } catch (RuntimeException e) {
552: e.printStackTrace();
553: }
554: }
555:
556: public String[] getResponseIds() {
557: try {
558: /*
559: ItemTextIfc text = (ItemTextIfc) itemData.getItemTextSet().toArray()[0];
560: String[] response = new String[text.getAnswerArraySorted().size()];
561: for (int i=0; i<response.length; i++)
562: {
563: Iterator iter = getItemGradingDataArray().iterator();
564: while (iter.hasNext())
565: {
566: ItemGradingData data = (ItemGradingData) iter.next();
567: if (data.getPublishedAnswerId() != null && data.getPublishedAnswerId().toString().equals(text.getAnswerArraySorted().toArray()[i]))
568: {
569: response[i] = data.getPublishedAnswerId().toString();
570: }
571: }
572: } */
573:
574: String[] response = new String[getItemGradingDataArray()
575: .size()];
576: Iterator iter = getItemGradingDataArray().iterator();
577: int i = 0;
578: while (iter.hasNext()) {
579: ItemGradingData data = (ItemGradingData) iter.next();
580: if (data.getPublishedAnswerId() != null) {
581: response[i++] = data.getPublishedAnswerId()
582: .toString();
583: } else {
584: response[i++] = null;
585: }
586: }
587: return response;
588: } catch (Exception e) {
589: e.printStackTrace();
590: return new String[0];
591: }
592: }
593:
594: public void setResponseIds(String[] presponseIds) {
595: try {
596: ArrayList newItems = new ArrayList();
597: responseIds = presponseIds;
598: if (getItemGradingDataArray().isEmpty()
599: && (presponseIds == null || presponseIds.length == 0)) {
600: return;
601: }
602: for (int i = 0; i < presponseIds.length; i++) {
603: ItemGradingData data = null;
604: Iterator iter = getItemGradingDataArray().iterator();
605: while (iter.hasNext()) {
606: ItemGradingData temp = (ItemGradingData) iter
607: .next();
608: if (temp.getPublishedAnswerId() != null
609: && temp.getPublishedAnswerId().toString()
610: .equals(presponseIds[i])) {
611: data = temp;
612: }
613: }
614: if (data == null) {
615: data = new ItemGradingData();
616: data.setPublishedItemId(itemData.getItemId());
617: ItemTextIfc itemText = (ItemTextIfc) itemData
618: .getItemTextSet().toArray()[0];
619: data.setPublishedItemTextId(itemText.getId());
620: Iterator iter2 = itemText.getAnswerSet().iterator();
621: while (iter2.hasNext()) {
622: AnswerIfc answer = (AnswerIfc) iter2.next();
623: if (answer.getId().toString().equals(
624: presponseIds[i])) {
625: data.setPublishedAnswerId(answer.getId());
626: }
627: }
628: }
629: newItems.add(data);
630: }
631: setItemGradingDataArray(newItems);
632: } catch (Exception e) {
633: e.printStackTrace();
634: }
635: }
636:
637: public String getResponseText() {
638: log.debug("itemcontentbean.getResponseText");
639: try {
640: String response = responseText;
641: Iterator iter = getItemGradingDataArray().iterator();
642: if (iter.hasNext()) {
643: ItemGradingData data = (ItemGradingData) iter.next();
644: response = data.getAnswerText();
645: }
646: return response;
647: } catch (Exception e) {
648: e.printStackTrace();
649: return responseText;
650: }
651: }
652:
653: public void setResponseText(String presponseId) {
654: log.debug("itemcontentbean.setResponseText");
655: try {
656: responseText = presponseId;
657: Iterator iter = getItemGradingDataArray().iterator();
658: if (!iter.hasNext()
659: && (presponseId == null || presponseId.equals(""))) {
660: return;
661: }
662: ItemGradingData data = null;
663: if (iter.hasNext()) {
664: data = (ItemGradingData) iter.next();
665: } else {
666: data = new ItemGradingData();
667: data.setPublishedItemId(itemData.getItemId());
668: ItemTextIfc itemText = (ItemTextIfc) itemData
669: .getItemTextSet().toArray()[0];
670: data.setPublishedItemTextId(itemText.getId());
671: ArrayList items = new ArrayList();
672: items.add(data);
673: setItemGradingDataArray(items);
674: }
675: data.setAnswerText(presponseId);
676: } catch (Exception e) {
677: e.printStackTrace();
678: }
679: }
680:
681: public ArrayList getMatchingArray() {
682: return matchingArray;
683: }
684:
685: public void setMatchingArray(ArrayList newArray) {
686: matchingArray = newArray;
687: }
688:
689: public ArrayList getFibArray() {
690: return fibArray;
691: }
692:
693: public void setFibArray(ArrayList newArray) {
694: fibArray = newArray;
695: }
696:
697: public ArrayList getFinArray() {
698: return finArray;
699: }
700:
701: public void setFinArray(ArrayList newArray) {
702: finArray = newArray;
703: }
704:
705: public ArrayList getSelectionArray() {
706: return selectionArray;
707: }
708:
709: public void setSelectionArray(ArrayList newArray) {
710: selectionArray = newArray;
711: }
712:
713: public ArrayList getAnswers() {
714: return answers;
715: }
716:
717: public void setAnswers(ArrayList list) {
718: answers = list;
719: }
720:
721: // added by Daisy
722: public void setInstruction(String instruction) {
723: this .instruction = instruction;
724: }
725:
726: public String getInstruction() {
727: return this .instruction;
728: }
729:
730: public void setRationale(String newRationale) {
731: int count = getItemGradingDataArray().size();
732: if (count <= 0) {
733: // student didn't answer the question, so no itemgrading to save rationale, skip.
734: return;
735: }
736: ItemGradingData data = (ItemGradingData) getItemGradingDataArray()
737: .toArray()[count - 1];
738:
739: if (getItemData().getTypeId().toString().equals(
740: TypeIfc.TRUE_FALSE.toString())) {
741: // for True false
742: data.setRationale(newRationale);
743: } else if (getItemData().getTypeId().toString().equals(
744: TypeIfc.MULTIPLE_CORRECT.toString())) {
745: // MCMC, need to update rationale in all itemgrading records
746: Iterator iter = getItemGradingDataArray().iterator();
747: while (iter.hasNext()) {
748: ItemGradingData mcmcdata = (ItemGradingData) iter
749: .next();
750:
751: mcmcdata.setRationale(newRationale);
752: }
753: } else {
754: // for MCSC
755: if (data.getItemGradingId() == null) {
756: // this is a new answer , now we just need to set the rationale
757:
758: data.setRationale(newRationale);
759:
760: } else {
761: // the answer is the same, the student only changed the
762: // rationale, not the MC selection
763: // we need to create a new ItemGradingData. because
764: // SubmitForGradingListener doesn't recognize that this is a
765: // modified answer
766: // unless the itemgradingid = null
767:
768: ItemGradingData newdata = new ItemGradingData();
769: newdata.setPublishedItemId(data.getPublishedItemId());
770: newdata.setPublishedItemTextId(data
771: .getPublishedItemTextId());
772: newdata.setRationale(newRationale);
773: newdata.setPublishedAnswerId(data
774: .getPublishedAnswerId());
775: ArrayList items = getItemGradingDataArray();
776: items.add(newdata);
777: setItemGradingDataArray(items);
778: }
779: }
780:
781: }
782:
783: public String getRationale() {
784: // Iterator iter = getItemGradingDataArray().iterator();
785: // if (iter.hasNext())
786: // {
787: int count = getItemGradingDataArray().size();
788: if (count > 0) {
789: ItemGradingData data = (ItemGradingData) getItemGradingDataArray()
790: .toArray()[count - 1];
791: // ItemGradingData data = (ItemGradingData) iter.next();
792: rationale = data.getRationale();
793: }
794: return Validator.check(rationale, "");
795: }
796:
797: public String getKey() {
798: return key;
799: }
800:
801: public void setKey(String newKey) {
802: key = newKey;
803: }
804:
805: public String getSequence() {
806: return sequence;
807: }
808:
809: public void setSequence(String newSequence) {
810: sequence = newSequence;
811: }
812:
813: public ArrayList getShuffledAnswers() {
814: return shuffledAnswers;
815: }
816:
817: public void setShuffledAnswers(ArrayList newAnswers) {
818: shuffledAnswers = newAnswers;
819: }
820:
821: public Integer getTriesAllowed() {
822: return triesAllowed;
823: }
824:
825: public void setTriesAllowed(Integer param) {
826: triesAllowed = param;
827: }
828:
829: public Integer getAttemptsRemaining() {
830: return attemptsRemaining;
831: }
832:
833: public void setAttemptsRemaining(Integer param) {
834: attemptsRemaining = param;
835: }
836:
837: public Integer getDuration() {
838: return duration;
839: }
840:
841: public void setDuration(Integer param) {
842: duration = param;
843: }
844:
845: public ArrayList getMediaArray() {
846: ArrayList mediaArray = new ArrayList();
847: ItemGradingData itemGradingData = null;
848: try {
849: Iterator iter = getItemGradingDataArray().iterator();
850: if (iter.hasNext()) {
851: itemGradingData = (ItemGradingData) iter.next();
852: }
853: } catch (Exception e) {
854: e.printStackTrace();
855: }
856: if (itemGradingData != null
857: && itemGradingData.getItemGradingId() != null) {
858: GradingService service = new GradingService();
859: mediaArray = service.getMediaArray(itemGradingData
860: .getItemGradingId().toString());
861: // if question is audio, check time limit
862: ItemDataIfc item = getItemData();
863: if ((TypeIfc.AUDIO_RECORDING).equals(item.getTypeId()))
864: setDurationIsOver(item, mediaArray);
865: }
866: return mediaArray;
867: }
868:
869: private void setDurationIsOver(ItemDataIfc item, ArrayList mediaList) {
870: // we set maxDurationAllowed = 60s for audio question published without
871: // a duration. This is created from imported assessment when duration for
872: // audio question was not set correctly. Note that this is just a work
873: // around. Ultimately, the importing procedure need to be fixed or the
874: // publishing procedure need to be tightened. - daisyf
875: int maxDurationAllowed = 60;
876: try {
877: maxDurationAllowed = item.getDuration().intValue();
878: } catch (Exception e) {
879: log.info("**duration recorded is not an integer value="
880: + e.getMessage());
881: maxDurationAllowed = 60;
882: }
883: for (int i = 0; i < mediaList.size(); i++) {
884: MediaIfc m = (MediaIfc) mediaList.get(i);
885: float duration = (new Float(m.getDuration())).floatValue();
886: if (duration > maxDurationAllowed)
887: m.setDurationIsOver(true);
888: else
889: m.setDurationIsOver(false);
890: }
891: }
892:
893: /**
894: * Show the student score currently earned?
895: *
896: * @return the score
897: */
898: public boolean isShowStudentScore() {
899: return showStudentScore;
900: }
901:
902: /**
903: * Set the student score currently earned.
904: *
905: * @param showStudentScore
906: * true/false Show the student score currently earned?
907: */
908: public void setShowStudentScore(boolean showStudentScore) {
909: this .showStudentScore = showStudentScore;
910: }
911:
912: /**
913: * Show the student question score currently earned?
914: *
915: * @return the score
916: */
917: public boolean isShowStudentQuestionScore() {
918: return showStudentQuestionScore;
919: }
920:
921: /**
922: * Set the student question score currently earned.
923: *
924: * @param param
925: * true/false Show the student score currently earned?
926: */
927: public void setShowStudentQuestionScore(boolean param) {
928: this .showStudentQuestionScore = param;
929: }
930:
931: /**
932: * If we display the score, return it, followed by a slash.
933: *
934: * @return either, a) the score followed by a slash, or, b) "" (empty
935: * string)
936: */
937: public String getPointsDisplayString() {
938: String pointsDisplayString = "";
939: if (showStudentQuestionScore) {
940: pointsDisplayString = SectionContentsBean
941: .roundTo2Decimals(points)
942: + "/";
943: }
944: return pointsDisplayString;
945: }
946:
947: public String strip(String text) {
948: if (text != null)
949: text = text.replaceAll("<.*?>", " ");
950: return text;
951:
952: }
953:
954: public boolean isNotEmpty(String wyzText) {
955:
956: if (wyzText != null && !wyzText.equals("null")) {
957: int index = 0;
958: String t = wyzText.trim();
959: while (index < t.length()) {
960: char c = t.charAt(index);
961: if (Character.isLetterOrDigit(c)) {
962: return true;
963: }
964: index++;
965: }
966: }
967: return false;
968: }
969:
970: public String getKeyInUnicode() {
971: return ContextUtil.getStringInUnicode(getKey());
972: }
973:
974: public boolean getHasAttachment() {
975: boolean hasAttachment = false;
976: if (itemData != null) {
977: List l = itemData.getItemAttachmentList();
978: if (l != null && l.size() > 0)
979: hasAttachment = true;
980: }
981: return hasAttachment;
982: }
983:
984: }
|