兜兜零元 发表于 2023-5-6 15:00:47

27基于java的学生在线考试系统

一、项目简介

随着互联网迅速发展,人们的生活已经越来越离不开互联网,人们足不出户就可以工作、学习等。对于在校学生,通过网络教育不仅可以随时进行网络学习,也可以根据学习的情况自我检测,有利于学生高效、快捷地掌握所学的知识。
本系统预设计的基于网络的学生自测系统将实现多种用户(包括学生、教师、管理员)同时访问,学生登录后可以针对课程的每一章节的每一道题目,提交答案;系统会自动按照学生的答案来判断对错,并自动给出成绩。另外,系统还具有添加用户、管理题库、添加试卷、添加习题、修改密码等功能。
简单的一句话,这是一个完整的学生在线考试系统,导入项目和数据库就可以使用;在本考试系统中,管理员、老师、学生三个角色是相当于是三个系统。
二、开发工具和环境

前端:html, css, js, vue等;
后端:java, spring,maven等
数据库:mysql
开发工具: eclipse或idea
更多内容可查看:项目帮
部分核心代码

import org.springframework.stereotype.Service;
import xyz.shiguangliang.mybatis.dao.UserMapper;

import xyz.shiguangliang.mybatis.domain.User;
import xyz.shiguangliang.service.UserService;
import xyz.shiguangliang.util.query.QueryInfo;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    //登录
    @Override
    public User login(String username, String password) {
      User user = userMapper.selectLogin(username,password);
      if (user != null) {
            //登录次数加一
            if (user.getIntimes() !=null) {
                user.setIntimes(user.getIntimes() + 1);
            }else {
                user.setIntimes(1);
            }
            //更新登录时间
            user.setLastlogin(new Date());
            return user;
      }
      return null;
    }

    //注册
    @Override
    public boolean register(User user) {
      int i = 0;
      //检测用户是否存在
      User user1 = userMapper.selectUsername(user.getUsername());
      if (user1 == null) {
            i = userMapper.insert(user);
      }
      return i > 0;
    }

    //用户列表
    @Override
    public QueryInfo getUserList(String query, Integer pagenum,Integer pagesize) {
      QueryInfo queryInfo = new QueryInfo();
      int start;
      int end;
      if (pagenum == null||pagesize == null){
            pagenum =0;
            pagesize = 3;
      }
      start = (pagenum-1)*pagesize;
      end = pagesize;
      int userSize = userMapper.selectUserListLimitSize(query,start,end);
      List<User> users = userMapper.selectUserListLimit(query,start,end);
      queryInfo.setList(users);
      queryInfo.setTotal(userSize);
      return queryInfo;
    }

    //删除用户
    @Override
    public int deleteUser(Integer tid) {
      return userMapper.deleteByPrimaryKey(tid);
    }

    //通过id查找用户
    @Override
    public User findById(Integer tid) {
      return userMapper.selectByPrimaryKey(tid);
    }



    //更新用户
    @Override
    public int updateUser(User user) {
      if (user.getPassword()==null|| Objects.equals(user.getPassword(), "")){
            user.setPassword(userMapper.selectByPrimaryKey(user.getTid()).getPassword());
      }
      return userMapper.updateByPrimaryKey(user);
    }

    //通过用户名查找用户
    @Override
    public User findByUsername(String username) {
      return userMapper.selectUsername(username);
    }

    //获取用户权限
    @Override
    public int getPower(String username) {
      return userMapper.selectUsername(username).getPower();
    }
}useMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xyz.shiguangliang.mybatis.dao.UserMapper">
<resultMap id="BaseResultMap" type="xyz.shiguangliang.mybatis.domain.User">
    <id column="tid" jdbcType="INTEGER" property="tid" />
    <result column="username" jdbcType="VARCHAR" property="username" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="teachername" jdbcType="VARCHAR" property="teachername" />
    <result column="dno" jdbcType="INTEGER" property="dno" />
    <result column="power" jdbcType="INTEGER" property="power" />
    <result column="intimes" jdbcType="INTEGER" property="intimes" />
    <result column="lastlogin" jdbcType="TIMESTAMP" property="lastlogin" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from teacher
    where tid = #{tid,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="xyz.shiguangliang.mybatis.domain.User">
    insert into teacher (tid, username, password,
      teachername, dno, power,
      intimes, lastlogin)
    values (#{tid,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
      #{teachername,jdbcType=VARCHAR}, #{dno,jdbcType=INTEGER}, #{power,jdbcType=INTEGER},
      #{intimes,jdbcType=INTEGER}, #{lastlogin,jdbcType=TIMESTAMP})
</insert>
<update id="updateByPrimaryKey" parameterType="xyz.shiguangliang.mybatis.domain.User">
    update teacher
    set username = #{username,jdbcType=VARCHAR},
      password = #{password,jdbcType=VARCHAR},
      teachername = #{teachername,jdbcType=VARCHAR},
      dno = #{dno,jdbcType=INTEGER},
      power = #{power,jdbcType=INTEGER},
      intimes = #{intimes,jdbcType=INTEGER},
      lastlogin = #{lastlogin,jdbcType=TIMESTAMP}
    where tid = #{tid,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select tid, username, password, teachername, dno, power, intimes, lastlogin
    from teacher
    where tid = #{tid,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
    select tid, username, password, teachername, dno, power, intimes, lastlogin
    from teacher
</select>
    <select id="selectLogin" resultType="xyz.shiguangliang.mybatis.domain.User">
      select tid, username, password, teachername, dno, power, intimes, lastlogin
      from teacher
      where username = #{username} and password = #{password}
    </select>
<select id="selectUsername" resultType="xyz.shiguangliang.mybatis.domain.User">
    select tid, username, password, teachername, dno, power, intimes, lastlogin
      from teacher
      where username = #{username}
</select>
<select id="selectUserListLimit" resultType="xyz.shiguangliang.mybatis.domain.User">
    select tid, username, password, teachername, dno, power, intimes, lastlogin
    from teacher
    where
    /*条件判断*/
    <if test="#{query} != null and #{query} != ''">
      /*模糊查询*/
      <bind name="query2" value="'%' + query + '%'"/>
      username like #{query2}
    </if>
    LIMIT #{start},#{end}
</select>
<select id="selectUserListLimitSize" resultType="java.lang.Integer">
    select count(*)
    from teacher
    where
    /*条件判断*/
    <if test="#{query} != null and #{query} != ''">
      /*模糊查询*/
      <bind name="query2" value="'%' + query + '%'"/>
      username like #{query2}
    </if>
</select>
</mapper>三、系统展示

学生模块


[*]登录
https://img-blog.csdnimg.cn/15a8eaa73e7344db8205192c49967283.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
[*]首页:
https://img-blog.csdnimg.cn/dc47647b95844546b75fb65d875cacb2.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
[*]答题
学生可以选择自己的试卷进行答题,可以上一题和下一题,同时还有时间倒计时功能,还可以标记题目,提交试卷后系统自动计算分数出来:
https://img-blog.csdnimg.cn/6b44130530f9444795d9e8f363f45a32.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
https://img-blog.csdnimg.cn/d2916603994f48ca94fbb229df326aa8.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
https://img-blog.csdnimg.cn/8932411be237418ba7bdc77c4a0f637e.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
[*]练习模式
https://img-blog.csdnimg.cn/6051422c78844abf8553f509937c5501.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
-学生查看分数
https://img-blog.csdnimg.cn/64beeb41c6e948d1afa82dcdfb183758.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center

[*]留言功能
https://img-blog.csdnimg.cn/f2e9f9319c5b46d390ff2692878a03d9.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
教师管理

教师管理:考试管理;题库管理;成绩管理;学生管理等;
https://img-blog.csdnimg.cn/6efc907f9fdd4a09b5dd44cc8401fa12.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center

[*]考试管理
https://img-blog.csdnimg.cn/3e4c4faf19c2420baa4ac342bc3421f3.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center
https://img-blog.csdnimg.cn/31293cb29cfe4c6fb31367bbdd8a8f75.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70#pic_center

[*]题库管理
https://img-blog.csdnimg.cn/8541e77908fb4707ab928b0907d3f357.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
[*]增加题目信息
https://img-blog.csdnimg.cn/e744226678f246d1bde3af89a7f0f102.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
[*]成绩管理
https://img-blog.csdnimg.cn/f4814fe674ef46cbbbb5fb2e65ab72a6.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
查看某个学生分数情况:
https://img-blog.csdnimg.cn/66907fc4e3de46f7b26256129df403d0.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
[*]查看班级分数段情况:
https://img-blog.csdnimg.cn/7b5366d433ee436ea782e472a4d87fec.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
https://img-blog.csdnimg.cn/ec674e7dc63442e482ac6310e904b3f2.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
[*]学生管理
https://img-blog.csdnimg.cn/6f54a6a2ce0a4d29b7c850b8b64fb54e.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
管理员模块

https://img-blog.csdnimg.cn/029a8249b5a841fbb704d12111c41843.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70

[*]拥有教师的所有权限,同时增加可以管理教师模块:
https://img-blog.csdnimg.cn/a6ba6ce78b7747ddacc49e81aa0a00f3.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70
https://img-blog.csdnimg.cn/4eefc8d462d24fc1b290999d24e882b9.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNTI2NDcz,size_16,color_FFFFFF,t_70

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: 27基于java的学生在线考试系统