📄 questionform.java
字号:
/* * CyberTester - J2EE Web application for creating, delivering and managing tests/exams/surveys. * Copyright (C) 2004 CyberDemia Research and Services Pty Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, write to the * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * See the COPYING file located in the top-level-directory of * the archive of this program for complete text of license. */package com.cyberdemia.cybertester.testee.test;import java.util.*;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.*;import com.cyberdemia.school.IQuestionType;/** * * QuestionForm is a Struts ActionForm to send, receive and validate values from * the single question form. * * @version $Revision: 1.2 $ at $Date: 2004/03/29 14:55:42 $ by $Author: alexycyap $ * @author Alexander Yap */public final class QuestionForm extends ActionForm{ public String getAnswer() { if (IQuestionType.MULTIPLE_CHOICE_TYPE.equals(m_type)) { StringBuffer ansStrBuf = new StringBuffer(); int corCnt = m_multipleAnswers.size(); boolean hasCorrect=false; for (int c=0; c<corCnt; c++) { if (((Boolean)m_multipleAnswers.get(c)).booleanValue()) { if (hasCorrect) { ansStrBuf.append(","); } else { hasCorrect = true; } ansStrBuf.append(c); } } return ansStrBuf.toString(); } return m_answer; } public void setAnswer(String ans) { m_answer = ans; } public Object getQuesId() { return m_id; } public void setQuesId(Object id) { m_id = id; } public int getQuesIndex() { return m_index; }/* public int getQuesDisplayNumber() { return m_index+1; }*/ public void setQuesIndex(int index) { m_index = index; } public void setType(Integer type) { m_type = type; } public boolean getMultipleAnswerIndexed(int index) { return false; } public void setMultipleAnswerIndexed(int index, boolean correct) { if (m_multipleAnswers==null) { m_multipleAnswers = new ArrayList(); } while (index >= m_multipleAnswers.size()) { m_multipleAnswers.add(Boolean.FALSE); } m_multipleAnswers.set(index, correct ? Boolean.TRUE : Boolean.FALSE); } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { m_answer = ""; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors();// if ((m_answer<0) || (m_answer>=4))// errors.add("answer", new ActionError("error.answer.required")); return errors; } private List m_multipleAnswers = null; private String m_answer = "0"; private Object m_id = null; private Integer m_type = IQuestionType.SINGLE_CHOICE_TYPE; private int m_index = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -