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



相关文章
|
1天前
|
JavaScript Java 测试技术
基于Java的网上书城的设计与实现(源码+lw+部署文档+讲解等)
基于Java的网上书城的设计与实现(源码+lw+部署文档+讲解等)
9 0
|
5天前
|
JavaScript Java 测试技术
基于Java的网上茶叶销售平台的设计与实现(源码+lw+部署文档+讲解等)
基于Java的网上茶叶销售平台的设计与实现(源码+lw+部署文档+讲解等)
16 0
|
6天前
|
JavaScript Java 测试技术
基于Java的智能交互式在线网上花店的设计与实现(源码+lw+部署文档+讲解等)
基于Java的智能交互式在线网上花店的设计与实现(源码+lw+部署文档+讲解等)
19 3
|
1月前
|
Java 数据库连接 数据库
JAVA Web项目开发SSM框架搭建(第一天)
JAVA Web项目开发SSM框架搭建(第一天)
|
1月前
|
Java 关系型数据库 应用服务中间件
JAVA Web项目开发eclipse工具包配置(第一天)
JAVA Web项目开发eclipse工具包配置(第一天)
|
1月前
|
存储 安全 前端开发
ssm656基于JAVA的校园失物招领平台的设计与实现
ssm656基于JAVA的校园失物招领平台的设计与实现
|
1月前
|
存储 安全 前端开发
509基于java的网上手机销售系统
509基于java的网上手机销售系统
|
2月前
|
Java 数据安全/隐私保护
6-4 字符串加密(Java解法,两种网上的类型题)
6-4 字符串加密(Java解法,两种网上的类型题)
23 0
|
3月前
|
XML Java Android开发
Java学习—Eclipse/Idea如何设置自动提示
Java学习—Eclipse/Idea如何设置自动提示
|
3月前
|
人工智能 前端开发 JavaScript
计算机Java项目|基于SSM的课程智能组卷系统(二)
计算机Java项目|基于SSM的课程智能组卷系统
计算机Java项目|基于SSM的课程智能组卷系统(二)

推荐镜像

更多