📄 questionform.java
字号:
/* * CyberTester - J2EE Web application for creating, delivering and managing tests/exams/surveys. * Copyright (C) 2003 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.admin.test;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.*;import com.cyberdemia.cybertester.admin.*;import com.cyberdemia.cybertester.CyberTesterUtils;import com.cyberdemia.school.DifficultyEnum;/** * * QuestionForm is a Struts ActionForm to send, receive and validate values from the * question editor form. * * @author Alexander Yap */public final class QuestionForm extends ActionForm{ public QuestionForm() { super(); for (int aidx=0; aidx<m_answerChoices.length; aidx++) { m_answerChoices[aidx]=null; } } public String getQuesId() { return m_id; } public void setQuesId(String id) { m_id = id; } public String getMode() { return m_mode; } public void setMode(String mode) { m_mode = mode; } public boolean isNew() { return AdminConstants.EDITOR_NEW_MODE.equalsIgnoreCase(m_mode); } public String getTitle() { return m_title; } public void setTitle(String title) { m_title = title; } public String getQuestionText() { return m_quesText; } public void setQuestionText(String quesText) { m_quesText = quesText; } public String getHintText() { return m_hintText; } public void setHintText(String hintText) { m_hintText = hintText; } public String getExplanationText() { return m_explanationText; } public void setExplanationText(String explanationText) { m_explanationText = explanationText; } public int getAnswer() { return m_answer; } public void setAnswer(int ans) { m_answer = ans; } public String[] getAnswerChoices() { return m_answerChoices; } public String getAnswerChoice0() { return m_answerChoices[0]; } public void setAnswerChoice0(String choice) { m_answerChoices[0] = choice; } public String getAnswerChoice1() { return m_answerChoices[1]; } public void setAnswerChoice1(String choice) { m_answerChoices[1] = choice; } public String getAnswerChoice2() { return m_answerChoices[2]; } public void setAnswerChoice2(String choice) { m_answerChoices[2] = choice; } public String getAnswerChoice3() { return m_answerChoices[3]; } public void setAnswerChoice3(String choice) { m_answerChoices[3] = choice; } public void setDifficultyStr( String diffStr) { m_diffStr = diffStr; } public String getDifficultyStr() { return m_diffStr; } public int getTimeLimitSeconds() { return m_timeLimitSecs; } public void setTimeLimitSeconds(int secs) { m_timeLimitSecs = secs; } /** * 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_title=null; m_quesText=null; m_hintText=null; m_diffStr=DifficultyEnum.TRIVIAL.getStr(); m_id=""; for (int aidx=0; aidx<m_answerChoices.length; aidx++) { m_answerChoices[aidx]=null; } m_answer = 0; m_mode=AdminConstants.EDITOR_NEW_MODE; m_timeLimitSecs = 0; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); CyberTesterUtils.validateRequiredFormSelectedParam("Title", m_title, errors); CyberTesterUtils.validateRequiredFormEnteredParam("Question text", m_quesText, errors); CyberTesterUtils.validateRequiredFormSelectedParam("Difficulty", m_diffStr, errors); if ((m_answer<0) || (m_answer>=m_answerChoices.length)) { errors.add("Answer", new ActionError("error.form.missingParam.select","Answer")); } for (int aidx=0; aidx<m_answerChoices.length; aidx++) { CyberTesterUtils.validateRequiredFormEnteredParam("Answer choice "+aidx, m_answerChoices[aidx], errors); } return errors; } private String m_id=""; private String m_title=null; private String m_quesText=null; private String m_hintText=null; private String m_explanationText=null; private String[] m_answerChoices = new String[4]; private int m_answer = 0; private String m_mode=AdminConstants.EDITOR_NEW_MODE; private String m_diffStr = DifficultyEnum.TRIVIAL.getStr(); private int m_timeLimitSecs = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -