Eclipse+Java+SSM+Easyui实现网上考试系统

简介: Eclipse+Java+SSM+Easyui实现网上考试系统

一、系统介绍


软件环境

IDEA:2018.2

Java:jdk1.8

Mysql:8.0.13

Tomcat:8.5.23


系统功能

1.考生:注册与登录,考试,查询成绩,修改个人资料。

2.超级管理员:管理管理员信息,考生信息管理,套题信息管理,考试题目管理。

3.一般管理员:考生信息管理,套题信息管理,考试题目管理。


数据库涉及的表

lesson

manager

questions

student

studentresult

taoti


二、系统展示


1.考生-注册登录


20210401224637753.jpg


2.考生-主页面


20210401224653657.jpg


3.考生-选择课程


20210401224708975.jpg

4.考生-考试界面


20210401224725132.jpg


5.考生-自动判卷

20210401224740397.jpg

6.考生-查询成绩


20210401224756359.jpg


7.考生-修改信息


20210401224915361.jpg

8.管理员-登录


2021040122492954.jpg


9.管理员-管理员信息管理


20210401224942366.jpg


10.管理员-考生信息管理


20210401224958214.jpg


11.管理员-考生成绩管理


20210401225011919.jpg


12.管理员-课程信息管理


20210401225027564.jpg


13.管理员-套题信息管理


20210401225041751.jpg


14.管理员-考试题目管理


20210401225056325.jpg


三、代码实现


ExamController.java

package controller;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpSession;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import po.Exam;
import po.Questions;
import po.QuestionsCustom;
import po.Student;
import po.Studentresult;
import po.StudentresultCustom;
import po.Taoti;
import service.QuestionsService;
import service.ResultService;
import service.StudentService;
import service.TaotiService;
@Controller
public class ExamController {
  @Autowired
  private TaotiService taotiService;
  @Autowired
  private QuestionsService questionsService;
  @Autowired
  private StudentService studentService;
  @Autowired
  private ResultService resultService;
  @RequestMapping("/toExam.action")
  public String toExam() throws Exception{
    return "/exam";
  }
  @RequestMapping("/toExamPage.action")
  public ModelAndView toExamPage(Integer lessonid) throws Exception{
    ModelAndView modelAndView=new ModelAndView();
    List<Taoti> list = taotiService.findListByLessonid(lessonid);
    if (list.size()>0) {
      Integer length=list.size();
      Integer index=(int) (Math.random()*(length-1));
      Taoti taoti=list.get(index);
      List<QuestionsCustom> list2 = questionsService.findListByTaotiid(taoti.getId());
      modelAndView.addObject("list", list2);
    }else {
      modelAndView.addObject("list", null);
    }
    modelAndView.setViewName("/examPage");
    return modelAndView;
  }
  @RequestMapping("/postExam.action")
  public ModelAndView postExam(Exam exam,HttpSession session) throws Exception{
    ModelAndView modelAndView=new ModelAndView();
    Studentresult studentresult=new Studentresult();
    Map<Integer, String> map = exam.getAnswerMap();
    Set<Integer> keySet=map.keySet();
    Iterator<Integer> it=keySet.iterator();
    Integer singleGrade=0;
    Integer doubleGrade=0;
    Integer taotiId=null;
    while(it.hasNext()) {
      Integer key=it.next();
      String value=map.get(key);
      Questions questions = questionsService.findById(key);
      if(taotiId == null) {
        taotiId=questions.getTaotiid();
      }
      if(questions.getType().equals("单选")) {
        if(questions.getAnswer().equals(value)) {
          singleGrade+=10;
        }
      }else {
        if(questions.getAnswer().equals(value)) {
          doubleGrade+=20;
        }
      }
    }
    Integer totalGrade=singleGrade+doubleGrade;
    Taoti taoti = taotiService.fintOneById(taotiId);
    String examnumber="CN";
    SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyyMMdd");
    Date date=new Date();
    String strD = simpleDateFormat.format(date);
    Object studentName = session.getAttribute("studentName");
    String studentId=null;
    if(studentName!=null) {
      String studentName2=studentName.toString();
      Student student = studentService.findOne(studentName2);
      studentId=student.getId().toString();
    }
    examnumber=examnumber+strD+studentId;
    studentresult.setExamnumber(examnumber);
    studentresult.setLessonid(taoti.getLessonid());
    studentresult.setResingle(singleGrade);
    studentresult.setResmore(doubleGrade);
    studentresult.setRestotal(totalGrade);
    studentresult.setCreatetime(new Timestamp(new Date().getTime()));
    if(session.getAttribute("xiaowutoken")!=null) {
      resultService.addOne(studentresult);
      session.removeAttribute("xiaowutoken");
    }
    List<QuestionsCustom> questionsCustoms = questionsService.findListByTaotiid(taotiId);
    StudentresultCustom studentresultCustom=new StudentresultCustom();
    BeanUtils.copyProperties(studentresult, studentresultCustom);
    studentresultCustom.setLessonname(questionsCustoms.get(0).getLessonName());
    modelAndView.setViewName("/examResult");
    modelAndView.addObject("studentresult", studentresultCustom);
    return modelAndView;
  }
}

CustomException.java

package exception;
public class CustomException extends Exception {
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  private String message;
  public CustomException(String message) {
    super(message);
    this.message=message;
  }
  public String getMessage() {
    return message;
  }
  public void setMessage(String message) {
    this.message = message;
  } 
}

LessonServiceImpl.java

package serviceImpl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import mapper.LessonMapper;
import mapper.LessonMapperCustom;
import po.Lesson;
import po.LessonExample;
import po.Pagination;
import service.LessonService;
public class LessonServiceImpl implements LessonService {
  @Autowired
  private LessonMapper lessonMapper;
  @Autowired
  private LessonMapperCustom lessonMapperCustom;
  public List<Lesson> getListByLimit(Pagination pagination) throws Exception {
    pagination.setStartPage((pagination.getPage()-1)*pagination.getRows());
    return lessonMapperCustom.getListByLimit(pagination);
  }
  public List<Lesson> getList() throws Exception {
    LessonExample example=new LessonExample();
    return lessonMapper.selectByExample(example);
  }
  @Transactional
  public void deleteOneById(Integer id) {
    lessonMapper.deleteByPrimaryKey(id);
  }
  @Transactional
  public void addOne(Lesson lesson) {
    lessonMapper.insertSelective(lesson);
  }
}

QueryResultVo.java

package vo;
import po.Pagination;
import po.QueryResult;
import po.StudentresultCustom;
public class QueryResultVo {
  private Pagination pagination;
  private QueryResult queryResult;
  public Pagination getPagination() {
    return pagination;
  }
  public void setPagination(Pagination pagination) {
    this.pagination = pagination;
  }
  public QueryResult getQueryResult() {
    return queryResult;
  }
  public void setQueryResult(QueryResult queryResult) {
    this.queryResult = queryResult;
  }
}

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${pageContext.request.contextPath }/image/main_logo.ico" rel="shortcut icon">
<title>在线考试系统-首页</title>
<link rel="stylesheet" type="text/css"
  href="${pageContext.request.contextPath }/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
  href="${pageContext.request.contextPath }/easyui/themes/icon.css">
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/jquery.min.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
  $(function(){
    var spanText = $("#sp").text();
    if(spanText==""){
      $("#ft").hide();
    }
  })
</script>
</head>
<body style="background-image:url('${pageContext.request.contextPath}/image/indexback.jpg');background-size:cover">
<div style="margin-top:2%">
  <font color="#01814A" size="12px" face="仿宋" style="font-weight:bold;margin-left:34%">营 养 在 线 考 试 网</font>
  <br>
  <br>
  <font id="ft" style="margin-left:35%">当 前 学 生:<span id="sp">${sessionScope.studentName }</span></font>
</div>
<div style="margin-top:5%;margin-left:30%">
  <table cellpadding="30px">
    <tr>
      <td>
        <a href="${pageContext.request.contextPath }/toExam.action" class="easyui-linkbutton" data-options="iconCls:'icon-edit',size:'large'"><font size="4px">在线考试</font></a>
      </td>
      <td>
        <a href="${pageContext.request.contextPath }/queryResult.action" class="easyui-linkbutton" data-options="iconCls:'icon-search',size:'large'"><font size="4px">成绩查询</font></a>
      </td>
    </tr>
    <tr>
      <td>
        <a href="${pageContext.request.contextPath }/toEdit.action" class="easyui-linkbutton" data-options="iconCls:'icon-reload',size:'large'"><font size="4px">修改资料</font></a>
      </td>
      <td>
        <a href="${pageContext.request.contextPath }/logout.action" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',size:'large'"><font size="4px">退出系统</font></a>
      </td>
    </tr>
  </table>
</div>
<center style="margin-top:5%">
  <font>CopyRight ©: 水坚石青 版权所有</font>
</center>
</body>
</html>

managerIndex.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${pageContext.request.contextPath }/image/main_logo.ico" rel="shortcut icon">
<title>在线考试系统-后台管理</title>
<link rel="stylesheet" type="text/css"
  href="${pageContext.request.contextPath }/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
  href="${pageContext.request.contextPath }/easyui/themes/icon.css">
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/jquery.min.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
  function openTab(title,url,icon){
    var managerName="${sessionScope.managerName}";
    if (managerName=="") {
      window.location.href="${pageContext.request.contextPath }/managerLogout.action";
      return;
    }
    if ($("#tabs").tabs("exists",title)) {
      $("#tabs").tabs("select",title);
    }else{
      var content="<iframe frameborder='0' scolling='auto' width='100%' height='100%' src='${pageContext.request.contextPath}/jsp/"+url+"'></iframe>";
      $("#tabs").tabs("add",{
        title:title,
        iconCls:icon,
        closable:true,
        content:content
      })
    }
  }
</script>
</head>
<body class="easyui-layout">
<input id="managerAuthority" type="hidden" value="${sessionScope.managerAuthority }">
  <div data-options="region:'north'" style="height:60px">
    <div style="line-height:60px;height:58px;background-image:url('${pageContext.request.contextPath}/image/signinback.jpg');background-size:cover">
      <font color="white" size="8px" face="仿宋" style="font-weight:bold;margin-left:2%">营 养 在 线 考 试 网<font size="5px" color="black"> -- 后 台 管 理 </font></font>
      <font id="ft" style="margin-left:20%">当 前 管 理 员:<span id="sp">${sessionScope.managerName }</span></font>
    </div>
  </div>
  <div data-options="region:'south'" style="height:40px">
    <center style="margin-top:1%">
      <font>CopyRight © : 2021 水坚石青 版权所有</font>
    </center>
  </div>
  <div data-options="region:'west',title:'后台导航栏',split:true" style="width:200px">
    <div class="easyui-accordion" data-options="fit:true">
      <c:if test="${sessionScope.managerAuthority=='super' }">
        <div title="管理员管理" style="padding: 10px" data-options="iconCls:'icon-man'" align="center">
          <a href="javascript:openTab('管理员信息管理','managerList.jsp','icon-man')"  class="easyui-linkbutton" data-options="iconCls:'icon-man',plain:true" style="width:150px">管理员信息管理</a>
        </div>
      </c:if>
      <div title="考生管理" style="padding: 10px" data-options="iconCls:'icon-group'" align="center">
        <a href="javascript:openTab('考生信息管理','managerStudentList.jsp','icon-group')" class="easyui-linkbutton" data-options="iconCls:'icon-group',plain:true" style="width:150px">考生信息管理</a>
        <a href="javascript:openTab('考生成绩管理','managerQueryResult.jsp','icon-definition')" class="easyui-linkbutton" data-options="iconCls:'icon-definition',plain:true" style="width:150px">考生成绩管理</a>
      </div>
      <div title="试题管理" style="padding:10px" data-options="iconCls:'icon-ask'" align="center">
        <a href="javascript:openTab('课程信息管理','managerLessonList.jsp','icon-ask')" class="easyui-linkbutton" data-options="iconCls:'icon-ask',plain:true" style="width:150px">课程信息管理</a>
        <a href="javascript:openTab('套题信息管理','managerTaotiList.jsp','icon-deployment')" class="easyui-linkbutton" data-options="iconCls:'icon-deployment',plain:true" style="width:150px">套题信息管理</a>
        <a href="javascript:openTab('考试题目管理','managerQuestionsList.jsp','icon-flow')" class="easyui-linkbutton" data-options="iconCls:'icon-flow',plain:true" style="width:150px">考试题目管理</a>
      </div>
      <div title="系统管理" style="padding: 10px" align="center">
        <a href="${pageContext.request.contextPath }/managerLogout.action" class="easyui-linkbutton" data-options="iconCls:'icon-signout',plain:true" style="width:150px">退出后台管理</a>
      </div>
    </div>
  </div>
  <div data-options="region:'center'" style="padding:1px;background:#eee">
    <div id="tabs" class="easyui-tabs" data-options="fit:true,border:false">
      <div title="首页">
        <div align="center" style="margin-top: 15%">
          <font size="6" style="font-weight: bold">欢  迎  使  用  !</font>
        </div>
      </div>
    </div>
  </div>
</body>
</html>


四、其他


1.其他系统实现


Java+JSP实现图书管理系统

Java+Servlet+JSP实现学生成绩管理系统

Java+Servlet+JSP实现宠物诊所管理系统



目录
打赏
0
0
0
0
30
分享
相关文章
接替此文【下篇-服务端+后台管理】优雅草蜻蜓z系统JAVA版暗影版为例-【蜻蜓z系列通用】-2025年全新项目整合搭建方式-这是独立吃透代码以后首次改变-独立PC版本vue版搭建教程-优雅草卓伊凡
接替此文【下篇-服务端+后台管理】优雅草蜻蜓z系统JAVA版暗影版为例-【蜻蜓z系列通用】-2025年全新项目整合搭建方式-这是独立吃透代码以后首次改变-独立PC版本vue版搭建教程-优雅草卓伊凡
154 96
接替此文【下篇-服务端+后台管理】优雅草蜻蜓z系统JAVA版暗影版为例-【蜻蜓z系列通用】-2025年全新项目整合搭建方式-这是独立吃透代码以后首次改变-独立PC版本vue版搭建教程-优雅草卓伊凡
ssm026校园美食交流系统(文档+源码)_kaic
本文介绍了基于Java语言和MySQL数据库的校园美食交流系统的设计与实现。该系统采用B/S架构和SSM框架,旨在提高校园美食信息管理的效率与便捷性。主要内容包括:系统的开发背景、目的及内容;对Java技术、MySQL数据库、B/S结构和SSM框架的介绍;系统分析部分涵盖可行性分析、性能分析和功能需求分析;最后详细描述了系统各功能模块的具体实现,如登录、管理员功能(美食分类管理、用户管理等)和前台首页功能。通过此系统,管理员可以高效管理美食信息,用户也能方便地获取和分享美食资讯,从而提升校园美食交流的管理水平和用户体验。
【03】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架搭建-服务端-后台管理-整体搭建-优雅草卓伊凡商业项目实战
【03】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架搭建-服务端-后台管理-整体搭建-优雅草卓伊凡商业项目实战
60 13
【03】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架搭建-服务端-后台管理-整体搭建-优雅草卓伊凡商业项目实战
【02】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-ui设计图figmaUI设计准备-figma汉化插件-mysql数据库设计-优雅草卓伊凡商业项目实战
【02】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-ui设计图figmaUI设计准备-figma汉化插件-mysql数据库设计-优雅草卓伊凡商业项目实战
59 14
【02】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-ui设计图figmaUI设计准备-figma汉化插件-mysql数据库设计-优雅草卓伊凡商业项目实战
【04】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架二次开发准备工作-以及建立初步后端目录菜单列-优雅草卓伊凡商业项目实战
【04】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架二次开发准备工作-以及建立初步后端目录菜单列-优雅草卓伊凡商业项目实战
48 11
【04】Java+若依+vue.js技术栈实现钱包积分管理系统项目-若依框架二次开发准备工作-以及建立初步后端目录菜单列-优雅草卓伊凡商业项目实战
【01】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-需求改为思维导图-设计数据库-确定基础架构和设计-优雅草卓伊凡商业项目实战
【01】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-需求改为思维导图-设计数据库-确定基础架构和设计-优雅草卓伊凡商业项目实战
58 13
【01】Java+若依+vue.js技术栈实现钱包积分管理系统项目-商业级电玩城积分系统商业项目实战-需求改为思维导图-设计数据库-确定基础架构和设计-优雅草卓伊凡商业项目实战
如何使用Java语言快速开发一套智慧工地系统
使用Java开发智慧工地系统,采用Spring Cloud微服务架构和前后端分离设计,结合MySQL、MongoDB数据库及RESTful API,集成人脸识别、视频监控、设备与环境监测等功能模块,运用Spark/Flink处理大数据,ECharts/AntV G2实现数据可视化,确保系统安全与性能,采用敏捷开发模式,提供详尽文档与用户培训,支持云部署与容器化管理,快速构建高效、灵活的智慧工地解决方案。
java语言后台管理若依框架-登录提示404-接口异常-系统接口404异常如何处理-登录验证码不显示prod-api/captchaImage 404 (Not Found) 如何处理-解决方案优雅草卓伊凡
java语言后台管理若依框架-登录提示404-接口异常-系统接口404异常如何处理-登录验证码不显示prod-api/captchaImage 404 (Not Found) 如何处理-解决方案优雅草卓伊凡
36 5
基于Java+SpringBoot+Vue实现的车辆充电桩系统设计与实现(系统源码+文档+部署讲解等)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
59 6
基于Java的Hadoop文件处理系统:高效分布式数据解析与存储
本文介绍了如何借鉴Hadoop的设计思想,使用Java实现其核心功能MapReduce,解决海量数据处理问题。通过类比图书馆管理系统,详细解释了Hadoop的两大组件:HDFS(分布式文件系统)和MapReduce(分布式计算模型)。具体实现了单词统计任务,并扩展支持CSV和JSON格式的数据解析。为了提升性能,引入了Combiner减少中间数据传输,以及自定义Partitioner解决数据倾斜问题。最后总结了Hadoop在大数据处理中的重要性,鼓励Java开发者学习Hadoop以拓展技术边界。
50 7

推荐镜像

更多
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等