📄 questionbean.java
字号:
/* * SchoolEJB - CyberDemia's library of EJBs for educational related services. * Copyright (C) 2003 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; 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 library for complete text of license. */package com.cyberdemia.school;import javax.ejb.*;import java.util.*;/** * QuestionBean models a question which may be one of several types, such as * multiple choice, single choice, keywords matching etc. * It extends AbstractTextResource and adds additional properties * such as answer, hint, etc. * * @ejb.bean name="QuestionBean" * type="CMP" * view-type="local" * schema="Question" * cmp-version="2.x" * primkey-field="id" * local-jndi-name="ejb/LocalQuestion" * * @ejb.util generate="physical" * @ejb.interface local-class="com.cyberdemia.school.LocalQuestion" local-extends="javax.ejb.EJBLocalObject" * @ejb.home local-class="com.cyberdemia.school.LocalQuestionHome" local-extends="javax.ejb.EJBLocalHome" * @ejb.persistence table-name="Question" * * @ejb.finder signature="java.util.Collection findAll()" * query="SELECT DISTINCT OBJECT(q) FROM Question q" * * @ejb.finder signature="java.util.Collection findAllActive()" * query="SELECT DISTINCT OBJECT(q) FROM Question q WHERE q.active=true" * * @ejb.finder signature="java.util.Collection findByTest(java.lang.Integer testId)" * query="SELECT DISTINCT OBJECT(q) FROM Question q WHERE q.test.id=?1 AND q.active=true" * * @ejb.finder signature="java.util.Collection findUnassignedToTest(boolean active)" * query="SELECT DISTINCT OBJECT(q) FROM Question q WHERE q.assignedToTest=false AND q.active=?1" * * @jboss.method-attributes pattern="get*" read-only="true" * @jboss.method-attributes pattern="is*" read-only="true" * @jboss.container-configuration name="CyberDemia Optimized Standalone CMP" * * * @author Alexander Yap * @version $Revision: 1.11 $ at $Date: 2004/06/20 16:05:17 $ by $Author: alexycyap $ * */public abstract class QuestionBean extends AbstractTextResource{ /** * <p> * Gets the answer for this Question. * This method returns a String, the format of which depends on the * question type. * </p><ul> * <li> * For a single-choice question, it is simply the String representation of * an index that refers to one of the answer choices, e.g. "2" * </li><li> * For a multiple-choice question, it is a comma-separated list of * indices that refers to multiple answer choices, e.g. "0,1,3" * </li><li> * For a keywords question, it is a comma-separated list of * keywords, e.g. "java,c++,linux". They should all be in lower case. * </li> * * @ejb.interface-method * @ejb.persistence * * @return Answer for this Question. */ public abstract String getAnswer(); /** * <p> * Sets the answer for this Question. * This method expects a String parameter, the format of which * depends on the question type. * </p><ul> * <li> * For a single-choice question, it is simply the String representation of * an index that refers to one of the answer choices, e.g. "2" * </li><li> * For a multiple-choice question, it is a comma-separated list of * indices that refers to multiple answer choices, e.g. "0,1,3" * </li><li> * For a keywords question, it is a comma-separated list of * keywords, e.g. "java,c++,linux". * <b>IMPORTANT : <code>ans</code> must be converted to all lower-case before being passed to this method</b>. * </li> * * @ejb.interface-method * * @param ans Answer for this Question. */ public abstract void setAnswer( String ans); /** * Gets the question type. * * @ejb.interface-method * @ejb.persistence * * @return Question type, one of IQuestionType.SINGLE_CHOICE_TYPE, IQuestionType.MULTIPLE_CHOICE_TYPE or IQuestionType.KEYWORDS_TYPE. */ public abstract Integer getType(); /** * Sets the question type. * * @ejb.interface-method * * @param type Question type, one of IQuestionType.SINGLE_CHOICE_TYPE, IQuestionType.MULTIPLE_CHOICE_TYPE or IQuestionType.KEYWORDS_TYPE. */ public abstract void setType(Integer type); /** * Sets the Set of answer choices. * * @ejb.interface-method * * @param choices Set of answer choices. */ public abstract void setAnswerChoiceSet( Set choices); /** * Gets the Set of answer choices. * * @ejb.interface-method * @ejb.relation name="question-answerChoices" role-name="question-has-answerChoices" target-ejb="AnswerChoiceBean" target-role-name="answerChoice-belongs-to-question" * * @return Set of answer choices. */ public abstract Set getAnswerChoiceSet(); /** * Gets the hint for this question. * * @ejb.interface-method * @ejb.persistence * * @return Hint for this question. */ public abstract String getHint(); /** * Sets the hint for this question. * * @ejb.interface-method * * @param hint Hint for this question. */ public abstract void setHint( String hint); /** * Gets the explanation for this question. * * @ejb.interface-method * @ejb.persistence * @jboss.jdbc-type type="LONGVARCHAR" * @jboss.sql-type type="TEXT" * * @return Explanation for this question. */ public abstract String getExplanation(); /** * Sets the explanation for this question. * * @ejb.interface-method * * @param explain Explanation for this question. */ public abstract void setExplanation( String explain); /** * Sets the difficulty code of this question. * This method is equivalent to setDifficulty(DifficultyEnum), * except that difficulty is specified using its code instead * of DifficultyEnum. * * @ejb.interface-method * * @param diffCode Difficulty code of this question. * @see #setDifficulty(DifficultyEnum) */ public abstract void setDifficultyCode( Integer diffCode); /** * Gets the difficulty code of this question. * This method is equivalent to getDifficulty(), * except that difficulty is identified by its code instead * of DifficultyEnum. * * @ejb.interface-method * @ejb.persistence * * @return Difficulty code of this question. * @see #getDifficulty() */ public abstract Integer getDifficultyCode(); /** * Gets the score for this question. * This score is awarded to the user for correct answer(s). * * @ejb.interface-method * @ejb.persistence * * @return Score for this question. */ public abstract int getScore(); /** * Sets the score for this question. * This score is awarded to the user for correct answer(s). * * @ejb.interface-method * * @param score Score for this question. */ public abstract void setScore(int score); /** * Gets the test that this question is currently assigned to. * * @ejb.interface-method * @ejb.relation name="test-questions" role-name="questions-belongs-to-test" target-ejb="TestBean" target-role-name="test-has-questions" target-multiple="yes" cascade-delete="no" * @jboss.relation fk-constraint="yes" related-pk-field="id" fk-column="testId" * * @return Test. */ public abstract LocalTest getTest(); /** * Sets the test this question. * * @param test Test. */ public abstract void setTest(LocalTest test); /** * Sets the allocated time limit (in seconds) for this question. * * @ejb.interface-method * * @param limit Time limit in seconds, or 0 (or negative) for no time limit. */ public abstract void setTimeLimitSeconds(int limit); /** * Gets the allocated time limit (in seconds) for this question. * * @ejb.interface-method * @ejb.persistence * * @return Time limit in seconds, or 0 (or negative) for no time limit. */ public abstract int getTimeLimitSeconds(); /** * Checks if this question is currently assigned to a test. * This property allows a finder to quickly retrieve a list of * questions that are assigned or not assigned to tests, without * having to load any corresponding TestBean instances. * * @ejb.persistence * * @return true if this question is assigned to a test, false if not assigned. */ public abstract boolean getAssignedToTest(); /** * Sets whether this question is currently assigned to a test. * This property allows a finder to quickly retrieve a list of * questions that are assigned or not assigned to tests, without * having to load any corresponding TestBean instances. * * @ejb.interface-method * * @param assigned true to mark this question as assigned, false to mark it as not assigned. */ public abstract void setAssignedToTest(boolean assigned); /** * Checks if this question is active. An active question * may be allocated to a test, editted and used. * An inactive question may be considered to be logically removed * from the system, but is kept in the database to maintain * consistency in reporting and historical logging. * * @ejb.persistence * * @return true if this question is active, false if inactive. */ public abstract boolean getActive(); /** * Sets whether this question is active. An active question * may be allocated to a test, editted and used. * An inactive question may be considered to be logically removed * from the system, but is kept in the database to maintain * consistency in reporting and historical logging. * * @ejb.interface-method * * @param active true to make this question active, false to make it inactive. */ public abstract void setActive(boolean active); /** * Gets whether a keywords-type question requires all keywords to be matched in * the user's answer for it to be considered correct and awarded any score. * If this is true, no score should be awarded if any of the keywords is not found in the user's answer. * If this is false, a partial score may be awarded (subject to other business rules) if some keywords is found in the user's answer. * This property is only relevent for a keywords-type question and ignored for other types. * * @ejb.persistence * * @return true if all keywords are required to be matched, otherwise false.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -