当前位置: 首页 > 编程日记 > 正文

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

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

运行环境: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";}}

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

相关文章:

Keil中使用宏编译来定义DEBUG输出

使用宏编译来格式化调试信息&#xff0c;是一个不错的方法&#xff0c;即可以在需要的时候打印出信息&#xff0c;还可以格式化我们所需要的输出。 #define DEBUG 1 #if (DEBUG 1) #define DBG(Args...) printf(##Args) #define DBGFL(s, Args...) printf("[%s:%d]&qu…

解决用户使用临时配置文件登陆WIN7的问题

用户登录Win7后&#xff0c;经常会遇到 “您已使用临时配置文件登陆” 的提示,忽略此提示的用户通常在桌面上保留的文件再次重启进入后发现文件丢失了&#xff0c;或者原有桌面上的文件不见了&#xff0c;这样一定程度上降低了工作的效率.这里主要说一下如何解决此问题。用户登…

chosen.jquery.js 有搜索功能、多选功能的下拉框插件

chosen.jquery.js 有搜索功能、多选功能的下拉框插件 官方源码&#xff1a; https://github.com/harvesthq/chosen 该源码中的样例index.html有该插件的详细使用介绍posted on 2019-05-09 14:40 三天打鱼&#xff0c;两天晒网 阅读(...) 评论(...) 编辑 收藏 转载于:https://w…

MIB in SNMP

管理信息库MIB指明了网络元素所维持的变量&#xff08;即能够被管理进程查询和设置的信息&#xff09;。MIB给出了一个网络中所有可能的被管理对象的集合的数据结构。SNMP的管理信息库采用和域名系统DNS相似的树型结构&#xff0c;它的根在最上面&#xff0c;根没有名字。图3画…

Java项目:后台管理系统脚手架项目(java+SpringBoot+FreeMarker+mysql+JSP)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 项目描述&#xff1a; 这是一个基于SpringBoot框架开发的后台管理系统脚手架项目。之所以称为脚手架项目&#xff0c;是因为这个项目复用性很强&#xff0c;如果以后有其他新的项目要设计后台管理系统的话&…

Extjs4.0.7 MVC Architecture异常

uncaught exception: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: AM.controller.User 解决方法&#xff1a; 在app.js最上面加上&#xff1a;Ext.Loader.setConfig({ enabled: true }); Ext.Loader.setConfig({ …

Mybatis常见面试题(三)

Mybatis 映射文件中&#xff0c;如果 A 标签通过 include 引用了 B 标签的内容&#xff0c;请问&#xff0c; B 标签能否定义在 A 标签的后面&#xff0c;还是说必须定义在 A 标签的前面&#xff1f; :虽然 Mybatis 解析 Xml 映射文件是按照顺序解析的&#xff0c;但是&#x…

SMI in SNMP

SNMP中&#xff0c;数据类型并不多。这里我们就讨论这些数据类型&#xff0c;而不关心这些数据类型在实际中是如何编码的。INTEGER一个变量虽然定义为整型&#xff0c;但也有多种形式。有些整型变量没有范围限制&#xff0c;有些整型变量定义为特定的数值&#xff08;例如&am…

Java项目:在线拍卖竞价系统(java+SpringBoot+FreeMarker+Mysql+redis)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 超级管理员&#xff1a;系统管理、用户管理&#xff08;冻结等&#xff09;、审批竞拍标的物管理、竞标类型管理、审批机构、个人提现管理&#xff08;审核&#xff09;、企业提现管理&#xff08;审批&…

pig脚本不需要后缀名(python tempfile模块生成pig脚本临时文件,执行)

pig 脚本运行不需要后缀名 pig脚本名为tempfile&#xff0c;无后缀名 用pig -f tempfile 可直接运行 另外&#xff0c;pig tempfile也可以直接运行这样就可以用python临时文件存储pig脚本内容直接调用 python调用pig脚本的一种方式 将pig脚本用任意文件存储&#xff0c;执行时写…

老谢oracle视频笔记_day02

1:databasea:physical structure1:controlfile控制文件select * from v$controlfile;11g 以三个11g二个互为镜像文件坏了数据库就打不开了..IO一个块 16k一个文件2MB不会太大?10MB数据库名数据文件位置很多的参数.....2:datafile 数据文件select file_name,file_id from dba_d…

WCDMA系统中的扰码规划

摘要&#xff1a;宽带码分多址(WCDMA)系统采用码分多址的无线接入方式&#xff0c;不需频率规划&#xff0c;但需进行相邻小区扰码的规划用以区分各小区。通过WCDMA无线网络的扰码规划&#xff0c;可以确定两个使用相同扰码的小区的复用距离&#xff0c;区分各小区。扰码规划时…

Java项目:宿舍寝室维修上报管理系统(java+SpringBoot+FreeMarker+Mysql)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 管理员&#xff1a;校园管理&#xff08;楼栋管理、宿舍管理&#xff09;、师生管理&#xff08;学生管理、辅导员管理&#xff09;、维修管理&#xff08;维修工管理、维修进度管理&#xff09;、阅览室管理…

项目需求分析与建议

软件名称&#xff1a;私人助手 1.N(需求)&#xff1a;当今生活节奏迅速&#xff0c;每个人每天都有许多事情要做&#xff0c;堆积成山的事情往往让人感到迷茫&#xff0c;不知道什么时候要做什么事情。私人助手就是为了解决这个烦恼而产生&#xff0c;它会根据最初你添加的事物…

使用面向 iOS 的本机插件扩展 PhoneGap

本文细致探讨了 Xcode&#xff08;以 iOS 设备为目标&#xff09;中的 PhoneGap&#xff08;也称为 Apache Cordova&#xff09;应用程序本机插件。如果您刚开始接触 PhoneGap 或者需要回顾 PhoneGap 基础知识&#xff0c;请先阅读 Xcode for iOS 的 PhoneGap 入门&#xff0c;…

算法总结---最常用的五大算法(算法题思路)

算法总结---最常用的五大算法&#xff08;算法题思路&#xff09; 一、总结 一句话总结&#xff1a; 【明确所求&#xff1a;dijkstra是求点到点的距离&#xff0c;辅助数组就是源点到目标点的数组】 【最简实例分析&#xff1a;比如思考dijkstra&#xff1a;假设先只有三个点】…

软切换中的测量

软切换中的测量 同频测量&#xff1a; CPICH RSCP、Ec/N0, 事件触发报告&#xff0c;1A,...,1F 1A&#xff0c;相对门限增加事件&#xff0c;表示一个小区的质量已经接近最好小区或者活动集质量 1B&#xff0c;相对门限删除事件&#xff0c;表示一个小区…

测试与封装5.1.5.2

1.第一阶段目标 - 把计算的功能封装成类。2.设计测试用例&#xff1a;用白盒与黑盒测试设计技术&#xff0c;为计算核心设计测试用例。3.在实验环境中&#xff08;如MyEclipse集成开发环境Junit测试框架&#xff09;运行测试用例&#xff0c;分析测试结果&#xff0c;找出程序问…

Java项目:企业员工绩效工资管理系统(java+SpringBoot+FreeMarker+Mysql)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 超级管理员等角色&#xff0c;除基础脚手架外&#xff0c;实现的功能有&#xff1a; 超级管理员&#xff1a;系统管理、用户管理&#xff08;冻结等&#xff09;、职称管理、部门管理&#xff08;工资项&am…

Sql server 阻塞定位

很多人都遇到过这样的情况&#xff0c;当网站达到一定的访问量&#xff0c;数据库就会成为瓶颈&#xff0c;进而引起阻塞。有人认为这可能就是硬件的极限了&#xff0c;于是想办法增加硬件设备。而我本人认为问题的元凶可能是性能不高的sql脚本&#xff0c;引起了阻塞。如果你和…

基于EasyNVR摄像机网页无插件直播服务二次开发实现H5播放页面的简单集成方案...

我们通常在构架一套视频SaaS应用的过程中&#xff0c;将平台设计为3层&#xff1a;视频硬件层&#xff08;视频源&#xff09;、视频能力平台&#xff08;vPaaS&#xff09;、视频应用平台&#xff08;vSaaS&#xff09;&#xff0c;视频硬件包括各种IPC、NVR、编码器等视频生成…

active set + serving cell

空闲态&#xff1a;这时候手机只能使用一路信号&#xff0c;应该是最强的那一路。手机在空闲态时不断地搜索各个导频的强度&#xff0c;如果搜到比当前使用的导频更强的&#xff0c;那么它就自发的进行切换。这个切换的过程是手机自发的过程&#xff0c;不需要基站的参与。业务…

Java项目:医院分诊挂号住院管理系统(java+SpringBoot+FreeMarker+Mysql)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 主要实现了从挂号预约到分诊住院出诊等一些列医院基本操作流程的全部功能&#xff0c;系统分医生、患者、管理员三个角色&#xff0c;除基础脚手架外&#xff0c;实现的功能有&#xff1a; 管理员&#xff…

网站压力测试工具webbench

webbench最多可以模拟3万个并发连接去测试网站的负载能力&#xff0c;个人感觉要比Apache自带的ab压力测试工具好&#xff0c;安装使用也特别方便。  1、适用系统&#xff1a;Linux  2、编译安装&#xff1a; 引用wget http://blog.zyan.cc/soft/linux/webbench/webbench-1…

运维人员处理云服务器故障的方法总结

2019独角兽企业重金招聘Python工程师标准>>> 我们团队为Ucloud云计算服务提供专家技术支持,每天都要碰到无数的用户故障,毕竟IAAS涉及比较底层的东西,不管设计的是大客户也好还是小客户,有了问题就必须要解决,也要要是再赶上修复时间紧、奇葩的技术平台、缺少信息和…

玉米田Corn Fields

传送门 #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #define ll long long #define re register const int mod1e8; void read(int &a) {a0;int d1;char ch;while(chgetchar(),ch>9||ch…

Java项目:酒店管理系统(java+Springboot+Mybatis+Beetl+Layui)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 此系统用的是springboot框架&#xff0c;前端框架主要用的是layui&#xff0c;表格用的bootstrap 表格&#xff0c;都是一些主流的框架&#xff0c;前端模板引擎用的是beetl&#xff0c;操作简单&#xff0c…

word导入中的一个乱码

2019独角兽企业重金招聘Python工程师标准>>> 在做一个题库的项目中,需要将word中的试题导入到数据库中,中间过程真是坎坷,且不说word中的公式,图片等等格式,还有凌乱的排版,还有一些不明觉厉的乱码; 由于PHP暂时不能胜任,所以使用了C#开发了一个客户端来导入,时间很…

Eclipse中git检出、更新、提交、合并分支、以及解决冲突

一、、检出git代码 在eclipse中空白区域右键 Import 检出项目&#xff1b;选择git方式检出 选择用git urI 链接的方式检出项目并点击继续 在这里填写你的git项目地址、账号密码 二、更新 1、先更新 "远程服务器 --> 本地服务器"&#xff0c;再进行 更新 " 本…

Cell select

WCDMA系统的小区重选采用R准则&#xff0c;适用于同频、异频和异系统的小区重选。UE在空闲模式下&#xff0c;要随时监测当前小区和邻区的信号质量&#xff0c;以选择一个最好的小区提供服务&#xff0c;这就是小区重选过程&#xff08;cell reselection&#xff09;。而切换是…