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实现宠物诊所管理系统



相关文章
|
Java 数据库连接 Maven
手把手教你如何搭建SSM框架、图书商城系统案例
这篇文章是关于如何搭建SSM框架以及实现一个图书商城系统的详细教程,包括了项目的配置文件整合、依赖管理、项目结构和运行效果展示,并提供了GitHub源码链接。
手把手教你如何搭建SSM框架、图书商城系统案例
|
存储 Java 关系型数据库
ssm026校园美食交流系统(文档+源码)_kaic
本文介绍了基于Java语言和MySQL数据库的校园美食交流系统的设计与实现。该系统采用B/S架构和SSM框架,旨在提高校园美食信息管理的效率与便捷性。主要内容包括:系统的开发背景、目的及内容;对Java技术、MySQL数据库、B/S结构和SSM框架的介绍;系统分析部分涵盖可行性分析、性能分析和功能需求分析;最后详细描述了系统各功能模块的具体实现,如登录、管理员功能(美食分类管理、用户管理等)和前台首页功能。通过此系统,管理员可以高效管理美食信息,用户也能方便地获取和分享美食资讯,从而提升校园美食交流的管理水平和用户体验。
|
Java 关系型数据库 MySQL
weixin050高校体育场管理系统+ssm(文档+源码)_kaic
本文针对高校体育场管理系统的开发与实现进行详细介绍。随着经济快速发展,人们对手机软件需求增加,高校体育场管理系统应运而生。系统采用JAVA技术、Mysql数据库和SSM框架等成熟技术,通过分析功能需求、可行性及性能,设计出包含管理员、用户和学生角色的功能模块。系统实现用户注册登录、信息管理等功能,简化传统手工统计模式,提高管理效率,满足用户对信息获取的及时性与准确性需求。
weixin050高校体育场管理系统+ssm(文档+源码)_kaic
|
前端开发 Java 关系型数据库
基于ssm的社区物业管理系统,附源码+数据库+论文+任务书
社区物业管理系统采用B/S架构,基于Java语言开发,使用MySQL数据库。系统涵盖个人中心、用户管理、楼盘管理、收费管理、停车登记、报修与投诉管理等功能模块,方便管理员及用户操作。前端采用Vue、HTML、JavaScript等技术,后端使用SSM框架。系统支持远程安装调试,确保顺利运行。提供演示视频和详细文档截图,帮助用户快速上手。
579 17
|
前端开发 Java 关系型数据库
基于ssm的超市会员(积分)管理系统,附源码+数据库+论文,包安装调试
本项目为简单内容浏览和信息处理系统,具备管理员和员工权限。管理员可管理会员、员工、商品及积分记录,员工则负责积分、商品信息和兑换管理。技术框架采用Java编程语言,B/S架构,前端使用Vue+JSP+JavaScript+Css+LayUI,后端为SSM框架,数据库为MySQL。运行环境为Windows,JDK8+Tomcat8.5,非前后端分离的Maven项目。提供演示视频和详细文档,购买后支持免费远程安装调试。
721 19
|
前端开发 JavaScript Java
[Java计算机毕设]基于ssm的OA办公管理系统的设计与实现,附源码+数据库+论文+开题,包安装调试
OA办公管理系统是一款基于Java和SSM框架开发的B/S架构应用,适用于Windows系统。项目包含管理员、项目管理人员和普通用户三种角色,分别负责系统管理、请假审批、图书借阅等日常办公事务。系统使用Vue、HTML、JavaScript、CSS和LayUI构建前端,后端采用SSM框架,数据库为MySQL,共24张表。提供完整演示视频和详细文档截图,支持远程安装调试,确保顺利运行。
536 17
|
前端开发 Java 关系型数据库
基于ssm的网络直播带货管理系统,附源码+数据库+论文
该项目为网络直播带货网站,包含管理员和用户两个角色。管理员可进行主页、个人中心、用户管理、商品分类与信息管理、系统及订单管理;用户可浏览主页、管理个人中心、收藏和订单。系统基于Java开发,采用B/S架构,前端使用Vue、JSP等技术,后端为SSM框架,数据库为MySQL。项目运行环境为Windows,支持JDK8、Tomcat8.5。提供演示视频和详细文档截图。
405 10
|
前端开发 Java 关系型数据库
基于ssm的台球厅管理系统,附源码+数据库+论文
本项目为新锐台球厅管理系统,支持管理员和会员两种角色。管理员可进行会员管理、台球桌管理、订单管理等;会员可查看台球桌、预约、购买商品等。技术框架基于Java,采用B/S架构,前端使用Vue+HTML+JavaScript+CSS+LayUI,后端使用SSM框架,数据库为MySQL。运行环境为Windows,JDK8+MySQL5.7+Tomcat8.5。提供演示视频及详细文档截图。
|
存储 Java 关系型数据库
ssm064农产品仓库管理系统系统(文档+源码)_kaic
农产品仓库管理系统基于现代经济快速发展和信息化技术的升级,采用SSM框架、Java语言及Mysql数据库开发。系统旨在帮助管理者高效处理大量数据信息,提升事务处理效率,实现数据管理的科学化与规范化。该系统涵盖物资基础数据管理、出入库订单管理等功能,界面简洁美观,符合用户操作习惯,并提供数据安全解决方案,确保信息的安全性和可靠性。通过自动化和集中处理,系统显著提高了仓库管理的效率和准确性。
|
设计模式 Java 关系型数据库
【Java笔记+踩坑汇总】Java基础+JavaWeb+SSM+SpringBoot+SpringCloud+瑞吉外卖/谷粒商城/学成在线+设计模式+面试题汇总+性能调优/架构设计+源码解析
本文是“Java学习路线”专栏的导航文章,目标是为Java初学者和初中高级工程师提供一套完整的Java学习路线。
1102 37

推荐镜像

更多