基于javaweb的SSM在线考试系统(java+ssm+mysql+jsp+bootstrap)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

142123460509

152123460509

162123460509

182123460509

192123460509

202123460509

212123460509

222123460509

232123460509

242123460509

基于javaweb的SSM在线考试系统(java+ssm+mysql+jsp+bootstrap)

老师:
teacher1 123456——管理员权限
teacher2 123456
teacher3 123456

学生:
student1 123456
student2 123456
student3 123456

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
 * 预修改教师
* @param teacherId
* @return
*/
@RequestMapping(value="/teacher/{teacherId}", method=RequestMethod.GET)
public ModelAndView preUpdateTeacher(@PathVariable("teacherId") Integer teacherId) {
logger.info("预修改教师处理");

ModelAndView model = new ModelAndView();
//获取要修改教师
TeacherInfo teacher = teacherInfoService.getTeacherById(teacherId);
model.setViewName("/admin/teacheredit");
model.addObject("teacher", teacher);

return model;
}

/**
* 修改/添加 教师
* @param teacherId
* @param isUpdate 操作标识
* @param teacherName
* @param teacherAccount
* @param teacherPwd
* @param adminPower
* @return
*/
@RequestMapping(value="/teacher/teacher", method=RequestMethod.POST)
public String isUpdateOrAddTeacher(@RequestParam(value="teacherId", required=false) Integer teacherId,
@RequestParam(value="isupdate", required=false) Integer isUpdate,
@RequestParam("teacherName") String teacherName,
@RequestParam("teacherAccount") String teacherAccount,
@RequestParam("teacherPwd") String teacherPwd,
@RequestParam("adminPower") Integer adminPower) {

TeacherInfo teacher = new TeacherInfo();
teacher.setTeacherId(teacherId);
teacher.setTeacherName(teacherName);
teacher.setTeacherAccount(teacherAccount);
teacher.setTeacherPwd(teacherPwd);
teacher.setAdminPower(adminPower);

if (isUpdate != null) { //修改
logger.info("修改教师 "+teacher+" 的信息");
int row = teacherInfoService.isUpdateTeacherInfo(teacher);
} else { //添加
logger.info("添加教师 "+teacher+" 的信息");
int row = teacherInfoService.isAddTeacherInfo(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
	@RequestMapping("/self/{studentId}")
public ModelAndView selfInfo(@PathVariable("studentId") Integer studentId) {
StudentInfo stu = studentInfoService.getStudentById(studentId);

ModelAndView model = new ModelAndView();
model.setViewName("/reception/self");
model.addObject("self", stu);


return model;
}


/**
* 学生修改密码
* @param pwd
* @param studentId
* @param response
* @throws IOException
*/
@RequestMapping("/reset/{pwd}/{studentId}")
public void isResetPwd(
@PathVariable("pwd") String pwd,
@PathVariable("studentId") Integer studentId,
HttpServletResponse response) throws IOException {
logger.info("学生 "+studentId+" 修改密码");
student.setStudentId(studentId);
student.setStudentPwd(pwd);

int row = studentInfoService.isResetPwdWithStu(student);

if (row > 0) {
response.getWriter().print("t");
} else {
response.getWriter().print("f");
}
}
}

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
        }
} catch (Exception e) {
e.printStackTrace();
}
}


/**
* 处理 试题 添加到 试卷
*
* @param subjects 试题集合
* @param examPaperId 对应试卷编号
*/
private void dispatcherExamPaperAndSubject(List<SubjectInfo> subjects, Integer examPaperId) {
List<Integer> subjectIds = new ArrayList<Integer>();
//试题总量统计
int count = 0;
//试题总分统计
int score = 0;

/** 添加试题 */
for (SubjectInfo subjectInfo : subjects) {
int row1 = subjectInfoService.isAddSubject(subjectInfo);
score += subjectInfo.getSubjectScore();
subjectIds.add(subjectInfo.getSubjectId());
count++;
}
logger.info("添加试题 SIZE " + count);

/** 添加试题到试卷 */
Map<String, Object> esmMap = new HashMap<String, Object>();
esmMap.put("examPaperId", examPaperId);
esmMap.put("subjectIds", subjectIds);
esmService.isAddESM(esmMap);
logger.info("添加试题 SIZE " + count + " SCORE " + score + " 到试卷 " + examPaperId);

//修改试卷信息
Map<String, Object> scoreWithNum = new HashMap<String, Object>();
scoreWithNum.put("subjectNum", count);
scoreWithNum.put("score", score);
scoreWithNum.put("examPaperId", examPaperId);
/** 修改试卷总分 */
examPaperInfoService.isUpdateExamPaperScore(scoreWithNum);
/** 修改试卷试题总量 */
examPaperInfoService.isUpdateExamPaperSubjects(scoreWithNum);
}


/**
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
		return "../error";
}

return "redirect:/classes";
}


/**
* 获取指定年级下的班级
* @param gradeId 年级编号
* @param response
* @throws IOException
*/
@RequestMapping(value="/gradeclass/{gradeId}", method=RequestMethod.GET)
public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId,
HttpServletResponse response) throws IOException {
logger.info("获取年级 "+gradeId+" 下的班级集合");

List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId);

String json = gson.toJson(classes);
response.getWriter().print(json);
}


/**
* 修改教师(班主任)工作状态
* @param status 是否为班主任标识
* @param teacherId 教师编号
*/
private String isChangeTeacherWork(int status, Integer teacherId) {
logger.info("修改教师 "+teacherId+" 的状态为 "+status);
teacher.setIsWork(status);
if (teacherId == null) {
logger.error("修改教师班主任状态 对应教师编号有误");
return "修改教师班主任状态 对应教师编号有误";
}
teacher.setTeacherId(teacherId);
int row = teacherInfoService.updateTeacherIsWork(teacher);
return null;
}

@RequestMapping("/stuCount")
public void getStudentCountForClass(
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
 *   返回学生密码,前台登录焦点离开密码框使用 JavaScript 判断
*
* @param studentAccount 学生登录账户
* @param response
* @throws IOException
*/
@RequestMapping("/validateLoginStudent")
public void validateLoginStudent(@RequestParam("studentAccount") String studentAccount,
HttpServletResponse response) throws IOException {
logger.info("学生账户 "+studentAccount+",尝试登录考试");

//获取需要登录的学生对象
StudentInfo student = studentInfoService.getStudentByAccountAndPwd(studentAccount);

if (student == null) {
logger.error("登录学生账户 "+studentAccount+" 不存在");
response.getWriter().print("n");
} else {
logger.error("登录学生账户 "+studentAccount+" 存在");
response.getWriter().print(student.getStudentPwd());
}
}

/**
* 学生登录考试
* @param student 登录学生
* @param request
* @return
*/
@RequestMapping(value="/studentLogin", method=RequestMethod.POST)
public ModelAndView studentLogin(StudentInfo student, HttpServletRequest request) {
ModelAndView model = new ModelAndView();
StudentInfo loginStudent = studentInfoService.getStudentByAccountAndPwd(student.getStudentAccount());
logger.info("学生 "+loginStudent+" 有效登录");
if(loginStudent == null || !student.getStudentPwd().equals(loginStudent.getStudentPwd())){
model.setViewName("reception/suc");
model.addObject("success", "密码错误");
return model;
}
request.getSession().setAttribute("loginStudent", loginStudent);

model.setViewName("reception/suc");
model.addObject("success", "登录成功");

return model;
}

/**
* 退出登录
* @param session
* @return


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