package com.xdf.exams.web.action;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.xdf.exams.bean.Options;
import com.xdf.exams.bean.Question;
import com.xdf.exams.bean.Subject;
import com.xdf.exams.bo.BOFactory;
import com.xdf.exams.bo.IQuestionService;
import com.xdf.exams.util.Constant;
import com.xdf.exams.util.PageUtil;
import com.xdf.exams.util.Tools;
import com.xdf.exams.web.form.QuestionForm;
import com.xdf.exams.web.form.SubjectForm;
/**
* MyEclipse Struts
* Creation date: 04-05-2007
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class SubjectAction extends BaseDispatchAction {
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward show(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IQuestionService ser = BOFactory.getQuestionService();
String spageno = request.getParameter("pageno");
PageUtil pu = new PageUtil(spageno,ser.findAllSubjectsnum(),Constant.PAGESIZE);
List list = ser.findAllSubjects(pu.getPageno(),pu.getPagesize());
request.setAttribute("subjectlist",list);
request.setAttribute("pageutil",pu);
return mapping.findForward("show");
}
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
this.saveToken(request);
SubjectForm sf = (SubjectForm)form;
return mapping.findForward("add");
}
public ActionForward adddo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SubjectForm sf = (SubjectForm)form;
ActionForward af = null;
if(this.isTokenValid(request)) {
IQuestionService ser = BOFactory.getQuestionService();
Subject s = new Subject();
s.setIntro(sf.getIntro());
s.setName(sf.getName());
s.setSdate(Tools.d2sshort(new Date()));
s.setState(sf.getState());
s.setTime(new Long(sf.getTime()));
try {
ser.addSubject(s);
request.setAttribute("message","增加科目成功");
af = mapping.findForward("show");
this.resetToken(request);
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","增加科目失败");
af = mapping.findForward("add");
}
}else {
request.setAttribute("message","请不要重复刷新");
af = mapping.findForward("show");
}
return af;
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IQuestionService ser = BOFactory.getQuestionService();
SubjectForm sf = (SubjectForm)form;
try {
Subject s = ser.findSubject(sf.getSubjectid());
ser.deleteSubject(s);
request.setAttribute("message","删除成功");
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","删除失败");
}
return mapping.findForward("show");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IQuestionService ser = BOFactory.getQuestionService();
SubjectForm sf = (SubjectForm)form;
try {
Subject s = ser.findSubject(sf.getSubjectid());
sf.setName(s.getName());
sf.setIntro(s.getIntro());
sf.setState(s.getState());
sf.setTime(s.getTime().intValue());
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","查询失败");
}
return mapping.findForward("update");
}
public ActionForward updatedo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IQuestionService ser = BOFactory.getQuestionService();
SubjectForm sf = (SubjectForm)form;
try {
Subject s = ser.findSubject(sf.getSubjectid());
s.setName(sf.getName());
s.setIntro(sf.getIntro());
s.setState(sf.getState());
s.setTime(new Long(sf.getTime()));
ser.updateSubject(s);
request.setAttribute("message","修改成功");
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","修改失败");
}
return mapping.findForward("show");
}
public ActionForward showquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IQuestionService ser = BOFactory.getQuestionService();
QuestionForm sf = (QuestionForm)form;
String spageno = request.getParameter("pageno");
try {
Subject s = ser.findSubject(sf.getSubjectid());
int num = ser.findQuestionnumBySubjects(sf.getSubjectid());
PageUtil pu = new PageUtil(spageno,num,Constant.PAGESIZE);
List list = ser.findQuestionBySubjects(sf.getSubjectid(),pu.getPageno(),pu.getPagesize());
request.setAttribute("questionlist",list);
request.setAttribute("pageutil",pu);
request.setAttribute("subject",s);
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","查询失败");
}
return mapping.findForward("show");
}
public ActionForward addquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QuestionForm qf= (QuestionForm)form;
IQuestionService ser = BOFactory.getQuestionService();
request.setAttribute("subject",ser.findSubject(qf.getSubjectid()));
this.saveToken(request);
return mapping.findForward("add");
}
public ActionForward addquestiondo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward af = null;
if(this.isTokenValid(request)) {
try {
IQuestionService ser = BOFactory.getQuestionService();
QuestionForm qf= (QuestionForm)form;
Question que = new Question();
que.setContent(qf.getContent());
que.setQtype(qf.getQtype());
String rans = "";
if(qf.getRightanswers()!=null)
for (int i=0;i<qf.getRightanswers().length;i++) {
rans += qf.getRightanswers()[i];
}
que.setRightanswer(rans);
que.setScore(qf.getScore());
que.setSdate(Tools.d2sshort(new Date()));
que.setSubject(ser.findSubject(qf.getSubjectid()));
List oplist = new ArrayList();
if(qf.getOptions()!=null)
for (int i=0;i<qf.getOptions().length;i++) {
if(qf.getOptions()[i]!=null&&!qf.getOptions()[i].equals("")) {
Options ops = new Options();
ops.setContent(qf.getOptions()[i]);
ops.setQuestion(que);
oplist.add(ops);
}
}
ser.addQuestion(que,oplist);
request.setAttribute("message","增加试题成功");
af = mapping.findForward("show");
this.resetToken(request);
} catch (RuntimeException e) {
e.printStackTrace();
request.setAttribute("message","增加试题失败");
af = mapping.findForward("add");
}
}else {
request.setAttribute("message","不要重复提交");
af = mapping.findForward("show");
}
return af;
}
public ActionForward updatequestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QuestionForm qf= (QuestionForm)form;
IQuestionService ser = BOFactory.getQuestionService();
Question que = ser.findQuestion(qf.getQuestionid());
qf.setSubjectid(qf.getSubjectid());
qf.setQuestionid(que.getQuestionid());
qf.setContent(que.getContent());
qf.setQtype(que.getQtype());
qf.setScore(que.getScore());
qf.setRightanswers(Tools.tostringarray(que.getRightanswer()));
Set s = que.getOptionses();
String[] os = new String[8];
int i=0;
for (Object o:s) {
Options opt = (Options)o;
os[i]
没有合适的资源?快使用搜索试试~ 我知道了~
通用的在线考试系统(jsp+struts+hibernate+oracle).zip项目JAVA源码+资料打包下载
共342个文件
gif:95个
class:71个
java:71个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 158 浏览量
2022-03-11
20:22:22
上传
评论
收藏 3.09MB ZIP 举报
温馨提示
通用的在线考试系统(jsp+struts+hibernate+oracle).zip项目JAVA源码+资料打包下载通用的在线考试系统(jsp+struts+hibernate+oracle).zip项目JAVA源码+资料打包下载 1.适合学生做毕业设计参考 2.适合个人学习技术研究参考 3.适合小公司做对应项目参考
资源推荐
资源详情
资源评论
收起资源包目录
通用的在线考试系统(jsp+struts+hibernate+oracle).zip项目JAVA源码+资料打包下载 (342个子文件)
1.jpg.bak 60KB
1.bat 147B
1.bat 147B
SubjectAction.class 9KB
ExamAction.class 7KB
QuestionServiceImp.class 6KB
StudentAction.class 5KB
ResultDAOImp.class 5KB
TeacherAction.class 4KB
ResultAction.class 4KB
StudentServiceImp.class 4KB
ExamServiceImp.class 4KB
StudentDAOImp.class 4KB
StudentInfoAction.class 3KB
Subject.class 3KB
RightFilter.class 3KB
Question.class 3KB
BOFactory.class 3KB
LoginAction.class 3KB
RegistAction.class 3KB
QuestionDAOImp.class 3KB
ResultServiceImp.class 3KB
Student.class 3KB
LogAction.class 3KB
Result.class 3KB
LogServiceImp.class 2KB
QuestionForm.class 2KB
ResultListAction.class 2KB
StudentForm.class 2KB
HibernateSessionFactory.class 2KB
Tools.class 2KB
LoginlogDAOImp.class 2KB
QueryResultForm.class 2KB
TeacherServiceImp.class 2KB
Loginlog.class 2KB
SubjectForm.class 2KB
PageUtil.class 2KB
TeacherDAOImp.class 2KB
SubjectDAOImp.class 2KB
Examrecord.class 2KB
DAOFactory.class 2KB
TeacherForm.class 1KB
QueryLogForm.class 1KB
BaseDispatchAction.class 1KB
LoginForm.class 1KB
ExamForm.class 1KB
HibernateFilter.class 1KB
StudentLogoutAction.class 1KB
TeacherLogoutAction.class 1KB
Options.class 1KB
EncodingFilter.class 1KB
Test.class 1KB
Teacher.class 1KB
ExamrecordDAOImp.class 1KB
BaseDAO.class 1KB
QueryStudentForm.class 1KB
BaseService.class 1KB
OptionsDAOImp.class 941B
IQuestionService.class 823B
IResultDAO.class 642B
IStudentService.class 607B
IResultService.class 574B
IStudentDAO.class 548B
ILogService.class 490B
ITeacherService.class 410B
Constant.class 387B
IQuestionDAO.class 374B
IExamService.class 357B
ITeacherDAO.class 351B
ISubjectDAO.class 324B
ILoginlogDAO.class 287B
IDAO.class 256B
IExamrecordDAO.class 251B
IOptionsDAO.class 200B
.classpath 1KB
style.css 948B
Thumbs.db 80KB
Thumbs.db 80KB
Model2.DM1 250KB
obj_sitetitle.gif 7KB
obj_sitetitle.gif 7KB
ba_goriyo-annai2.gif 3KB
ba_goriyo-annai3.gif 3KB
ba_goriyo-annai4.gif 3KB
ba_goriyo-annai4.gif 3KB
ba_goriyo-annai2.gif 3KB
ba_goriyo-annai6.gif 3KB
ba_goriyo-annai6.gif 3KB
ba_goriyo-annai3.gif 3KB
ba_goriyo-annai5.gif 3KB
ba_goriyo-annai5.gif 3KB
obj_sample_02.gif 2KB
obj_sample_02.gif 2KB
obj_top.gif 1KB
obj_top.gif 1KB
bt_03.gif 654B
bt_01.gif 654B
bt_05.gif 637B
bt_05.gif 637B
bt_02.gif 628B
共 342 条
- 1
- 2
- 3
- 4
资源评论
yxkfw
- 粉丝: 81
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功