欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Java毕业设计实战之在线高中考试系统的实现

程序员文章站 2022-03-03 09:18:05
项目分为前台和后台,前台主要为学生角色、后台主要为管理员角色。管理员添加试题和发布试卷,学生负责在线考试、在线查看成绩和错题记录列表等。管理员功能有:年级管理、课程管理、试题管理、试卷管理、学生管理等...

项目分为前台和后台,前台主要为学生角色、后台主要为管理员角色。

管理员添加试题和发布试卷,学生负责在线考试、在线查看成绩和错题记录列表等。

管理员功能有:年级管理、课程管理、试题管理、试卷管理、学生管理等。

运行环境:jdk1.8、mysql5.x、eclipse、tomcat8.5\7.0、maven3.5\3.6。

Java毕业设计实战之在线高中考试系统的实现

Java毕业设计实战之在线高中考试系统的实现

Java毕业设计实战之在线高中考试系统的实现

Java毕业设计实战之在线高中考试系统的实现

Java毕业设计实战之在线高中考试系统的实现

Java毕业设计实战之在线高中考试系统的实现

统一管理学生 教师 管理员信息:

/**
 * 统一管理学生 教师 管理员信息
 */
@restcontroller
public class usercontroller {
 
    @resource(name = "userservice")
    private iuserservice userservice;
 
    /**
     * 查询用户信息
     * 先判断用户类型 在查询用户信息
     */
    @requestmapping(value = "/user/qryuserinfo", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<user> qryuserinfo() {
        return userservice.qryuserinfo();
    }
 
    /**
     * 更新用户信息
     */
    @requestmapping(value = "/user/update", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<user> update(httprequest request) {
        user user = new user();
        user.setuserid(request.getstring("user_id"));
        user.setname(request.getstring("name"));
        user.setsex(request.getinteger("sex"));
        user.settype(user.usertype.get(request.getinteger("type")));
        return userservice.update(user, imageutil.stringtobytes(request.getstring("user_image")));
    }
 
    /**
     * 更新用户密码
     */
    @requestmapping(value = "/user/updatepwd", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<user> updatepwd(httprequest request) {
        return userservice.updatepwd(request.getstring("old_pwd"), request.getstring("pwd"));
    }
}

管理员控制器:

/**
 * 管理员控制器
 */
@restcontroller
public class admincontroller {
 
    @resource(name = "adminservice")
    private iadminservice adminservice;
 
    /**
     * 管理员 查询管理员列表
     */
    @requestmapping(value = "/admin/qrypage", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.admin})
    public listresult<admin> qrypage(httprequest request) {
        map<string, object> param = new hashmap<>();
        int pageno = request.containskey("page_no") ? request.getinteger("page_no") : 1;
        int pagesize = request.containskey("page_size") ? request.getinteger("page_size") : 20;
        if (request.containskey("login_name")) {
            param.put("login_name", request.getstring("login_name"));
        }
        if (request.containskey("name")) {
            param.put("name", request.getstring("name"));
        }
        return adminservice.qrypage(param, pageno, pagesize);
    }
 
    /**
     * 管理员 添加管理员
     */
    @requestmapping(value = "/admin/add", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.admin})
    public result<admin> insert(httprequest request) {
        admin admin = new admin();
        admin.setloginname(request.getstring("login_name"));
        admin.setname(request.getstring("admin_name"));
        admin.setpwd(request.getstring("login_name"));
        admin.setsex(request.getinteger("sex"));
        admin.setupdatetime(new date());
        return adminservice.insert(admin, imageutil.stringtobytes(request.getstring("admin_image")));
    }
 
    /**
     * 管理员 更新管理员
     */
    @requestmapping(value = "/admin/update", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.admin})
    public result<admin> update(httprequest request) {
        admin admin = new admin();
        admin.setloginname(request.getstring("login_name"));
        admin.setname(request.getstring("admin_name"));
        admin.setpwd(request.getstring("login_name"));
        admin.setsex(request.getinteger("sex"));
        admin.setupdatetime(new date());
        return adminservice.update(admin, imageutil.stringtobytes(request.getstring("admin_image")));
    }
 
    /**
     * 管理员 删除管理员
     */
    @requestmapping(value = "/admin/del", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.admin})
    public result<admin> del(httprequest request) {
        list<string> adminidlist = new arraylist<>();
        jsonarray array = request.getjsonarray("admin_id_list");
        for (int i = 0; i < array.size(); i++) {
            adminidlist.add(array.getstring(i));
        }
        return adminservice.del(adminidlist);
    }
}

考试管理控制器:

/**
 * 考试管理控制器
 */
@restcontroller
public class examinfocontroller {
 
    @resource(name = "examinfoservice")
    private iexaminfoservice examinfoservice;
 
    /**
     * 教师 查询考试列表
     */
    @requestmapping(value = "/examinfo/qrypage", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public listresult<examinfo> exam(httprequest request) {
        map<string, object> param = new hashmap<>();
        int pageno = request.containskey("page_no") ? request.getinteger("page_no") : 1;
        int pagesize = request.containskey("page_size") ? request.getinteger("page_size") : 20;
        return examinfoservice.qrypage(param, pageno, pagesize);
    }
 
    /**
     * 教师 添加新的考试信息
     */
    @requestmapping(value = "/examinfo/add", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> insert(httprequest request) {
        examinfo exam = new examinfo();
        exam.settestpaperid(request.getinteger("test_paper_id"));
        exam.setclassid(request.getstring("class_id"));
        exam.setstate(1);
        exam.settime(request.getinteger("time"));
        exam.setefftime(dateutils.todate(request.getstring("eff_time"), dateconst.date_time_format_yyyy_mm_dd_hh_mi));
        exam.setexptime(dateutils.todate(request.getstring("exp_time"), dateconst.date_time_format_yyyy_mm_dd_hh_mi));
        exam.setupdatetime(new date());
        return examinfoservice.insert(exam);
    }
 
    /**
     * 教师 更新考试信息
     */
    @requestmapping(value = "/examinfo/update", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> update(httprequest request) {
        examinfo exam = new examinfo();
        exam.setexamid(request.getinteger("exam_id"));
        exam.settestpaperid(request.getinteger("test_paper_id"));
        exam.setclassid(request.getstring("class_id"));
        exam.setstate(1);
        exam.settime(request.getinteger("time"));
        exam.setefftime(dateutils.todate(request.getstring("eff_time"), dateconst.date_time_format_yyyy_mm_dd_hh_mi));
        exam.setexptime(dateutils.todate(request.getstring("exp_time"), dateconst.date_time_format_yyyy_mm_dd_hh_mi));
        exam.setupdatetime(new date());
        exam.setupdatetime(new date());
        return examinfoservice.update(exam);
    }
 
    /**
     * 教师 新建状态的考试信息可以删除
     */
    @requestmapping(value = "/examinfo/del", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> del(httprequest request) {
        list<integer> examidlist = new arraylist<>();
        jsonarray array = request.getjsonarray("exam_id_list");
        for (int i = 0; i < array.size(); i++) {
            examidlist.add(array.getinteger(i));
        }
        return examinfoservice.del(examidlist);
    }
 
    /**
     * 教师 发布考试信息
     */
    @requestmapping(value = "/examinfo/release", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> updatestate(httprequest request) {
        return examinfoservice.release(request.getinteger("exam_id"));
    }
 
    /**
     * 学生 查询考试试题分组列表
     */
    @requestmapping(value = "/examinfo/qryexamquegrouplist", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.student, roleenum.teacher})
    public result<testpaperquestiongroup> qryexamquegrouplist(httprequest request) {
        return examinfoservice.qryexamquegrouplist(request.getinteger("exam_id"));
    }
 
    /**
     * 学生 查询考试试题列表
     */
    @requestmapping(value = "/examinfo/qryexamquestionlist", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.student})
    public result<studentexamquestionrecord> qryexamquestionlist(httprequest request) {
        return examinfoservice.qryexamquestionlist(request.getinteger("exam_id"), request.getstring("student_id"), request.getinteger("question_group_id"));
    }
 
    /**
     * 教师 判卷查询试题列表
     */
    @requestmapping(value = "/examinfo/qrymarkquelist", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<studentexamquestionrecord> qrymarkquelist(httprequest request) {
        return examinfoservice.qrymarkquelist(request.getinteger("exam_id"), request.getstring("student_id"), request.getinteger("question_group_id"));
    }
 
    /**
     * 教师 记录学生考试分数 complete
     */
    @requestmapping(value = "/examinfo/updatequescore", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> updatequescore(httprequest request) {
        studentexamquestionrecord record = new studentexamquestionrecord();
        record.setexamid(request.getinteger("exam_id"));
        record.setstudentid(request.getstring("student_id"));
        record.setquestiongroupid(request.getinteger("question_group_id"));
        record.setquestionid(request.getlong("question_id"));
        record.setscore(request.getfloat("score"));
        record.setcorrect(request.getboolean("correct"));
        return examinfoservice.updatequescore(record);
    }
 
    /**
     * 教师 完成评分
     */
    @requestmapping(value = "/examinfo/complete", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    @roleannotation(types = {roleenum.teacher})
    public result<examinfo> complete(httprequest request) {
        return examinfoservice.complete(request.getinteger("exam_id"),
                request.getstring("student_id"));
    }
 
}

登录控制层:

@restcontroller
public class logincontroller {
 
    @resource(name = "loginservice")
    private iloginservice loginservice;
 
    /**
     * 用户登录调用 在登陆成功生成两个token 同时返回各自首页
     * * 学生 student/student
     * * 老师 teacher/teacher
     * * 管理员 admin/admin
     */
    @requestmapping(value = "/login/login", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<token> login(httprequest request) {
        return loginservice.login(request.getstring("login_name"), request.getstring("pwd"));
    }
 
    /**
     * 登录检查
     */
    @requestmapping(value = "/login/check", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<token> check() {
        return new result<>();
    }
 
    /**
     * token 续约
     */
    @requestmapping(value = "/login/refresh", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<token> refresh(httprequest request) {
        string refreshtoken = request.getstring("refresh_token");
        string urlid = request.getstring("url_id");
        token token = tokencache.getinstance().get(urlid);
        if(token == null){
            exceptionhelper.error(errorcode.error_code_0003);
        }
        try {
            claims claims = tokenutils.parsetoken(refreshtoken);
            if (stringutils.isnotempty((string.valueof(claims.getordefault("student_id", ""))))) {
                claims.put("student_id", sessioncontext.get("student_id"));
            }
            if (stringutils.isnotempty((string.valueof(claims.getordefault("teacher_id", ""))))) {
                claims.put("teacher_id", sessioncontext.get("teacher_id"));
            }
            if (stringutils.isnotempty((string.valueof(claims.getordefault("login_name", ""))))) {
                claims.put("login_name", sessioncontext.get("login_name"));
            }
            claims.put("name", claims.get("name"));
            token.settoken(tokenutils.createtoken(claims, tokenutils.expiretime));
            token.setrefreshtoken(tokenutils.createtoken(claims, tokenutils.long_expiretime));
            tokencache.getinstance().add(token);
        } catch (exception e) {
            exceptionhelper.error(errorcode.error_code_0003);
        }
        return new result<>(token);
    }
 
    /**
     * 退出系统
     */
    @requestmapping(value = "/login/exit", method = requestmethod.post, produces = {"application/json;charset=utf-8"})
    public result<token> exit(httprequest request) {
        string urlid = request.getstring("url_id");
        if (stringutils.isnotempty(urlid)) {
            tokencache.getinstance().remove(urlid);
        }
        return new result<>();
    }
}

到此这篇关于java毕业设计实战之在线高中考试系统的实现的文章就介绍到这了,更多相关java 考试系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!