项目编号:BS-GX-018
本系统基于SSM框架实现开发,前端采用BootStrap+Jquery 实现页面的设计与用户的交互。开发工具使用IDEA或Eclipse,数据库采用MYSQL数据库。
在校学生考试系统是一个功能非常完整的系统,界面简洁大方,用户交互性好,完整的包含了在校学生考试需要的相关功能:像题库管理,试卷管理,组卷管理,考试安排管理,在线考试,自动阅卷等功能均包含在内,比较适合做毕业设计使用,如果你选择了它,一定是一个优秀的毕业设计。
本系统角色分为三种:
管理员:可以对各类信息进行管理操作等
教师:主要进行试卷管理,试题管理和安排考试等
学生:主要进行系统参加考试,并进看考试分析结果等
下面一 一为大家展示系统的相关功能。
管理员登陆
http://localhost:8080/admin/login.jsp pcs / 123123
后台管理主界面:
年级管理
科目管理
班级管理:基本信息管理
班级管理:各班人数统计
教师管理:
学生管理:基本信息管理
学生管理:学生考试信息管理
试卷管理:
试题管理:
导入试题:
考试安排:
考试记录:
二,教师登陆系统
lyinping / 123456
考试登陆系统后一些基本信息只能查看,不能管理,但是可以管理学生、试卷、试题、安排考试,具体功能见管理员操作,不再一一截图。
三,学生登陆系统
user01 / 111111
学生在前台先注册再登陆:
进入考试中心进行考试:
答题考试
考试历史:回顾试卷
以上是在校学生考试系统的部分功能展示,所展示的各个功能模块增删改查的功能均能正常运行,功能十分强大,业务非常流畅,是一个难得的优秀系统。
系统实现的核心代码:
package com.taohan.online.exam.handler; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.google.gson.Gson; import com.taohan.online.exam.service.ExamPaperInfoService; import com.taohan.online.exam.service.StudentInfoService; import com.taohan.online.exam.service.SubjectInfoService; import com.taohan.online.exam.service.TeacherInfoService; /** * * <p>Title: AdminHomeHandler</p> * <p>Description: 后台首页相关</p> * @version: 1.0 */ @Controller public class AdminHomeHandler { @Autowired ExamPaperInfoService examPaperInfoService; @Autowired SubjectInfoService subjectInfoService; @Autowired TeacherInfoService teacherInfoService; @Autowired StudentInfoService studentInfoService; @Autowired Gson gson; private Logger logger = Logger.getLogger(AdminHomeHandler.class); @RequestMapping("/homeInfo") public void homeInfo(HttpServletResponse response) throws IOException { logger.info("加载后台首页相关数据"); int examPaperTotal = examPaperInfoService.getExamPpaerTotal(); int subjectTotal = subjectInfoService.getSubjectTotal(); int teacherTotal = teacherInfoService.getTeacherTotal(); int studentTotal = studentInfoService.getStudentTotal(); String json = "{\"examPaperTotal\":"+examPaperTotal+", " + "\"subjectTotal\":"+subjectTotal+", " + "\"teacherTotal\":"+teacherTotal+", " + "\"studentTotal\":"+studentTotal+"}"; response.getWriter().print(json); } }
package com.taohan.online.exam.handler; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import com.google.gson.Gson; import com.taohan.online.exam.charts.StudentCount; import com.taohan.online.exam.po.ClassInfo; import com.taohan.online.exam.po.GradeInfo; import com.taohan.online.exam.po.TeacherInfo; import com.taohan.online.exam.service.ClassInfoService; import com.taohan.online.exam.service.GradeInfoService; import com.taohan.online.exam.service.TeacherInfoService; /** * * <p>Title: ClassInfoHandler</p> * <p>Description: 班级</p> * @version: 1.0 */ @Controller @SuppressWarnings("all") public class ClassInfoHandler { @Autowired private ClassInfoService classInfoService; @Autowired private GradeInfoService gradeInfoService; @Autowired private TeacherInfoService teacherInfoService; @Autowired private TeacherInfo teacher; @Autowired private ClassInfo classInfo; @Autowired private Gson gson; private Logger logger = Logger.getLogger(ClassInfoHandler.class); /** * 获取所有班级 * @param gradeId 年级编号 * @param className 班级名称 可用于模糊查询 * @param classId 班级编号 * @return */ @RequestMapping(value="/classes", method=RequestMethod.GET) public ModelAndView getClasses(@RequestParam(value="gradeId", required=false) Integer gradeId, @RequestParam(value="className", required=false) String className, @RequestParam(value="classId", required=false) Integer classId) { logger.info("获取班级集合 条件:gradeId: "+gradeId+", 班级编号:"+classId+", 班级:"+className); ModelAndView model = new ModelAndView(); ClassInfo classInfo = new ClassInfo(); /*处理查询条件*/ if (gradeId != null) { GradeInfo gradeInfo = new GradeInfo(); gradeInfo.setGradeId(gradeId); classInfo.setGrade(gradeInfo); } if (classId != null) classInfo.setClassId(classId); if (className != null) { if (className.trim() != "") classInfo.setClassName(className); } List<ClassInfo> classes = classInfoService.getClasses(classInfo); model.setViewName("admin/classes"); model.addObject("classes", classes); return model; } /** * 预添加班级处理 * @return */ @RequestMapping("/preAddClass") public ModelAndView preAddClass() { logger.info("预添加班级信息"); ModelAndView model = new ModelAndView(); //获取年级信息 List<GradeInfo> grades = gradeInfoService.getGrades(); model.setViewName("admin/classedit"); model.addObject("grades", grades); //获取不是班主任的教师 teacher.setIsWork(0); Map<String, Object> map = new HashMap<String, Object>(); map.put("startIndex", null); map.put("pageShow", null); map.put("teacher", teacher); List<TeacherInfo> teachers = teacherInfoService.getTeachers(map); model.addObject("teachers", teachers); model.addObject("editClass", new ClassInfo()); return model; } /** * 添加班级 * @param classInfo 班级信息 * @param request * @return */ @RequestMapping(value="/class", method=RequestMethod.POST) public String isAddClass(ClassInfo classInfo, HttpServletRequest request) { logger.info("添加班级信息 "+classInfo); //修改教师班主任状态 String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId()); if (returnMsg != null) { request.setAttribute("error", "修改教师班主任状态 对应教师编号有误"); return "error"; } //添加 int row = classInfoService.isAddClass(classInfo); if (row < 1) { logger.error("班级 "+classInfo+" 删除失败"); request.setAttribute("error", "班级 "+classInfo.getClassName()+" 添加失败,请稍后再试!"); return "../error"; } return "redirect:/classes"; } /** * 删除班级 * @param classId 班级编号 * @param request * @return */ @RequestMapping(value="/del/class/{classId}", method=RequestMethod.DELETE) public String isDelClass(@PathVariable("classId") Integer classId, HttpServletRequest request) { logger.info("删除班级 "+classId); //将删除班级对于之前班主任改为 非班主任状态 //需要在删除班级之前修改,如果先删除了班级,再根据班级获取教师编号,就不能获取 ClassInfo delClass = classInfoService.getClassById(classId); String returnMsg = isChangeTeacherWork(0, delClass.getTeacher().getTeacherId()); if (returnMsg != null) { request.setAttribute("error", "修改教师班主任状态 对应教师编号有误"); return "error"; } //删除 int row = classInfoService.isDelClass(classId); if (row < 1) { logger.error("班级 "+classId+" 删除失败"); request.setAttribute("error", "班级删除失败,请稍后再试!"); return "../error"; } return "redirect:/classes"; } /** * 预修改班级处理 * @param classId 班级编号 * @return */ @RequestMapping(value="edit/class/{classId}", method=RequestMethod.GET) public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) { logger.info("预修改班级处理"); ModelAndView model = new ModelAndView(); //获取要修改班级 ClassInfo classInfo = classInfoService.getClassById(classId); model.setViewName("/admin/classedit"); model.addObject("editClass", classInfo); List<GradeInfo> grades = gradeInfoService.getGrades(); //获取不是班主任的教师 teacher.setIsWork(0); Map<String, Object> map = new HashMap<String, Object>(); map.put("startIndex", null); map.put("pageShow", null); map.put("teacher", teacher); List<TeacherInfo> teachers = teacherInfoService.getTeachers(map); //如果没有可用班主任 if (teachers.size() == 0 || teachers == null) { teacher.setTeacherId(classInfo.getTeacher().getTeacherId()); teacher.setTeacherName("暂无剩余教师"); teachers.add(teacher); } model.addObject("teachers", teachers); model.addObject("grades", grades); return model; } /** * 修改班级信息 * @param classInfo 班级信息 * @param request * @param lastTeacherId 上一个班主任编号,修改其 班主任状态 * @return */ @RequestMapping(value="edit/class/class", method=RequestMethod.PUT) public String isUpdateClass(ClassInfo classInfo, HttpServletRequest request, @RequestParam(value="lastTeacher", required=false) Integer lastTeacherId) { //修改上一教师不为班主任状态 if (lastTeacherId != null) { String returnMsg = isChangeTeacherWork(0, lastTeacherId); if (returnMsg != null) { request.setAttribute("error", "修改教师班主任状态 对应教师编号有误"); return "/error"; } } //修改当前教师为班主任状态 String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId()); if (returnMsg != null) { request.setAttribute("error", "修改教师班主任状态 对应教师编号有误"); return "/error"; } logger.info("修改班级 "+classInfo); int row = classInfoService.isUpdateClass(classInfo); if (row < 1) { logger.error("班级 "+classInfo+" 修改失败"); request.setAttribute("error", "班级修改失败,请稍后再试!"); return "../error"; } return "redirect:/classes"; } /** * 获取指定年级下的班级 * @param gradeId 年级编号 * @param response * @throws IOException */ @RequestMapping(value="/gradeclass/{gradeId}", method=RequestMethod.GET) public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId, HttpServletResponse response) throws IOException { logger.info("获取年级 "+gradeId+" 下的班级集合"); List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId); String json = gson.toJson(classes); response.getWriter().print(json); } /** * 修改教师(班主任)工作状态 * @param status 是否为班主任标识 * @param teacherId 教师编号 */ private String isChangeTeacherWork(int status, Integer teacherId) { logger.info("修改教师 "+teacherId+" 的状态为 "+status); teacher.setIsWork(status); if (teacherId == null) { logger.error("修改教师班主任状态 对应教师编号有误"); return "修改教师班主任状态 对应教师编号有误"; } teacher.setTeacherId(teacherId); int row = teacherInfoService.updateTeacherIsWork(teacher); return null; } @RequestMapping("/stuCount") public void getStudentCountForClass( @RequestParam(value="gradeId", required=false) Integer gradeId, HttpServletResponse response) throws IOException { Map<String, Object> map = classInfoService.getStudentCountForClass(gradeId); String json = StudentCount.createBarJson(map); response.getWriter().print(json); } /** * 预添加班级处理 * @return */ @RequestMapping("/preStudentCount") public ModelAndView preStudentCount() { ModelAndView model = new ModelAndView(); //获取年级信息 List<GradeInfo> grades = gradeInfoService.getGrades(); model.setViewName("admin/charts/studentCount"); model.addObject("grades", grades); return model; } }
package com.taohan.online.exam.handler; import java.util.List; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import com.taohan.online.exam.po.CourseInfo; import com.taohan.online.exam.po.GradeInfo; import com.taohan.online.exam.service.CourseInfoService; import com.taohan.online.exam.service.GradeInfoService; /** * * <p>Title: CourseInfoHandler</p> * <p>Description: 科目</p> * @version: 1.0 */ @Controller @SuppressWarnings("all") public class CourseInfoHandler { @Autowired private CourseInfoService courseInfoService; @Autowired private GradeInfoService gradeInfoService; private Logger logger = Logger.getLogger(CourseInfoHandler.class); /** * 获取科目信息 * @param gradeId 年级编号 * @param division 分科情况 * @return */ @RequestMapping("/courses") public ModelAndView getCourses(@RequestParam(value="gradeId", required=false) Integer gradeId, @RequestParam(value="division", required=false) Integer division) { logger.info("获取科目集合 年级条件 "+gradeId+" 分科条件 "+division); ModelAndView model = new ModelAndView(); model.setViewName("/admin/courses"); CourseInfo course = new CourseInfo(); if (gradeId != null) course.getGrade().setGradeId(gradeId); if (division != null) course.setDivision(division); List<CourseInfo> courses = courseInfoService.getCourses(course); model.addObject("courses", courses); return model; } /** * 根据科目编号获取学科信息 * @param courseId 科目编号 * @return */ @RequestMapping("/course/{courseId}") public ModelAndView getCourseById(@PathVariable("courseId") Integer courseId) { logger.info("获取科目信息 科目编号 "+courseId); ModelAndView model = new ModelAndView(); model.setViewName("/admin/courseedit"); CourseInfo course = courseInfoService.getCourseById(courseId); model.addObject("course", course); /** 获取所有年级列表 */ List<GradeInfo> grades = gradeInfoService.getGrades(); model.addObject("grades", grades); return model; } /** * 添加/修改科目信息 * @param courseId 科目编号 * @param isUpdate 标识是否为修改操作 * @param courseName 科目名称 * @param division 分科情况 * @param gradeId 年级编号 * @return */ @RequestMapping(value="/course/course", method=RequestMethod.POST) public String isUpdateOrAddCourse(@RequestParam(value="courseId", required=false) Integer courseId, @RequestParam(value="isupdate", required=false) Integer isUpdate, @RequestParam("courseName") String courseName, @RequestParam("division") Integer division, @RequestParam("gradeId") Integer gradeId) { CourseInfo course = new CourseInfo(); course.setCourseId(courseId); course.setCourseName(courseName); course.setDivision(division); GradeInfo grade = new GradeInfo(); grade.setGradeId(gradeId); course.setGrade(grade); //修改 if (isUpdate != null) { logger.info("修改科目 "+course+" 的信息"); int row = courseInfoService.isUpdateCourse(course); } //添加 else { logger.info("添加科目 "+course+" 的信息"); int row = courseInfoService.isAddCourse(course); } return "redirect:/courses"; } /** * 删除科目 * @param courseId 待删除科目编号 * @return */ @RequestMapping(value="/course/{courseId}", method=RequestMethod.DELETE) public String isDelTeacher(@PathVariable("courseId") Integer courseId) { logger.info("删除科目 "+courseId); int row = courseInfoService.isDelCourse(courseId); return "redirect:/courses"; } /** * 预添加科目信息 * @return */ @RequestMapping("/preAddCourse") public ModelAndView preAddCourse() { logger.info("预添加科目信息"); ModelAndView model = new ModelAndView(); model.setViewName("/admin/courseedit"); /** 获取年级集合 */ List<GradeInfo> grades = gradeInfoService.getGrades(); model.addObject("grades", grades); return model; } }