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]
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
基于jsp实现的通用的在线考试系统(jsp+struts+hibernate+oracle).zip (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
TeacherLogoutAction.class 1KB
StudentLogoutAction.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_01.gif 654B
bt_03.gif 654B
bt_05.gif 637B
bt_05.gif 637B
bt_02.gif 628B
共 342 条
- 1
- 2
- 3
- 4
资源评论
CyMylive.
- 粉丝: 7284
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 机器学习客观题测验,备战期末复习的题库
- HBR740语音识别协处理芯片开发工具包(硬件参考设计原理图+PCB+51单片机软件驱动源码DEMO例程+文档资料).zip
- 数据库管理工具:dbeaver-ce-23.0.1-macos-aarch64.dmg
- M25P20, M25P40, M25P80, M25P16, M25P32, M25P64存储 SPI FLASH C语言驱动
- Matlab基于PCA算法的简单图像人脸识别.zip
- 免费的画图工具drawio,可以代替visio,版本24.5.3,适用于windows
- 瑞昱RTL8723DS-WiFi-linux- android 驱动 内含详细移植说明,支持android4.4
- AMSR/ADEOS-II L1A Raw Observation Counts, Version 3用户手册
- zaopingshujufenxi.zip
- 六级作文模板万能句型pdf.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功