基于javaweb的SpringBoot在线考试系统(单选,多选,判断,填空,简答题)(java+springboot+ssm+mysql+html+thymeleaf+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

470023102402

490023102402

500023102402

510023102402

520023102402

有三种角色:老师、学生、管理员

基于javaweb的SpringBoot在线考试系统(单选,多选,判断,填空,简答题)(java+springboot+ssm+mysql+html+thymeleaf+maven)

功能:

学生信息 班级 专业 学号 姓名  在线考试 成绩查询 个人信息 密码修改 教师管理 教师编号 姓名  所教科目  题库管理  单选题  多选题 填空题  判断题,简答题(人工阅卷) 试卷管理  新建试卷  在试库中选择试题 试卷设置 发布试卷 考试管理  发布考试计划  学生考试 自动阅卷  人工阅卷 个人信息 密码修改 管理员 学生管理 教师管理 管理员管理 院系管理 班级管理 个人信息 密码修改。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
if (request.containsKey("student_id")) {
param.put("student_id", request.getString("student_id"));
}
if (request.containsKey("name")) {
param.put("name", request.getString("name"));
}
return studentService.qryPage(param, pageNo, pageSize);
}

@RequestMapping(value = "/student/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public Result<Student> insert(HttpRequest request) {
Student student = new Student();
student.setStudentId(request.getString("student_id"));
student.setName(request.getString("student_name"));
student.setPwd(request.getString("student_id"));
student.setSex(request.getInteger("sex"));
student.setClassId(request.getString("class_id"));
student.setUpdateTime(new Date());
return studentService.insert(student, ImageUtil.stringToBytes(request.getString("student_image")));
}

@RequestMapping(value = "/student/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public Result<Student> update(HttpRequest request) {
Student student = new Student();
student.setStudentId(request.getString("student_id"));
student.setName(request.getString("student_name"));
student.setPwd(request.getString("student_id"));
student.setSex(request.getInteger("sex"));
student.setClassId(request.getString("class_id"));
student.setUpdateTime(new Date());
return studentService.update(student, ImageUtil.stringToBytes(request.getString("student_image")));
}

@RequestMapping(value = "/student/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public Result<Student> del(HttpRequest request) {
List<String> studentIdList = new ArrayList<>();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


/**
* 教师控制器
*/
@RestController
public class TeacherController {

@Resource(name = "teacherService")
private ITeacherService teacherService;

/**
* 管理员 查询教师列表
*/
@RequestMapping(value = "/teacher/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public ListResult<Teacher> 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("teacher_id")) {
param.put("teacher_id", request.getString("teacher_id"));
}
if (request.containsKey("name")) {
param.put("name", request.getString("name"));
}
return teacherService.qryPage(param, pageNo, pageSize);
}

/**
* 管理员 添加教师
*/
@RequestMapping(value = "/teacher/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public Result<Teacher> insert(HttpRequest request) {
Teacher teacher = new Teacher();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


/**
* 试卷控制器
*/
@RestController
public class TestPaperController {

@Resource(name = "testPaperService")
private ITestPaperService testPaperService;

/**
* 分页查询试卷信息
*/
@RequestMapping(value = "/testpaper/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.teacher})
public ListResult<TestPaper> qryPage(HttpRequest request) {
int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1;
int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20;
String testPaperName = request.getString("test_paper_name");
String academicsId = request.getString("academics_id");
return testPaperService.qryPage(testPaperName, academicsId, pageNo, pageSize);
}

/**
* 教师 更新新试卷
*/
@RequestMapping(value = "/testpaper/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.teacher})
public Result<TestPaper> insert(HttpRequest request) {
return testPaperService.insert(request.getString("test_paper_name"), request.getString("academics_id"));
}

/**
* 教师 删除试卷
*/
@RequestMapping(value = "/testpaper/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.teacher})
public Result<TestPaper> del(HttpRequest request) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@RequestMapping(value = "/teacher/testpapermanage/{url_id}")
public String testpapermanage(@PathVariable(value = "url_id") String urlId, Model model) {
if (!ValidateUrlIdUtil.validate(urlId, model)) {
return "error/error";
}
return "teacher/testpapermanage/testpapermanage";
}

/**
* 教师 试卷编辑
*/
@RequestMapping(value = "/teacher/testpaperedit/{url_id}/{test_paper_id}")
public String examplanmanage(@PathVariable(value = "url_id") String urlId, @PathVariable(value = "test_paper_id") String testPaperId, Model model) {
if (!ValidateUrlIdUtil.validate(urlId, model)) {
return "error/error";
}
testPaperService.qryByTestPaperId(Integer.parseInt(testPaperId), model);
return "teacher/testpapermanage/testpaperedit";
}

/**
* 教师 考试管理
*/
@RequestMapping(value = "/teacher/examinfomanage/{url_id}")
public String examplanmanage(@PathVariable(value = "url_id") String urlId, Model model) {
if (!ValidateUrlIdUtil.validate(urlId, model)) {
return "error/error";
}
return "teacher/examinfomanage/examinfomanage";
}

/**
* 教师 阅卷成绩查看
*/
@RequestMapping(value = "/teacher/markpapers/{url_id}/{exam_id}")
public String markpapers(@PathVariable(value = "url_id") String urlId,
@PathVariable(value = "exam_id") String examId, Model model) {
if (!ValidateUrlIdUtil.validate(urlId, model)) {
return "error/error";
}
studentExamRecordService.markpapers(Integer.parseInt(examId), model);
return "teacher/markpapers/markpapers";
}

@RequestMapping(value = "/teacher/studentpapers/{url_id}/{exam_id}/{student_id}")
public String studentpapers(@PathVariable(value = "url_id") String urlId,
@PathVariable(value = "exam_id") String examId,
@PathVariable(value = "student_id") String studentId, Model model) {
if (!ValidateUrlIdUtil.validate(urlId, model)) {
return "error/error";
}
model.addAttribute("exam_id", examId);
model.addAttribute("student_id", studentId);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49


@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"));
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
     * 管理员 删除院系
*/
@RequestMapping(value = "/department/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
@RoleAnnotation(types = {RoleEnum.admin})
public Result<Department> del(HttpRequest request) {
List<String> departmentIdList = new ArrayList<>();
JSONArray array = request.getJSONArray("department_id_list");
for (int i = 0; i < array.size(); i++) {
departmentIdList.add(array.getString(i));
}
return departmentService.del(departmentIdList);
}
}
package com.controller;



/**
* 管理员控制器
*/
@RestController
public class AdminController {

@Resource(name = "adminService")
private IAdminService adminService;


项目链接:
https://javayms.github.io?id=101422282105200ck
https://javayms.pages.dev?id=101422282105200ck