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

网上考试系统

  • 一、系统介绍
  • 二、系统展示
    • 1.考生-注册登录
    • 2.考生-主页面
    • 3.考生-选择课程
    • 4.考生-考试界面
    • 5.考生-自动判卷
    • 6.考生-查询成绩
    • 7.考生-修改信息
    • 8.管理员-登录
    • 9.管理员-管理员信息管理
    • 10.管理员-考生信息管理
    • 11.管理员-考生成绩管理
    • 12.管理员-课程信息管理
    • 13.管理员-套题信息管理
    • 14.管理员-考试题目管理
  • 三、代码实现
    • ExamController.java
    • CustomException.java
    • LessonServiceImpl.java
    • QueryResultVo.java
    • index.jsp
    • managerIndex.jsp
  • 四、其他
    • 1.其他系统实现
    • 2.获取源码
    • 3.备注

一、系统介绍

软件环境
IDEA:2018.2
Java:jdk1.8
Mysql:8.0.13
Tomcat:8.5.23

系统功能
1.考生:注册与登录,考试,查询成绩,修改个人资料。
2.超级管理员:管理管理员信息,考生信息管理,套题信息管理,考试题目管理。
3.一般管理员:考生信息管理,套题信息管理,考试题目管理。

数据库涉及的表
lesson
manager
questions
student
studentresult
taoti

二、系统展示

1.考生-注册登录

Eclipse+Java+SSM+Easyui实现网上考试系统_第1张图片

2.考生-主页面

Eclipse+Java+SSM+Easyui实现网上考试系统_第2张图片

3.考生-选择课程

Eclipse+Java+SSM+Easyui实现网上考试系统_第3张图片

4.考生-考试界面

Eclipse+Java+SSM+Easyui实现网上考试系统_第4张图片

5.考生-自动判卷

Eclipse+Java+SSM+Easyui实现网上考试系统_第5张图片

6.考生-查询成绩

Eclipse+Java+SSM+Easyui实现网上考试系统_第6张图片

7.考生-修改信息

Eclipse+Java+SSM+Easyui实现网上考试系统_第7张图片

8.管理员-登录

Eclipse+Java+SSM+Easyui实现网上考试系统_第8张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第9张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第10张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第11张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第12张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第13张图片

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

Eclipse+Java+SSM+Easyui实现网上考试系统_第14张图片

三、代码实现

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="";
			$("#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实现宠物诊所管理系统

2.获取源码

请联系QQ:3079118617

3.备注

如有侵权请联系我删除。

你可能感兴趣的:(Web,java,web,easyui)