基于javaweb+mysql的springboot前台+后台在线考试系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot前台+后台在线考试系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
一、项目简述
本系统主要实现的功能有: 学生以及老师的注册登录,在线考试,错题查询,学生管理,问题管理,错题管理,错题查询,分数查询,试卷管 理,人工组卷。自动组卷,教师,班级,统计等等管理功能。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等
double setToscore=toscore*0.6;
recordExam.setToscore(setToscore);
//对应每一个班级,查询考试人数和及格人数
allScore=recordService.queryAllScore(recordExam);
//及格人数默认>60***
accScore=recordService.queryAccScore(recordExam);
double accre=(double)accScore/allScore;
//四舍五入保留2位
double acc = (double) Math.round(accre * 100) / 100;
ClaAcc claAcc=new ClaAcc();
claAcc.setExamName(exaName);
claAcc.setClaName(claName.getClasseName());
claAcc.setToscPer(allScore);
claAcc.setAcscPer(accScore);
claAcc.setAcc(acc);
//每个对象添加到list
claAccRes.add(claAcc);
}
}
model.addAttribute("claAccRes",claAccRes);
return "record/claAcc";
}
}
@Controller
@RequestMapping("/classe")
public class ClasseController {
@Autowired
private ClasseService classeService;
@Autowired
private TeacherService teacherService;
//查看所有班级
@RequestMapping("/getAllClasse")
//用于条件查询题库中尚未分配的题有多少道
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);
model.addAttribute("questionCourses",questionCourses);
return "paper/RandomQuestion";
}
//指定试卷id和课程随机生成试题
@RequestMapping("/RandomADDQuestion/{id}")
public String RandomADDQuestion(@PathVariable ("id") Integer papid,String questionCourse,int QuesNums){
//找到试卷所有未分配的试题
PapIdQuesCourse papIdQuesCourse=new PapIdQuesCourse();
papIdQuesCourse.setPapid(papid);
if(!questionCourse.equals("all")) {
papIdQuesCourse.setQuestionCourse(questionCourse);
}
List<Question> questionsNodivIds=questionService.queryAllQueIdNotInPaperById(papIdQuesCourse);
List<Integer> list=new ArrayList<>();
for(Question question:questionsNodivIds){
list.add(question.getQuestionId());
}
Collections.shuffle(list);
List<QuestionPaper> questionPapers=new ArrayList<>();
for(int i=0;i<QuesNums;i++){
QuestionPaper questionPaper=new QuestionPaper(list.get(i),papid);
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());
}
}
model.addAttribute("quesds",quesds);
//分页
PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据
List<Question> questions = questionService.getAll(question);
PageInfo<Question> pageInfo = new PageInfo<Question>(questions);
Paper paperName=paperService.queryPaperNameById(paperId);
model.addAttribute("paperName",paperName.getPaperName());
model.addAttribute("questionCourseresRes",questionCourseresRes);
model.addAttribute("questionTypesRes",questionTypesRes);
//试卷删除
@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());
}
@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);
model.addAttribute("questionCourses",questionCourses);
return "paper/RandomQuestion";
}
//指定试卷id和课程随机生成试题
@RequestMapping("/RandomADDQuestion/{id}")
public String RandomADDQuestion(@PathVariable ("id") Integer papid,String questionCourse,int QuesNums){
//找到试卷所有未分配的试题
}
}
@Controller
@RequestMapping("/record")
public class RecordController {
@Autowired
RecordService recordService;
@Autowired
PaperService paperService;
@Autowired
ClasseService classeService;
//获取所有记录
@RequestMapping("/getAllRecord")
public String getAllRecord(Model model){
List<Record> records=recordService.queryAll();
model.addAttribute("records",records);
return "record/RecordList";
}
//删除记录
@RequestMapping("/deleteRecore/{id}")
public String deleteRecore(@PathVariable ("id") Integer id){
recordService.deleteById(id);
return "redirect:/record/getAllRecord";
}
//根据记录id获取试卷详情
@RequestMapping("/toShowExamHist/{id}")
public String toShowExamHist(@PathVariable ("id")Integer id,Model model){
//通过记录id查找试卷和答题记录
// if() {
// Record record=new Record();
// record.setStudentId(stu.getStudentId());
// record.setPaperId(id);
List<Record> ss= recordService.queryAllExamById(stu.getStudentId());
for (int i = 0; i < ss.size(); i++) {
if(ss.get(i).getPaperId() ==id ) {
return "redirect:/exam/tomError";
}
}
// }
List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(id);
int exId=Integer.parseInt(examId);
Exam examById = examService.getExamById(exId);
Paper paperName = paperService.queryPaperNameById(examById.getPaperId());
model.addAttribute("paperName",paperName);
model.addAttribute("examById",examById);
model.addAttribute("questionPapers",questionPapers);
return "exam/doExam";
}
//提交试卷
@RequestMapping("/submitExam")
public String submitExam(Integer paperId, Integer studentId, HttpServletRequest request){
List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(paperId);
List<String> ans=new ArrayList<>();
List<String> RightAns=new ArrayList<>();
for (QuestionPaper qb:questionPapers){
RightAns.add(qb.getQuestion().getQuestionOpright());
String parameter="";
String []parameters;
if(qb.getQuestion().getQuestionType().equals("y")){
parameters= request.getParameterValues("optionsSelect" + qb.getQuestionId());
if(parameters!=null) {
for(String s:parameters){
parameter+=s;
}
}
}else {
parameter = request.getParameter("optionsSelect" + qb.getQuestionId());
if(parameter==null) {
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());
}
}
model.addAttribute("quesds",quesds);
//分页
PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据
List<Question> questions = questionService.getAll(question);
PageInfo<Question> pageInfo = new PageInfo<Question>(questions);
Paper paperName=paperService.queryPaperNameById(paperId);
model.addAttribute("paperName",paperName.getPaperName());
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;
}
}
@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";
}
@RequestMapping("/toError")
public String toError(Model model){
List<Exam> Exams = examService.getAll();
model.addAttribute("Exams",Exams);
return "exam/error";
}
@RequestMapping("/tomError")
public String tomError(Model model){
List<Exam> Exams = examService.getAll();
model.addAttribute("Exams",Exams);
return "exam/merror";
}
@RequestMapping("/toHist/{id}")
Integer papid=recordService.queryByRecordId(id);
String answers=recordService.queryAnsByRecordId(id);
//原始试卷
List<QuestionPaper> questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(papid);
//提交过的答案
List<String> ans = Arrays.asList(answers.split(","));
model.addAttribute("questionPapers",questionPapers);
model.addAttribute("ans",ans);
return "record/showExamHist";
}
//显示所有班级记录
@RequestMapping("/showClaAcc")
public String showClaAcc(Model model){
//查询所有测试名称
List<Record> records=recordService.queryAllExam();
List<ClaAcc> claAccRes=new ArrayList<>();
//按照测试名称查询所有班级
for(Record rec:records){
//通过记录对应考试paperid查找总分***
int paperid=rec.getPaperId();
int toscore=recordService.queryToscore(paperid);
//记录考试名
String exaName=rec.getRecordName();
List<Classe> clas=recordService.queryAllClass(exaName);
//初始化所有人和及格人数
int allScore=0;
int accScore=0;
for(Classe cla:clas){
int claId=cla.getClasseId();
//班级信息
Classe claName=classeService.queryClaNameById(claId);
RecordExam recordExam=new RecordExam();
recordExam.setClaId(claId);
recordExam.setExaName(exaName);
double setToscore=toscore*0.6;
recordExam.setToscore(setToscore);
//对应每一个班级,查询考试人数和及格人数
allScore=recordService.queryAllScore(recordExam);
//及格人数默认>60***
accScore=recordService.queryAccScore(recordExam);
double accre=(double)accScore/allScore;
//四舍五入保留2位
double acc = (double) Math.round(accre * 100) / 100;
@Controller
@RequestMapping("/question")
public class QuestionController {
@Autowired
private QuestionService questionService;
@Autowired
private TeacherService teacherService;
@Autowired
private PaperService paperService;
//查看所有试题 pagesize控制每页数据条数
@RequestMapping("/getAllQuestion")
public String getAllQuestion(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.queryALlQuestionId();
List<Integer> quesIds=new ArrayList<>();
for(Question qid:questionids){
quesIds.add(qid.getQuestionId());
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);
model.addAttribute("questionCourses",questionCourses);
return "paper/RandomQuestion";
}
//指定试卷id和课程随机生成试题
@RequestMapping("/RandomADDQuestion/{id}")
public String RandomADDQuestion(@PathVariable ("id") Integer papid,String questionCourse,int QuesNums){
//找到试卷所有未分配的试题
PapIdQuesCourse papIdQuesCourse=new PapIdQuesCourse();
papIdQuesCourse.setPapid(papid);
if(!questionCourse.equals("all")) {
papIdQuesCourse.setQuestionCourse(questionCourse);
}
List<Question> questionsNodivIds=questionService.queryAllQueIdNotInPaperById(papIdQuesCourse);
List<Integer> list=new ArrayList<>();
for(Question question:questionsNodivIds){
list.add(question.getQuestionId());
}
Collections.shuffle(list);
List<QuestionPaper> questionPapers=new ArrayList<>();
model.addAttribute("quesIds",quesIds);
PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据
List<Question> questions = questionService.getAll(question);
PageInfo<Question> pageInfo = new PageInfo<Question>(questions);
model.addAttribute("questionCourseresRes",questionCourseresRes);
model.addAttribute("questionTypesRes",questionTypesRes);
model.addAttribute("questionTypes",questionTypes);
model.addAttribute("questionCourses",questionCourses);
model.addAttribute("pageInfo",pageInfo);
return "question/questionList";
}
//试题添加或者修改操作,先去添加页面
@RequestMapping("/toAddQuestion")
public String toAddQuestion(Model model){
List<Question> questionCourses=questionService.queryAllCourse();
List<Question> questionTypes=questionService.queryAllType();
model.addAttribute("questionTypes",questionTypes);
model.addAttribute("questionCourses",questionCourses);
return "question/questionAdd";
}
//添加具体操作
@RequestMapping("/addQuestion")
public String addQuestion(Question question){
questionService.addQuestion(question);
return "redirect:/question/getAllQuestion";
}
//试题去修改页面
@RequestMapping("/toEditQuestion/{id}")
public String toEditQuestion(@PathVariable("id") Integer id,Model model){
List<Question> questionCourses=questionService.queryAllCourse();
List<Question> questionTypes=questionService.queryAllType();
Question question=questionService.getQuestionById(id);
model.addAttribute("questionTypes",questionTypes);
model.addAttribute("questionCourses",questionCourses);
model.addAttribute("question",question);
return "question/questionEdit";
}
//修改具体操作
@RequestMapping("/EditQuestion")
public String EditQuestion(Question question){
questionService.editQuestion(question);
return "redirect:/question/getAllQuestion";
}
//试题删除
@Controller
@RequestMapping("/paper")
public class PaperController {
@Autowired
private PaperService paperService;
@Autowired
private ClasseService classeService;
@Autowired
private QuestionService questionService;
//查看所有试卷
@RequestMapping("/getAllPaper")
public String getAllPaper(Model model){
List<Paper> papers = paperService.getAll();
//查找classe表中已存在的试卷,将用于表单试卷是否可以删除
model.addAttribute("papers",papers);
return "paper/paperList";
}
//试卷添加或者修改操作,先去添加页面
@RequestMapping("/toAddPaper")
public String toAddPaper(){
return "paper/paperAdd";
}
//添加具体操作
@RequestMapping("/addPaper")
public String addPaper(Paper paper){
paperService.addPaper(paper);
return "redirect:/paper/getAllPaper";
}
return "question/questionAdd";
}
//添加具体操作
@RequestMapping("/addQuestion")
public String addQuestion(Question question){
questionService.addQuestion(question);
return "redirect:/question/getAllQuestion";
}
//试题去修改页面
@RequestMapping("/toEditQuestion/{id}")
public String toEditQuestion(@PathVariable("id") Integer id,Model model){
List<Question> questionCourses=questionService.queryAllCourse();
List<Question> questionTypes=questionService.queryAllType();
Question question=questionService.getQuestionById(id);
model.addAttribute("questionTypes",questionTypes);
model.addAttribute("questionCourses",questionCourses);
model.addAttribute("question",question);
return "question/questionEdit";
}
//修改具体操作
@RequestMapping("/EditQuestion")
public String EditQuestion(Question question){
questionService.editQuestion(question);
return "redirect:/question/getAllQuestion";
}
//试题删除
@RequestMapping("/deleteQuestion/{id}")
public String deleteQuestionById(@PathVariable("id") Integer id){
questionService.deleteQuestionById(id);
return "redirect:/question/getAllQuestion";
}
}
@Controller
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@Autowired
private ClasseService classeService;
//查看所有教师
@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){
@Controller
@RequestMapping("/question")
public class QuestionController {
@Autowired
private QuestionService questionService;
@Autowired
private TeacherService teacherService;
@Autowired
private PaperService paperService;
//查看所有试题 pagesize控制每页数据条数
@RequestMapping("/getAllQuestion")
public String getAllQuestion(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();
public String backLogin(){
return "stage/loginx";
}
//后台教师登录验证
@ResponseBody
@RequestMapping("/backLogin/check")
public Object backCheck(Teacher teacher, HttpServletRequest request){
AjaxResult result=new AjaxResult();
HttpSession session=request.getSession();
Teacher teac=teacherService.check(teacher);
if(teac!=null){
session.setAttribute("logerd",teac);
result.setSuccess(true);
}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);
}