📄 answerhistoryrecordbean.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 java.util.Date;import javax.ejb.*;import com.cyberdemia.ejb.BaseEntityBean;/** * AnswerHistoryRecordBean records the answer given by a user to a specific * question. It forms a historical record of the users' answers. * The information here is mainly intended for reporting and logging. * * @ejb.bean name="AnswerHistoryRecordBean" * type="CMP" * view-type="local" * schema="AnswerHistoryRecord" * cmp-version="2.x" * local-jndi-name="ejb/LocalAnswerHistoryRecord" * * @ejb.util generate="physical" * @ejb.interface local-class="com.cyberdemia.school.LocalAnswerHistoryRecord" local-extends="javax.ejb.EJBLocalObject" * @ejb.home local-class="com.cyberdemia.school.LocalAnswerHistoryRecordHome" local-extends="javax.ejb.EJBLocalHome" * @ejb.pk class="com.cyberdemia.school.AnswerHistoryRecordKey" extends="java.lang.Object" * @ejb.persistence table-name="AnswerHistoryRecord" * * @ejb.finder signature="java.util.Collection findAll()" * query="SELECT DISTINCT OBJECT(r) FROM AnswerHistoryRecord r" * * @ejb.finder signature="java.util.Collection findByUser(java.lang.Integer userId)" * query="SELECT DISTINCT OBJECT(r) FROM AnswerHistoryRecord r WHERE r.userId=?1" * * @ejb.finder signature="java.util.Collection findByTest(java.lang.Integer testId)" * query="SELECT DISTINCT OBJECT(r) FROM AnswerHistoryRecord r WHERE r.testId=?1" * * @ejb.finder signature="java.util.Collection findByUserAndTest(java.lang.Integer userId, java.lang.Integer testId)" * query="SELECT DISTINCT OBJECT(r) FROM AnswerHistoryRecord r WHERE r.userId=?1 AND r.testId=?2" * * @jboss.method-attributes pattern="get*" read-only="true" * @jboss.container-configuration name="CyberDemia Optimized Standalone CMP" * * @author Alexander Yap * @version $Revision: 1.6 $ at $Date: 2004/06/20 10:17:44 $ by $Author: alexycyap $ */public abstract class AnswerHistoryRecordBean extends BaseEntityBean{ /** * Gets the User ID of this history record. * * @ejb.persistence * @ejb.pk-field * @ejb.interface-method * * @return User ID. */ public abstract Integer getUserId(); /** * Sets the User ID of this history record. * @param userId User ID. */ public abstract void setUserId(Integer userId); /** * Gets the Test ID of this history record. * * @ejb.persistence * @ejb.pk-field * @ejb.interface-method * * @return Test ID. */ public abstract Integer getTestId(); /** * Sets the Test ID of this history record. * @param testId Test ID. */ public abstract void setTestId(Integer testId); /** * Gets the Question ID of this history record. * * @ejb.persistence * @ejb.pk-field * @ejb.interface-method * * @return Question ID. */ public abstract Integer getQuestionId(); /** * Sets the Question ID of this history record. * @param quesId Question ID. */ public abstract void setQuestionId(Integer quesId); /** * Gets the index of the question within its owner test. * * @ejb.persistence * @ejb.interface-method * * @return Question's index within its test. */ public abstract int getQuestionIndex(); /** * Sets the index of the question within its owner test. * * @ejb.interface-method * * @param index Question's index within its test. */ public abstract void setQuestionIndex(int index); /** * Gets the score that the question is worth. * * @ejb.persistence * @ejb.interface-method * * @return Question's score */ public abstract int getQuestionScore(); /** * Sets the score that the question is worth. * * @ejb.interface-method * * @param score Question's score */ public abstract void setQuestionScore(int score); /** * Gets the score actually awarded to the user for this question. * * @ejb.persistence * @ejb.interface-method * * @return Score awarded to the user. */ public abstract int getUserScore(); /** * Sets the score actually awarded to the user for this question. * * @ejb.interface-method * * @param score Score awarded to the user */ public abstract void setUserScore(int score); /** * Gets the question type. * * @ejb.interface-method * @ejb.persistence * * @return Question type, one of QuestionBean.SINGLE_CHOICE_TYPE, QuestionBean.MULTIPLE_CHOICE_TYPE or QuestionBean.KEYWORDS_TYPE. */ public abstract Integer getQuestionType(); /** * Sets the question type. * * @ejb.interface-method * * @param type Question type, one of QuestionBean.SINGLE_CHOICE_TYPE, QuestionBean.MULTIPLE_CHOICE_TYPE or QuestionBean.KEYWORDS_TYPE. */ public abstract void setQuestionType(Integer type); /** * Gets the user's answer to the question. * The format depends on the question type. * * @ejb.persistence * @ejb.interface-method * * @return User's answer */ public abstract String getUserAnswer(); /** * Sets the user's answer to the question. * The format depends on the question type. * * @ejb.interface-method * * @param answer User's answer */ public abstract void setUserAnswer(String answer); /** * Gets the correct answer to the question. * The format depends on the question type. * * @ejb.persistence * @ejb.interface-method * * @return Question's correct answer. * @see QuestionBean#getAnswer() */ public abstract String getCorrectAnswer(); /** * Sets the correct answer to the question. * The format depends on the question type. * * @ejb.interface-method * * @param answer Correct answer * @see QuestionBean#setAnswer() */ public abstract void setCorrectAnswer(String answer); /** * Gets the exceeded question time flag. * * @ejb.persistence * @ejb.interface-method * * @return true if this question's time limit has been exceeded. */ public abstract boolean getExceededQuestionTime(); /** * Sets the exceeded question time flag. * * @ejb.interface-method * * @param exceeded true if this question's time limit has been exceeded. */ public abstract void setExceededQuestionTime(boolean exceeded); /** * Gets the timestamp in milliseconds when the user answered the question. * * @ejb.persistence * @ejb.interface-method * * @return Timestamp in milliseconds when the user answered the question. */ public abstract long getTimestampMillis(); /** * Gets the timestamp in milliseconds when the user answered the question. * * @ejb.interface-method * * @param millis Timestamp in milliseconds when the user answered the question. */ public abstract void setTimestampMillis(long millis); /** * Gets the timestamp when the user answered the question. * * @ejb.interface-method * * @return Timestamp when the user answered the question. */ public Date getTimestamp() { return new Date(getTimestampMillis()); } /** * Gets the timestamp when the user answered the question. * * @ejb.interface-method * * @param dt Timestamp when the user answered the question. */ public void setTimestamp(Date dt) { setTimestampMillis(dt.getTime()); } /** * Gets whether the user answered the question correctly. * This only makes sense for question of type SINGLE_CHOICE or MULTIPLE_CHOICE. * Otherwise, it returns false. * * @ejb.persistence * @ejb.interface-method * * @return true if the user answered the question correctly, otherwise false. */ public abstract boolean getAnswerCorrect(); /** * Sets whether the user answered the question correctly. * This only makes sense for question of type SINGLE_CHOICE or MULTIPLE_CHOICE. * Otherwise, it should be set to false. * * @ejb.interface-method * * @param correct true if the user answered the question correctly, otherwise false. */ public abstract void setAnswerCorrect(boolean correct); /** * Checks whether the user answered the question correctly. * This only makes sense for question of type SINGLE_CHOICE or MULTIPLE_CHOICE. * Otherwise, it returns false. * * @ejb.interface-method * * @return true if the user answered the question correctly, otherwise false. */ public boolean isAnswerCorrect() { return getAnswerCorrect(); } //----------------------------- // Create methods. //----------------------------- /** * Creates a AnswerHistoryRecord. * * @ejb.create-method view-type="local" */ public AnswerHistoryRecordKey ejbCreate( Integer testId, Integer questionId, Integer userId, Integer questionType, int questionIndex, int questionScore, int userScore,String userAnswer, String correctAnswer, boolean answerCorrect, boolean exceedQuesTime ) throws CreateException { setUserId(userId); setTestId(testId); setQuestionId(questionId); setQuestionType(questionType); setQuestionIndex(questionIndex); setQuestionScore(questionScore); setUserScore(userScore); setUserAnswer(userAnswer); setAnswerCorrect(answerCorrect); setCorrectAnswer(correctAnswer); setTimestamp(new Date()); setExceededQuestionTime(exceedQuesTime); return null; } public void ejbPostCreate( Integer testId, Integer questionId, Integer userId, Integer questionType, int questionIndex, int questionScore, int userScore, String userAnswer, String correctAnswer, boolean answerCorrect, boolean exceedQuesTime ) { // Not used. }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -