试题管理批量添加试题
组卷管理手动组卷管理自动组卷管理
考试登录
进行答题
提交试卷
查询成绩
图1
系统总体功能结构图
图2
教师信息管理页面图
56
2011.03
NETWORK&;COMMUNICATION
教师管理实现主要代码:界面效果如图4所示。
网络与
通信 //保存教师信息publicActionForwardaddTeacher(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{HttpSessionsession=request.getSession();TeacherDAOtdao=newTeacherDAO();//初始化教师数据库处理对象TeacherFormteacherform=(TeacherForm)form;Stringtid=request.getParameter("tid");Listlist=tdao.findByTid(tid);//查看该教工号是否已经存在if(list.isEmpty()){Teacherteacher=newTeacher();//初始化教师类对象teacher.setTid(teacherform.getTid());//设置教师对象值teacher.setName(teacherform.getName());teacher.setPass
word(teacherform.getPassword());teacher.setBornplace(teacherform.getBornplace());teacher.setContact(teacherform.getContact());tdao.save(teacher);//保存对象System.out.println("插入成功");returnnewActionForward("/teacher.do?action=listTeacher");}else{session.setAttribute("errorteach","添加失败,教工号"+tid+"已经存在");returnnewActionForward("/newTeacher.do");}}
(2)试题模块试题模块中可实现试题的添加、修改、删除等功能。试题管理的流程如图3所示。
图4
添加选择题页面
添加题目实现主要代码:
publicActionForwardquestionAdd(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)//试题添加throwsException{StringuserName=(String)request.getSession().getAttribute("loginname");if(userName==null){returnmapping.findForward("reLogin");}QuestionActionFormquestionform=(QuestionActionForm)form;Questionquestion=newQuestion();QuestionTypequestionType=questionTypeDAOImpl.findById(questionform.getQuesTypeId());//试题题型Subjectsubject=(Subject)subjectDAO.findById(questionform.getSubId()).get(0);//试题科目QuestionAnswerquesAns=newQuestionAnswer();//试题答案quesAns.setQuesAns(questionform.getQuesAns());quesAns.setQuesAnsOne(questionform.getQuesAnsOne());quesAns.setQuesAnsTwo(questionform.getQuesAnsTwo());quesAns.setQuesAnsThree(questionform.getQuesAnsThree());quesAns.setQuesAnsFour(questionform.getQuesAnsFour());question.setQuesContent(questionform.getQuesContent());//设置试题内容question.setQuestionType(questionType);//设置试题题型question.setSubject(subject);//设置试题科目question.setQuesLevel(questionform.getQuesLevel());//设置试题难易度question.setQuesCreate(userName);//设置出题者SimpleDateFormatformatter=newSimpleDateFormat("yyyy-MM-dd");//设置出题日期