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/ItemConfigBean.java $
003: * $Id: ItemConfigBean.java 22608 2007-03-14 19:27:17Z 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.author;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024:
025: import javax.faces.model.SelectItem;
026: import org.sakaiproject.util.ResourceLoader;
027:
028: /**
029: *
030: * <p> </p>
031: * <p>Description: Describes global item settings for authoring.
032: * Describes what item types the will be supported.
033: * To change, modify the itemConfig properties in the faces.config file.
034: * Also developers could add an administrative configuration later.</p>
035: *
036: */
037: public class ItemConfigBean implements Serializable {
038: /**
039: *
040: */
041: private static final long serialVersionUID = 5017545754149103817L;
042:
043: private static final String msgResource = "org.sakaiproject.tool.assessment.bundle.AuthorMessages";
044:
045: private boolean showFileUpload;
046: private boolean showEssay;
047: private boolean showAudio;
048: private boolean showMatching;
049: private boolean showTrueFalse;
050: private boolean showMultipleChoiceSingleCorrect;
051: private boolean showMultipleChoiceMultipleCorrect;
052: private boolean showSurvey;
053: private boolean showFillInTheBlank;
054: private boolean showFillInNumeric;
055: private boolean selectFromQuestionPool;
056:
057: /**
058: * Should we show file upload question?
059: * @return if true
060: */
061: public boolean isShowFileUpload() {
062: return showFileUpload;
063: }
064:
065: /**
066: * Set whether file upload should be shown.
067: * @param showFileUpload if this type should be shown
068: */
069: public void setShowFileUpload(boolean showFileUpload) {
070: this .showFileUpload = showFileUpload;
071: }
072:
073: /**
074: * Should we show short answer/essay question?
075: * @return if true
076: */
077: public boolean isShowEssay() {
078: return showEssay;
079: }
080:
081: /**
082: * Set whether essay/short answer should be shown.
083: * @param showEssay if this type should be shown
084: */
085: public void setShowEssay(boolean showEssay) {
086: this .showEssay = showEssay;
087: }
088:
089: /**
090: * Should we show audio upload question?
091: * @return if true
092: */
093: public boolean isShowAudio() {
094: return showAudio;
095: }
096:
097: /**
098: * Set whether audio recording should be shown.
099: * @param showAudio if this type should be shown
100: */
101: public void setShowAudio(boolean showAudio) {
102: this .showAudio = showAudio;
103: }
104:
105: /**
106: * Should we show matching question?
107: * @return if true
108: */
109: public boolean isShowMatching() {
110: return showMatching;
111: }
112:
113: /**
114: * Set whether matching should be shown.
115: * @param showMatching if this type should be shown
116: */
117: public void setShowMatching(boolean showMatching) {
118: this .showMatching = showMatching;
119: }
120:
121: /**
122: *
123: * @return if true
124: */
125: public boolean isShowTrueFalse() {
126: return showTrueFalse;
127: }
128:
129: /**
130: * Set whether we show true/false question.
131: * @param showTrueFalse if this type should be shown
132: */
133: public void setShowTrueFalse(boolean showTrueFalse) {
134: this .showTrueFalse = showTrueFalse;
135: }
136:
137: /**
138: * Should we show all multiple choice type question?
139: * That means both multiple correct and single correct.
140: * @return if true if this type should be shown
141: */
142: public boolean isShowAllMultipleChoice() {
143: return showMultipleChoiceMultipleCorrect
144: && showMultipleChoiceSingleCorrect;
145: }
146:
147: /**
148: * Should we show multiple choice single correct question?
149: * @return if true
150: */
151: public boolean isShowMultipleChoiceSingleCorrect() {
152: return showMultipleChoiceSingleCorrect;
153: }
154:
155: /**
156: * Set whether multiple choice single correct should be shown.
157: * @param showMultipleChoiceSingleCorrect if this type should be shown
158: */
159: public void setShowMultipleChoiceSingleCorrect(
160: boolean showMultipleChoiceSingleCorrect) {
161: this .showMultipleChoiceSingleCorrect = showMultipleChoiceSingleCorrect;
162: }
163:
164: /**
165: * Should we show multiple choice multiple correct question?
166: * @return if true
167: */
168: public boolean isShowMultipleChoiceMultipleCorrect() {
169: return showMultipleChoiceMultipleCorrect;
170: }
171:
172: /**
173: * Set whether multiple choice multiple correct should be shown.
174: * @param showMultipleChoiceMultipleCorrect if this type should be shown
175: */
176: public void setShowMultipleChoiceMultipleCorrect(
177: boolean showMultipleChoiceMultipleCorrect) {
178: this .showMultipleChoiceMultipleCorrect = showMultipleChoiceMultipleCorrect;
179: }
180:
181: /**
182: * Should we show fill in the blank question?
183: * @return if true
184: */
185:
186: public boolean isShowFillInTheBlank() {
187: return showFillInTheBlank;
188: }
189:
190: /**
191: * Set whether fill in the blank should be shown.
192: * @param showFillInTheBlank if this type should be shown
193: */
194: public void setShowFillInTheBlank(boolean showFillInTheBlank) {
195: this .showFillInTheBlank = showFillInTheBlank;
196: }
197:
198: /**
199: * Should we show survey question?
200: * @return if true
201: */
202:
203: public boolean isShowFillInNumeric() {
204: return showFillInNumeric;
205: }
206:
207: /**
208: * Set whether fill in numeric should be shown.
209: * @param showFillInNumeric if this type should be shown
210: */
211:
212: public void setShowFillInNumeric(boolean showFillInNumeric) {
213: this .showFillInNumeric = showFillInNumeric;
214: }
215:
216: /**
217: * Should we show survey question?
218: * @return if true
219: */
220: public boolean isShowSurvey() {
221: return showSurvey;
222: }
223:
224: /**
225: * Set whether survey should be shown.
226: * @param showSurvey if this type should be shown
227: */
228: public void setShowSurvey(boolean showSurvey) {
229: this .showSurvey = showSurvey;
230: }
231:
232: /**
233: * Derived property. Get arraylist of item type SelectItems.
234: * We are not lazy loading this so that we can change these dynamically.
235: * Most are being injected from the faces-config, but whether we select from
236: * question pools is always dynamic.
237: *
238: * @return ArrayList of model SelectItems
239: */
240:
241: public ArrayList getItemTypeSelectList() {
242: ArrayList list = new ArrayList();
243:
244: list.add(new SelectItem("",
245: getResourceDisplayName("select_qtype")));
246:
247: if (isShowAllMultipleChoice())
248: list.add(new SelectItem("1",
249: getResourceDisplayName("multiple_choice_type")));
250:
251: if (showSurvey)
252: list.add(new SelectItem("3",
253: getResourceDisplayName("multiple_choice_surv")));
254:
255: if (showEssay)
256: list.add(new SelectItem("5",
257: getResourceDisplayName("short_answer_essay")));
258:
259: if (showFillInTheBlank)
260: list.add(new SelectItem("8",
261: getResourceDisplayName("fill_in_the_blank")));
262:
263: if (showFillInNumeric)
264: list.add(new SelectItem("11",
265: getResourceDisplayName("fill_in_numeric")));
266: if (showMatching)
267: list.add(new SelectItem("9",
268: getResourceDisplayName("matching")));
269:
270: if (showTrueFalse)
271: list.add(new SelectItem("4",
272: getResourceDisplayName("true_false")));
273:
274: if (showAudio)
275: list.add(new SelectItem("7",
276: getResourceDisplayName("audio_recording")));
277:
278: if (showFileUpload)
279: list.add(new SelectItem("6",
280: getResourceDisplayName("file_upload")));
281:
282: if (selectFromQuestionPool)
283: list.add(new SelectItem("10",
284: getResourceDisplayName("import_from_q")));
285:
286: return list;
287: }
288:
289: /*
290: // test the item accessors and mutators and the selectItem list
291: public static void main (String[] args)
292: {
293: ItemConfigBean bean = new ItemConfigBean();
294: ArrayList list = bean.getItemTypeSelectList();
295: for (int i = 0; i < list.size(); i++)
296: {
297: SelectItem sitem = (SelectItem)list.get(i);
298: }
299:
300: bean.setSelectFromQuestionPool(true);
301: bean.setShowAudio(true);
302: bean.setShowEssay(true);
303: bean.setShowFileUpload(true);
304: bean.setShowFillInTheBlank(true);
305: bean.setShowFillInNumeric(true);
306: bean.setShowMatching(true);
307: bean.setShowMultipleChoiceMultipleCorrect(true);
308: bean.setShowMultipleChoiceSingleCorrect(true);
309: bean.setShowSurvey(true);
310: bean.setShowTrueFalse(true);
311: list = bean.getItemTypeSelectList();
312: for (int i = 0; i < list.size(); i++)
313: {
314: SelectItem sitem = (SelectItem)list.get(i);
315: }
316: bean.setShowAudio(false);
317: bean.setShowFileUpload(false);
318: list = bean.getItemTypeSelectList();
319: for (int i = 0; i < list.size(); i++)
320: {
321: SelectItem sitem = (SelectItem)list.get(i);
322: }
323: }
324: */
325:
326: /**
327: * Can we select items from a question pool?
328: * If we are in question pools we cannot select items from pool.
329: * If we are not in question pools we can select items from pool.
330: * @return if we can select from question pool.
331: */
332: public boolean isSelectFromQuestionPool() {
333: return selectFromQuestionPool;
334: }
335:
336: /**
337: * Set whether we can select items from a question pool.
338: * If we are in question pools we cannot select items from pool.
339: * If we are not in question pools we can select items from pool.
340: * @return if we can select from question pool.
341: */
342:
343: public void setSelectFromQuestionPool(boolean selectFromQuestionPool) {
344: this .selectFromQuestionPool = selectFromQuestionPool;
345: }
346:
347: /**
348: * Utility for looking up item resources.
349: * @param resName name to look up
350: * @return the localized name.
351: */
352: private String getResourceDisplayName(String resName) {
353: ResourceLoader res = new ResourceLoader(msgResource);
354: return res.getString(resName);
355: }
356: }
|