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/MatchingBean.java $
003: * $Id: MatchingBean.java 17859 2006-11-02 21:11:50Z 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.util.ArrayList;
023: import java.util.Iterator;
024:
025: import org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingData;
026: import org.sakaiproject.tool.assessment.data.ifc.assessment.AnswerIfc;
027: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemTextIfc;
028:
029: /**
030: * @author rgollub@stanford.edu
031: * $Id: MatchingBean.java 17859 2006-11-02 21:11:50Z ktsao@stanford.edu $
032: */
033: public class MatchingBean {
034:
035: private ItemContentsBean parent;
036: private ItemTextIfc itemText;
037: private ItemGradingData data;
038: private String response;
039: private ArrayList choices;
040: private String text;
041: private String feedback;
042: private AnswerIfc answer;
043: private boolean isCorrect;
044:
045: public ItemContentsBean getItemContentsBean() {
046: return parent;
047: }
048:
049: public void setItemContentsBean(ItemContentsBean bean) {
050: parent = bean;
051: }
052:
053: public ItemTextIfc getItemText() {
054: return itemText;
055: }
056:
057: public void setItemText(ItemTextIfc newtext) {
058: itemText = newtext;
059: }
060:
061: public ItemGradingData getItemGradingData() {
062: return data;
063: }
064:
065: public void setItemGradingData(ItemGradingData newdata) {
066: data = newdata;
067: }
068:
069: public String getResponse() {
070: return response;
071: }
072:
073: public void setResponse(String newresp) {
074: response = newresp;
075: if (data == null) {
076: data = new ItemGradingData();
077: data.setPublishedItemId(parent.getItemData().getItemId());
078: data.setPublishedItemTextId(itemText.getId());
079: ArrayList items = parent.getItemGradingDataArray();
080: items.add(data);
081: parent.setItemGradingDataArray(items);
082: }
083:
084: // Fixed for SAK-5535
085: // If we don't reset published answer id to null, the previous selected value will remain in the bean
086: // That is, the "select" selection in dropdown will never be set
087: if (newresp.equals("0")) {
088: data.setPublishedAnswerId(null);
089: }
090: Iterator iter = itemText.getAnswerSet().iterator();
091: while (iter.hasNext()) {
092: AnswerIfc answer = (AnswerIfc) iter.next();
093: if (answer.getId().toString().equals(newresp)) {
094: data.setPublishedAnswerId(answer.getId());
095: break;
096: }
097: }
098: }
099:
100: public ArrayList getChoices() {
101: return choices;
102: }
103:
104: public void setChoices(ArrayList newch) {
105: choices = newch;
106: }
107:
108: public String getText() {
109: return text;
110: }
111:
112: public void setText(String newtext) {
113: text = newtext;
114: }
115:
116: public String getFeedback() {
117: return feedback;
118: }
119:
120: public void setFeedback(String newfb) {
121: feedback = newfb;
122: }
123:
124: public void setAnswer(AnswerIfc answer) {
125: this .answer = answer;
126: }
127:
128: public AnswerIfc getAnswer() {
129: return answer;
130: }
131:
132: public void setIsCorrect(boolean isCorrect) {
133: this .isCorrect = isCorrect;
134: }
135:
136: public boolean getIsCorrect() {
137: /*
138: if (data != null && data.getPublishedAnswerId() != null &&
139: answer.getIsCorrect() != null &&
140: answer.getIsCorrect().booleanValue())
141: return true;
142: return false;
143: */
144: return isCorrect;
145: }
146:
147: }
|