源码获取:博客首页 "资源" 里下载!

运行环境:jdk1.8、Mysql5.7、Tomcat8.5、IDEA/Eclipse

功能简介:在线考试、历史回顾、个人成绩查询等。

管理员和教师功能有:学院管理、班级管理、课程管理、教师、学生管理、统计分析、试卷试题管理、考试安排管理、历史考试管理等

在线考试控制层:

@Controller
@RequestMapping("/exam")
public class ExamController {@Autowiredprivate ExamService examService;@Autowiredprivate PaperService paperService;@Autowiredprivate RecordService recordService;//前台跳转@RequestMapping("/toExam")public String toExam(Model model){List<Exam> Exams = examService.getAll();model.addAttribute("Exams",Exams);return "exam/examplan";}@RequestMapping("/toError")public String toError(Model model){List<Exam> Exams = examService.getAll();model.addAttribute("Exams",Exams);return "exam/error";}@RequestMapping("/tomError")public String tomError(Model model){List<Exam> Exams = examService.getAll();model.addAttribute("Exams",Exams);return "exam/merror";}@RequestMapping("/toHist/{id}")public String toHist(@PathVariable ("id") Integer id,Model model){List<Record> records=recordService.queryAllExamById(id);model.addAttribute("records",records);return "exam/histplan";}//从其他页面跳转到home@RequestMapping("/toHome")public String tohome(){return "redirect:/indexprexam";}//来到对应考试页面@RequestMapping("/toDoExam/{id}")public String toDoExam(@PathVariable ("id") Integer id,Model model,String examId,HttpServletRequest request){HttpSession session=request.getSession();Student stu = (Student) session.getAttribute("loger");
//       if() {
//              Record record=new Record();
//              record.setStudentId(stu.getStudentId());
//              record.setPaperId(id);List<Record> ss=  recordService.queryAllExamById(stu.getStudentId());for (int i = 0; i < ss.size(); i++) {if(ss.get(i).getPaperId() ==id ) {return "redirect:/exam/tomError";}}
//       }List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(id);int exId=Integer.parseInt(examId);Exam examById = examService.getExamById(exId);Paper paperName = paperService.queryPaperNameById(examById.getPaperId());model.addAttribute("paperName",paperName);model.addAttribute("examById",examById);model.addAttribute("questionPapers",questionPapers);return "exam/doExam";}//提交试卷@RequestMapping("/submitExam")public String submitExam(Integer paperId, Integer studentId, HttpServletRequest request){List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(paperId);List<String> ans=new ArrayList<>();List<String> RightAns=new ArrayList<>();for (QuestionPaper qb:questionPapers){RightAns.add(qb.getQuestion().getQuestionOpright());String parameter="";String []parameters;if(qb.getQuestion().getQuestionType().equals("y")){parameters= request.getParameterValues("optionsSelect" + qb.getQuestionId());if(parameters!=null) {for(String s:parameters){parameter+=s;}}}else {parameter = request.getParameter("optionsSelect" + qb.getQuestionId());if(parameter==null) {return "redirect:/exam/toError";}}ans.add(parameter);}//核对答案得到成绩int k=0;    //哨兵Double y=0.0;    //正确数int score=0;    //得分int a=0;        //记录单选题个数int b=0;        //记录多选题个数int c=0;        //记录判断题个数int totalScore=0;for (QuestionPaper qb:questionPapers){if(ans==null) {break;}//若为单选题则正确+单选题分数if(qb.getQuestion().getQuestionType().equals("x")){if(ans.get(k).equals(RightAns.get(k))){score+=qb.getPaper().getScoreSin();y++;}a++;k++;}else if(qb.getQuestion().getQuestionType().equals("y")){if(ans.get(k).equals(RightAns.get(k))){score+=qb.getPaper().getScoreChe();y++;}b++;k++;}else {if(ans.get(k).equals(RightAns.get(k))){score+=qb.getPaper().getScoreJug();y++;}c++;k++;}}int scoreSin1 = questionPapers.get(0).getPaper().getScoreSin();int scoreChe1 = questionPapers.get(0).getPaper().getScoreChe();int scoreJug1 = questionPapers.get(0).getPaper().getScoreJug();int bool=recordService.queryBooleanToscore(paperId);if (bool==0){totalScore=scoreSin1*a+scoreChe1*b+scoreJug1*c; //得到每张试卷总分Toscore toscore=new Toscore();toscore.setPaperId(paperId);toscore.setToscore(totalScore);recordService.AddToScore(toscore);}//保存答题记录String answer = String.join(",", ans);Paper paper = paperService.queryPaperNameById(paperId);String paperName = paper.getPaperName();Double recordAcc=y/k;int recordScore=score;Record record=new Record();record.setRecordName(paperName);record.setStudentId(studentId);record.setPaperId(paperId);record.setRecordAnswer(answer);record.setRecordAcc(recordAcc);record.setRecordScore(recordScore);recordService.addRecord(record);return "redirect:/exam/toExam";}/*** 考试后台* *///查看所有考试安排后台@RequestMapping("/getAllExam")public String getAllExam(Model model){List<Exam> Exams = examService.getAllS();model.addAttribute("Exams",Exams);return "exam/backexamlist";}//去往考试添加页面@RequestMapping("/toAddExam")public String toAddExam(Model model){List<Paper> papers = paperService.getAll();model.addAttribute("papers",papers);return "exam/AddExam";}//添加操作@RequestMapping("/addExam")public String addExam(Exam exam, String examBegins,String examEnds) throws ParseException {String t1 = examBegins.replace("T", " ");String t2 = examEnds.replace("T", " ");SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");Date begin = sdf.parse(t1);Date end = sdf.parse(t2);exam.setExamBegin(begin);exam.setExamEnd(end);examService.AddExam(exam);return "redirect:/exam/getAllExam";}@RequestMapping("/deleteExam/{id}")public String toEditExam(@PathVariable ("id") Integer id,Model model){examService.deleteById(id);return "redirect:/exam/getAllExam";}
}

学生管理控制层:

@Controller
@RequestMapping("/student")
public class StudentController {@Autowiredprivate ClasseMapper classeMapper;@Autowiredprivate StudentService studentService;
//查看所有学生@RequestMapping("/getAllStudent")public String getAllStudent(Model model){List<Student> students = studentService.getAll();model.addAttribute("students",students);return "student/studentList";}//修改编辑功能,先获取该id得学生信息@RequestMapping("/{id}")public String updateStudent(@PathVariable("id") Integer id,Model model){Student student=studentService.getStudentById(id);List<Classe> classes = classeMapper.queryAll();model.addAttribute("classes",classes);model.addAttribute("student",student);return "student/studentEdit";}
//更改学生信息@RequestMapping("/editStudent")public String EditStudent(Student student){studentService.EditStudent(student);return "redirect:/student/getAllStudent";}
//删除学生@RequestMapping("/deleteStudent/{id}")public String deleteStudent(@PathVariable("id") Integer id){studentService.deleteById(id);return "redirect:/student/getAllStudent";}
}

试题控制层:

@Controller
@RequestMapping("/question")
public class QuestionController {@Autowiredprivate QuestionService questionService;@Autowiredprivate TeacherService teacherService;@Autowiredprivate PaperService paperService;//查看所有试题 pagesize控制每页数据条数@RequestMapping("/getAllQuestion")public String getAllQuestion(Question question,@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "4") int pageSize,Model model){//查找所有题目课程和所有类型,且去重List<Question> questionCourses=questionService.queryAllCourse();questionCourses.add(new Question("bug","all"));List<Question> questionTypes=questionService.queryAllType();questionTypes.add(new Question("k","bug"));String questionCourseBef = question.getQuestionCourse();String questionCourseresRes="";if(questionCourseBef==null){//默认查询所有questionCourseresRes="all";}else {questionCourseresRes=questionCourseBef;}//若是第一次查询则用上次提交的表单中的类型、课程,若是第二次查询则延用上次类型String questionTypeBef=question.getQuestionType();String questionTypesRes="";if(questionTypeBef==null){//默认查询所有questionTypesRes="k";}else {questionTypesRes=questionTypeBef;}List<Question> questionids=paperService.queryALlQuestionId();List<Integer> quesIds=new ArrayList<>();for(Question qid:questionids){quesIds.add(qid.getQuestionId());}model.addAttribute("quesIds",quesIds);PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据List<Question> questions = questionService.getAll(question);PageInfo<Question> pageInfo = new PageInfo<Question>(questions);model.addAttribute("questionCourseresRes",questionCourseresRes);model.addAttribute("questionTypesRes",questionTypesRes);model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);model.addAttribute("pageInfo",pageInfo);return "question/questionList";}
//试题添加或者修改操作,先去添加页面@RequestMapping("/toAddQuestion")public String toAddQuestion(Model model){List<Question> questionCourses=questionService.queryAllCourse();List<Question> questionTypes=questionService.queryAllType();model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);return "question/questionAdd";}//添加具体操作@RequestMapping("/addQuestion")public String addQuestion(Question question){questionService.addQuestion(question);return "redirect:/question/getAllQuestion";}//试题去修改页面@RequestMapping("/toEditQuestion/{id}")public String toEditQuestion(@PathVariable("id") Integer id,Model model){List<Question> questionCourses=questionService.queryAllCourse();List<Question> questionTypes=questionService.queryAllType();Question question=questionService.getQuestionById(id);model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);model.addAttribute("question",question);return "question/questionEdit";}//修改具体操作@RequestMapping("/EditQuestion")public String EditQuestion(Question question){questionService.editQuestion(question);return "redirect:/question/getAllQuestion";}//试题删除@RequestMapping("/deleteQuestion/{id}")public String deleteQuestionById(@PathVariable("id") Integer id){questionService.deleteQuestionById(id);return "redirect:/question/getAllQuestion";}}

源码获取:博客首页 "资源" 里下载!

Java项目:在线考试系统(java+SSM+mysql+JSP)相关推荐

  1. Java项目:在线考试系统(java+springboot+vue+jsp+mysql+maven)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统主要实现的功能有: 学生以及老师的注册登录,在线考试,错题查询,学生管理,问题管理,错题管理,错题查询,分数查询,试卷管 ...

  2. Java项目:在线考试系统(java+springBoot+vue+Mysql+maven)

    源码获取:博客首页 "资源" 里下载! 管理员和教师登陆此账号就进入后台,学生登陆此账号就进入前端做题. 老师发布了考试,学生才可以在主页面看到相应的考试信息. 有考试安排表以后, ...

  3. Java项目:在线考试系统(单选,多选,判断,填空,简答题)(java+Springboot+ssm+mysql+html+maven)

    源码获取:博客首页 "资源" 里下载! 功能: 学生信息 班级 专业 学号 姓名  在线考试 成绩查询 个人信息 密码修改 教师管理 教师编号 姓名  所教科目  题库管理  单选 ...

  4. Java项目:在线旅游系统(java+jsp+SSM+Spring+mysql+maven)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 功能:用户的登录注册,旅游景点的展示,旅游预订,收藏,购买,以及酒店住宿留言等等,后台管理员,订单管理,景点管理,留言管理,分 ...

  5. java计算机毕业设计web在线考试系统源码+mysql数据库+系统+lw文档+部署

    java计算机毕业设计web在线考试系统源码+mysql数据库+系统+lw文档+部署 java计算机毕业设计web在线考试系统源码+mysql数据库+系统+lw文档+部署 本源码技术栈: 项目架构:B ...

  6. 基于Java毕业设计在线考试系统源码+系统+mysql+lw文档+部署软件

    基于Java毕业设计在线考试系统源码+系统+mysql+lw文档+部署软件 基于Java毕业设计在线考试系统源码+系统+mysql+lw文档+部署软件 本源码技术栈: 项目架构:B/S架构 开发语言: ...

  7. 2023计算机毕业设计SSM最新选题之java中小学在线考试系统s29r0

    2023计算机毕业设计SSM最新选题之java中小学在线考试系统s29r0 最近发现近年来越来越多的人开始追求毕设题目的设创.和新颖性.以往的xx管理系统.xx校园系统都过时了.大多数人都不愿意做这类 ...

  8. java毕业设计在线考试系统Mybatis+系统+数据库+调试部署

    java毕业设计在线考试系统Mybatis+系统+数据库+调试部署 java毕业设计在线考试系统Mybatis+系统+数据库+调试部署 本源码技术栈: 项目架构:B/S架构 开发语言:Java语言 开 ...

  9. 基于Java的在线考试系统(附:源码和课件)

    项目介绍: 本系统是一个基于java的在线考试系统.它的用户由学生.教师和系统管理员组成.学生登陆系统可以进行在线测试和成绩查询.当学生登陆时,系统会随机地为学生选取试题组成考卷.当学生提交考卷后,系 ...

最新文章

  1. 活动报名丨悟道开放日:大模型最新研究进展、应用开发训练营、50+闪电演讲作者面对面...
  2. MongoDB 全文检索
  3. Codeforces Round #265 (Div. 2) E. Substitutes in Number
  4. delphi listview怎么自动宽度_自动门日常使用出现这些问题应尽快维修以免因小失大...
  5. 人工智能会让工作环境变得更公平,还是更压抑?
  6. java薪资年龄交叉表_巧用参数实现交叉表行列互换
  7. Python实现Adaboost
  8. python ppt自动生成_如何自动化生成PPT缩略图?
  9. 一首歌,一种情感,一种心情
  10. 错误:在非结构或联合中请求成员‘next’
  11. 初识生成器与生成器表达式 Day12
  12. 【爆牙齿】说说我期待中的苹果那块板子。
  13. 《Windows黑客编程技术》—— 学习历程
  14. Openjudge 1.13 33:实数加法
  15. 如何通过iPhone或Android手机制作自己的QR码
  16. 7个实用的Python自动化代码,别再重复造轮子了!
  17. 迷你世界一直显示服务器未连接,迷你世界为什么显示没网 | 手游网游页游攻略大全...
  18. F7弹出界面模糊查询
  19. Ubuntu22.04上安装Xilinix Vivado 2018.3
  20. 公共自行车租赁点无线管理解决方案

热门文章

  1. 在CentOS 6.6 64bit上基于源码安装全功能的vim 7.4实录
  2. UE4创建第一人称射击游戏学习教程 Unreal Engine 4: Create Your Own First-Person Shooter
  3. Go 分布式学习利器(14)-- Go语言的错误处理
  4. windows下 Source Monitor代码度量工具的使用
  5. static String valueOf(XXX xxx)
  6. P2261 [CQOI2007]余数求和
  7. Comparator 和 Comparable
  8. Eclipse+SVN搭建开发环境
  9. android:更改PagerTabStrip背景颜色,标题字体样式、颜色和图标,以及指示条的颜色...
  10. [转]HTTP协议详解