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/SelectionBean.java $
003: * $Id: SelectionBean.java 12732 2006-07-24 18:26:27Z lydial@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.util.ArrayList;
023:
024: import org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingData;
025: import org.sakaiproject.tool.assessment.data.ifc.assessment.AnswerIfc;
026: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemTextIfc;
027:
028: import org.apache.commons.logging.Log;
029: import org.apache.commons.logging.LogFactory;
030:
031: /**
032: * This is the JSF backing bean for delivery, used for TF and MC questions
033: *
034: * $Id: SelectionBean.java 12732 2006-07-24 18:26:27Z lydial@stanford.edu $
035: */
036: public class SelectionBean {
037:
038: private static Log log = LogFactory.getLog(SelectionBean.class);
039:
040: private ItemContentsBean parent;
041:
042: private ItemGradingData data;
043:
044: private boolean response;
045:
046: private AnswerIfc answer;
047:
048: private String feedback;
049:
050: private String responseId;
051:
052: public ItemContentsBean getItemContentsBean() {
053: return parent;
054: }
055:
056: public void setItemContentsBean(ItemContentsBean bean) {
057: parent = bean;
058: }
059:
060: public ItemGradingData getItemGradingData() {
061: return data;
062: }
063:
064: public void setItemGradingData(ItemGradingData newdata) {
065: data = newdata;
066: }
067:
068: public boolean getResponse() {
069: return response;
070: }
071:
072: public void setResponse(boolean newresp) {
073: // this is called with mcsc and mcmc
074:
075: response = newresp;
076: if (newresp) {
077: ItemTextIfc itemText = (ItemTextIfc) parent.getItemData()
078: .getItemTextSet().toArray()[0];
079: if (data == null) {
080: data = new ItemGradingData();
081: data.setPublishedItemId(parent.getItemData()
082: .getItemId());
083: data.setPublishedItemTextId(itemText.getId());
084: ArrayList items = parent.getItemGradingDataArray();
085: items.add(data);
086: parent.setItemGradingDataArray(items);
087: }
088: data.setPublishedAnswerId(answer.getId());
089: } else if (data != null)
090: data.setPublishedAnswerId(null);
091: }
092:
093: public AnswerIfc getAnswer() {
094: return answer;
095: }
096:
097: public void setAnswer(AnswerIfc newAnswer) {
098: answer = newAnswer;
099: }
100:
101: public String getFeedback() {
102: if (feedback == null)
103: return "";
104: return feedback;
105: }
106:
107: public void setFeedback(String newfb) {
108: feedback = newfb;
109: }
110:
111: public String getAnswerId() {
112: return answer.getId().toString();
113: }
114: }
|