package com.yuanlrc.online.exam.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.yuanlrc.online.exam.po.ClassInfo;
import com.yuanlrc.online.exam.po.ExamChooseInfo;
import com.yuanlrc.online.exam.po.ExamHistoryPaper;
import com.yuanlrc.online.exam.po.ExamPaperInfo;
import com.yuanlrc.online.exam.po.ExamSubjectMiddleInfo;
import com.yuanlrc.online.exam.po.GradeInfo;
import com.yuanlrc.online.exam.po.StudentInfo;
import com.yuanlrc.online.exam.po.SubjectInfo;
import com.yuanlrc.online.exam.service.ClassInfoService;
import com.yuanlrc.online.exam.service.ExamChooseInfoService;
import com.yuanlrc.online.exam.service.ExamHistoryPaperService;
import com.yuanlrc.online.exam.service.ExamPaperInfoService;
import com.yuanlrc.online.exam.service.ExamSubjectMiddleInfoService;
import com.yuanlrc.online.exam.service.StudentInfoService;
/**
*
* <p>Title: StudentInfoHandler</p>
* <p>Description: </p>
*/
@Controller
@SuppressWarnings("all")
public class StudentInfoHandler {
@Autowired
private StudentInfoService studentInfoService;
@Autowired
private ClassInfoService classInfoService;
@Autowired
private ExamSubjectMiddleInfoService examSubjectMiddleInfoService;
@Autowired
private ExamHistoryPaperService examHistoryPaperService;
@Autowired
private ExamChooseInfoService examChooseInfoService;
@Autowired
private ExamSubjectMiddleInfo esm;
@Autowired
private ClassInfo classInfo;
@Autowired
private ExamPaperInfo examPaper;
@Autowired
private GradeInfo grade;
@Autowired
private StudentInfo student;
@Autowired
private ExamPaperInfoService examPaperInfoService;
private Logger logger = Logger.getLogger(StudentInfoHandler.class);
/**
* 获取学生集合
* @param studentId 学生编号
* @param classId 班级编号
* @param gradeId 系部编号
* @param startPage 起始页 default=1
* @param pageShow 页容量 default=10
* @return
*/
@RequestMapping("/students")
public ModelAndView getCourses(@RequestParam(value = "studentId", required = false) Integer studentId,
@RequestParam(value = "classId", required = false) Integer classId,
@RequestParam(value = "gradeId", required = false) Integer gradeId,
@RequestParam(value="startPage", required=false, defaultValue="1") Integer startPage,
@RequestParam(value="pageShow", required=false, defaultValue="10") Integer pageShow ) {
logger.info("获取学生集合 classId="+classId+", gradeId="+gradeId+", startPage="+startPage+", pageShow="+pageShow);
ModelAndView model = new ModelAndView();
model.setViewName("/admin/student/students");
//查询条件处理
StudentInfo student = new StudentInfo();
if (studentId != null)
student.setStudentId(studentId);
if (classId != null) {
classInfo.setClassId(classId);
student.setClassInfo(classInfo);
}
if (gradeId != null) {
grade.setGradeId(gradeId);
student.setGrade(grade);
}
Map<String, Object> map = new HashMap<String, Object>();
//计算当前查询起始数据索引
int startIndex = (startPage-1) * pageShow;
map.put("student", student);
map.put("startIndex", startIndex);
map.put("pageShow", pageShow);
List<StudentInfo> students = studentInfoService.getStudents(map);
model.addObject("students", students);
//获取学生总量
int studentTotal = studentInfoService.getStudentTotal();
//计算总页数
int pageTotal = 1;
if (studentTotal % pageShow == 0)
pageTotal = studentTotal / pageShow;
else
pageTotal = studentTotal / pageShow + 1;
model.addObject("pageTotal", pageTotal);
model.addObject("pageNow", startPage);
return model;
}
/**
* 根据编号获取学生信息
* @param studentId
* @return
*/
@RequestMapping("/student/{studentId}")
public ModelAndView getCourseById(@PathVariable("studentId") Integer studentId) {
logger.info("获取学生 " + studentId);
ModelAndView model = new ModelAndView();
model.setViewName("/admin/student/studentedit");
StudentInfo student = studentInfoService.getStudentById(studentId);
model.addObject("student", student);
List<ClassInfo> classes = classInfoService.getClasses(null);
model.addObject("classes", classes);
return model;
}
/**
* 添加/修改学生信息
* @param studentId
* @param isUpdate 操作标识
* @param studentName
* @param studentAccount
* @param studentPwd
* @param classId
* @return
*/
@RequestMapping(value = "/student/student", method = RequestMethod.POST)
public String isUpdateOrAddCourse(
@RequestParam(value = "studentId", required = false) Integer studentId,
@RequestParam(value = "isupdate", required = false) Integer isUpdate,
@RequestParam(value = "studentName", required = false) String studentName,
@RequestParam("studentAccount") String studentAccount,
@RequestParam("studentPwd") String studentPwd,
@RequestParam("classId") Integer classId) {
StudentInfo student = new StudentInfo();
student.setStudentId(studentId);
student.setStudentName(studentName);
student.setStudentAccount(studentAccount);
student.setStudentPwd(studentPwd);
classInfo.setClassId(classId);
student.setClassInfo(classInfo);
if (isUpdate != null) {
logger.info("修改学生 " + student + " 的信息");
int row = studentInfoService.isUpdateStudent(student);
} else {
logger.info("添加学生 " + student + " 的信息");
int row = studentInfoService.isAddStudent(student);
}
return "redirect:/students";
}
/**
* 删除学生
* @param studentId
* @return
*/
@RequestMapping(value = "/student/{studentId}", method = RequestMethod.DELETE)
public String isDelTeacher(@PathVariable("studentId") Integer studentId) {
logger.info("删除学生 " + studentId);
int row = studentInfoService.isDelStudent(studentId);
return "redirect:/students";
}
/**
* 预添加学生
* @return
*/
@RequestMapping("/preAddStudent")
public ModelAndView preAddStudent() {
logger.info("预添加学生信息");
ModelAndView model = new ModelAndView();
model.setViewName("/admin/student/studentedit");
List<ClassInfo> classes = classInfoService.getClasses(null);
model.addObject("classes", classes);
return model;
}
/**
* 学生考试登录验证
*
* 此处验证并不合理 登录验证实现如下:
* 前台学生登录传入账户,后台根据账户获取学生密码
* 返回学生密码,前台登录焦点离开密码框使用 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="/stude
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
运行环境:jdk1.8、Mysql5.7、Tomcat8.5、IDEA/Eclipse 功能简介:在线考试、历史回顾、个人成绩查询等。 管理员和教师功能有:学院管理、班级管理、课程管理、教师、学生管理、统计分析、试卷试题管理、考试安排管理、历史考试管理等
资源详情
资源评论
资源推荐
收起资源包目录
Java项目:在线考试系统(java+SSM+mysql+JSP) (795个子文件)
file_manager_json.ashx 6KB
upload_json.ashx 3KB
UpLoad_Class.asp 15KB
file_manager_json.asp 6KB
JSON_2.0.4.asp 4KB
upload_json.asp 3KB
demo.asp 2KB
demo.aspx 2KB
org.eclipse.wst.common.component 483B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 147KB
bootstrap.css 143KB
bootstrap.min.css 118KB
ionicons.css 56KB
ionicons.min.css 50KB
ionicons.min.css 50KB
font-awesome.min.css 30KB
font-awesome.min.css 30KB
jquery-ui-1.9.2.custom.css 30KB
style.css 29KB
style.css 29KB
jquery-ui-1.9.2.custom.min.css 26KB
bootstrap-theme.css 26KB
animate.css 24KB
animate.css 24KB
zeroModal.css 23KB
bootstrap-theme.min.css 23KB
default.css 20KB
jedate.css 11KB
style_login.css 11KB
style_register.css 10KB
bootstrap-select.min.css 10KB
style1.css 8KB
magnific-popup.css 8KB
404.css 3KB
owl.carousel.min.css 3KB
owl.carousel.min.css 3KB
jeDate-test.css 3KB
qq.css 3KB
simple.css 2KB
_flaticon.css 2KB
prettify.css 960B
index.css 390B
form-public.css 387B
index.css 264B
style_classgrade.css 81B
public.css 31B
LitJSON.dll 49KB
fontawesome-webfont.eot 162KB
ionicons.eot 118KB
jedatefont.eot 2KB
static.gif 35KB
35.gif 13KB
42.gif 13KB
40.gif 10KB
18.gif 8KB
19.gif 8KB
11.gif 8KB
32.gif 7KB
49.gif 6KB
29.gif 6KB
97.gif 5KB
65.gif 5KB
31.gif 5KB
46.gif 5KB
57.gif 5KB
45.gif 5KB
8.gif 5KB
43.gif 4KB
33.gif 4KB
68.gif 4KB
26.gif 4KB
14.gif 4KB
7.gif 4KB
51.gif 4KB
10.gif 4KB
47.gif 4KB
72.gif 4KB
6.gif 3KB
94.gif 3KB
84.gif 3KB
41.gif 3KB
17.gif 3KB
9.gif 3KB
28.gif 3KB
50.gif 3KB
loading1.gif 3KB
95.gif 3KB
22.gif 3KB
27.gif 3KB
67.gif 3KB
90.gif 3KB
60.gif 3KB
loading.gif 3KB
58.gif 3KB
74.gif 2KB
25.gif 2KB
101.gif 2KB
54.gif 2KB
99.gif 2KB
共 795 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
beyondwild
- 粉丝: 9591
- 资源: 4892
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2