基于javaweb的SpringBoot前台+后台在线考试系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

380023262402

390023262402

400023262402

410023262402

420023262402

基于javaweb的SpringBoot前台+后台在线考试系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)

一、项目简述

本系统主要实现的功能有: 学生以及老师的注册登录,在线考试,错题查询,学生管理,问题管理,错题管理,错题查询,分数查询,试卷管 理,人工组卷。自动组卷,教师,班级,统计等等管理功能。

二、项目运行

环境配置: Jdk1.8 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + 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
41
42
    }else {
result.setSuccess(false);
}
return result;
}

@RequestMapping("/index")
public String index(Model model){
//查询所有用户
int teas=teacherService.queryCountAll();
int stus=studentService.queryCOuntALlstu();
int alllogers=teas+stus;
//统计试题
int allQues=questionService.queryCountAllQues();
//统计试卷
int allPaps=paperService.queryCountALlPaps();
List<Record> ScoreHStu=recordService.queryRankScoreRecord();
List<Record> AccHStu=recordService.queryRankAccRecord();
model.addAttribute("ScoreHStu",ScoreHStu);
model.addAttribute("AccHStu",AccHStu);
model.addAttribute("allPaps",allPaps);
model.addAttribute("allQues",allQues);
model.addAttribute("alllogers",alllogers);
return "index";
}

//前台学生登录考试
@ResponseBody
@RequestMapping("/foreCheck/check")
public Object foreCheck(Student student, HttpServletRequest request){
AjaxResult result=new AjaxResult();
HttpSession session=request.getSession();
Student stud=studentService.check(student);
if(stud!=null){
session.setAttribute("loger",stud);
result.setSuccess(true);
}else {
result.setSuccess(false);
}
return result;
}
//前台登录到展示页面
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
    @RequestMapping("/getAllTeacher")
public String getAllTeacher(Model model){
List<Teacher> teachers = teacherService.getAll();
//查找classe表中已存在的教师,将用于表单教师是否可以删除
List<Classe> classes=classeService.queryAllTeacherId();
List<Integer> teaId=new ArrayList<>();
for(Classe cla:classes){
teaId.add(cla.getTeacherId());
}
model.addAttribute("teaId",teaId);
model.addAttribute("teachers",teachers);
return "teacher/teacherList";
}
//教师添加或者修改操作,先去添加页面
@RequestMapping("/toAddTeacher")
public String toAddTeacher(){
return "teacher/teacherAdd";
}

//添加或者修改具体操作
@RequestMapping("/addTeacher")
public String addTeacher(Teacher teacher){
int teacherId = teacher.getTeacherId();
if(teacherId==0){
/*若id为0即是刚添加未分配,要进行增加操作*/
teacherService.addTeacher(teacher);
}else {
/*若id已存在,是要进行修改操作*/
teacherService.editTeacher(teacher);
}
return "redirect:/teacher/getAllTeacher";
}

//教师去修改页面
@RequestMapping("/{id}")
public String toEditTeacher(@PathVariable("id") Integer id,Model model){
Teacher teacher=teacherService.getTeacherById(id);
model.addAttribute("teacher",teacher);
return "teacher/teacherAdd";
}
//教师删除
@RequestMapping("/deleteTeacher/{id}")
public String deleteTeacherById(@PathVariable("id") Integer id,Model model){
teacherService.deleteTeacherById(id);
return "redirect:/teacher/getAllTeacher";
}

}
package com.zhao.quiz.controller;

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


@Controller
@RequestMapping("/classe")
public class ClasseController {
@Autowired
private ClasseService classeService;
@Autowired
private TeacherService teacherService;
//查看所有班级
@RequestMapping("/getAllClasse")
public String getAllClasse(Model model){
List<Classe> classes = classeService.getAll();
model.addAttribute("classes",classes);
return "classe/classeList";
}

//班级添加或者修改操作,先去添加页面
@RequestMapping("/toAddClasse")
public String toAddClasse(Model model){
List<Teacher> teachers=teacherService.queryTeacherNotAdvisor();
model.addAttribute("teachers",teachers);
return "classe/classeAdd";
}

//添加具体操作
@RequestMapping("/addClasse")
public String addClasse(Classe classe){
classeService.addClasse(classe);
return "redirect:/classe/getAllClasse";
}

//班级去修改页面
@RequestMapping("/toEditClasse/{id}")
public String toEditClasse(@PathVariable("id") Integer id,Model model){
//根据id查询班级
Classe classe=classeService.getClasseById(id);
//过去班级的班主任,回显
int teacherIdd=classe.getTeacherId();
Teacher teacherold=teacherService.getTeacherById(teacherIdd);
//查询可分配班主任得教师
List<Teacher> teachers=teacherService.queryTeacherNotAdvisor();
teachers.add(teacherold);
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
    model.addAttribute("questionCourseresRes",questionCourseresRes);
model.addAttribute("questionTypesRes",questionTypesRes);
model.addAttribute("questionTypes",questionTypes);
model.addAttribute("questionCourses",questionCourses);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("paperId",paperId);
return "paper/AddQuestion";
}
//为试卷添加试题
@RequestMapping("/AddQuestion")
public String AddQuestion(Integer paperId,Integer quesId,Integer pageNum,String questionCourse,String questionType){
QuestionPaper questionPaper=new QuestionPaper(quesId,paperId);
paperService.AddQuestionToPaperById(questionPaper);
return "redirect:/paper/toAddQuestion/"+paperId+"?pageNum="+pageNum+"&questionCourse="+questionCourse+"&questionType="+questionType;
}
//从试卷中移除试题
@RequestMapping("/detachQuestion")
public String detachQuestion(Integer qpId,Integer paperId){
paperService.detachQuestionById(qpId);
return "redirect:/paper/toManagerQuestion/"+paperId;
}

//去往随机组题页面
@RequestMapping("/toRandomQuestion/{id}")
public String toRandomQuestion(@PathVariable ("id") Integer papid,Question question,Model model){
List<Question> questionCourses=questionService.queryAllCourse();
questionCourses.add(new Question("bug","all"));
//查找所有题目课程和所有类型,且去重
//用于条件查询题库中尚未分配的题有多少道
int TotalQuestionNums=questionService.queryAllQuestionNums();
List<Map> maps = questionService.queryNumOfQuestionType();
List<String> course=new ArrayList<>();
List<Integer> count=new ArrayList<>();
for (Map map:maps){
for (Object key : map.keySet()) {
if(map.get(key) instanceof String){
course.add(map.get(key).toString());
}else{
count.add(Integer.parseInt(map.get(key).toString()));
}
}
}
Paper paperName=paperService.queryPaperNameById(papid);
model.addAttribute("paperName",paperName.getPaperName());
model.addAttribute("count",count);
model.addAttribute("course",course);
model.addAttribute("TotalQuestionNums",TotalQuestionNums);
model.addAttribute("paperId",papid);
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
54
    paperService.editPaper(paper);
return "redirect:/paper/getAllPaper";
}

//试卷删除
@RequestMapping("/deletePaper/{id}")
public String deletePaperById(@PathVariable("id") Integer id,Model model){
paperService.deletePaperById(id);
return "redirect:/paper/getAllPaper";
}

//去往试题管理页面
@RequestMapping("/toManagerQuestion/{id}")
public String toManagerQuestion(@PathVariable("id") Integer id,Model model){
List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionById(id);
model.addAttribute("papid",id);
Paper paperName=paperService.queryPaperNameById(id);
model.addAttribute("paperName",paperName.getPaperName());
model.addAttribute("questionPapers",questionPapers);
return "paper/ManagerQuestion";
}
//来到试题显示页面为试卷添加试题
@RequestMapping("/toAddQuestion/{id}")
public String getAllQuestion(@PathVariable("id") Integer paperId,Question question,@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "4") int pageSize,
Model model){
//查找所有题目课程和所有类型,且去重
List<Question> questionCourses=questionService.queryAllCourse();
questionCourses.add(new Question("bug","all"));
List<Question> questionTypes=questionService.queryAllType();
questionTypes.add(new Question("k","bug"));
String questionCourseBef = question.getQuestionCourse();
String questionCourseresRes="";
if(questionCourseBef==null){
//默认查询所有
questionCourseresRes="all";
}else {
questionCourseresRes=questionCourseBef;
}
//若是第一次查询则用上次提交的表单中的类型、课程,若是第二次查询则延用上次类型
String questionTypeBef=question.getQuestionType();
String questionTypesRes="";
if(questionTypeBef==null){
//默认查询所有
questionTypesRes="k";
}else {
questionTypesRes=questionTypeBef;
}
//查询试卷中已存在的试题,不能再次被添加
List<Question> questionids=paperService.queryALlQuestionIdInPaperById(paperId);
List<Integer> quesds=new ArrayList<>();
if(questionids!=null){
for(Question qid:questionids){
quesds.add(qid.getQuestionId());
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
        int nums=questionService.queryIdByPapQue(ques);
return "redirect:/paper/toManagerQuestion/"+papid;
}
}
package com.zhao.quiz.controller;




@Controller
@RequestMapping("/exam")
public class ExamController {
@Autowired
private ExamService examService;
@Autowired
private PaperService paperService;
@Autowired
private RecordService recordService;

//前台跳转
@RequestMapping("/toExam")
public String toExam(Model model){
List<Exam> Exams = examService.getAll();
model.addAttribute("Exams",Exams);
return "exam/examplan";


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