基于javaweb+mysql的springboot学生在线考试管理系统(java+springboot+thymleaf+bootstrap+html+mysql)

基于javaweb+mysql的springboot学生在线考试管理系统(java+springboot+thymleaf+bootstrap+html+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot学生在线考试管理系统(java+springboot+thymleaf+bootstrap+html+mysql)

项目介绍

学生在线考试管理系统,分为管理员与老师、学生三种角色;

教师/管理员主要功能:

  1. 学生管理:查看所有学生的基本信息,管理员则还可以对学生的基本信息(除了账号和密码外)进行修改和对学生的删除操作。

  2. 教师管理:查看所有教师的基本信息(除密码外),并修改自己的基本信息,而管理员除了以上功能还可以对所有教师的所有信息进行修改删除操作,也能添加教师。

  3. 班级管理:要能对班级的信息进行管理。

  4. 试题管理:首先要能对试题进行增删改查,并且应该对试题进行不同科目的分类以方便试卷的生成。

  5. 试卷管理:试卷的主体是试题,然后用户能对试卷进行增删改查操作。

  6. 考试管理:可以选择相应的试卷设置时间进行考试。考试一旦生成后无法修改。

  7. 记录管理:查看试卷的考试情况;以班级为单位根据班级考试情况生成每个考试的不同班级的及格率以方便排名。

学生主要功能:

  1. 学生注册:学生可以通过注册一个账号,然后可以用于登陆系统。

  2. 参与考试:学生要可以参与考试

  3. 查询历史考试情况:学生在考完试后系统便会记录它的考试得分,进行准确率的分析,并提供试卷详情查看,且这此的考试信息会存入数据库中以便于下次查看。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可

4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;

5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

6.数据库:MySql 5.7版本;

技术栈

  1. 后端:SpringBoot+Mybatis

  2. 前端:Thymleaf+BootStrap+Html

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

  1. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

  2. 访问地址:http://localhost:8080


@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";
    }

    //试卷去修改页面

    //从其他页面跳转到home
    @RequestMapping("/toHome")
    public String tohome(){
        return "redirect:/indexprexam";
    }

    //来到对应考试页面
    @RequestMapping("/toDoExam/{id}")
    public String toDoExam(@PathVariable ("id") Integer id,Model model,String examId){
        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());
                for(String s:parameters){
                    parameter+=s;
                }
            }else {
                parameter = request.getParameter("optionsSelect" + qb.getQuestionId());
            }
            ans.add(parameter);
        }
        //核对答案得到成绩
        int k=0;    //哨兵
        Double y=0.0;    //正确数
        int score=0;    //得分
                //及格人数默认>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
        List<Exam> examList = examService.getAll();
        System.err.println(examList);
        model.addAttribute("examList",examList);
        return "exam/examplan";
    }

    @RequestMapping("/toHist/{id}")
    public String toHist(@PathVariable ("id") Integer id,Model model){
        List<Record> records=recordService.queryAllExamById(id);
        model.addAttribute("records",records);
        return "exam/histplan";
    }

    //从其他页面跳转到home
    @RequestMapping("/toHome")
    public String tohome(){
        return "redirect:/indexprexam";
    }

    //来到对应考试页面
    @RequestMapping("/toDoExam/{id}")
    public String toDoExam(@PathVariable ("id") Integer id,Model model,String examId){
        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());
                for(String s:parameters){
                    parameter+=s;
                }
            }else {
                parameter = request.getParameter("optionsSelect" + qb.getQuestionId());
            }
            ans.add(parameter);
        }
        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){
        //找到试卷所有未分配的试题
        PapIdQuesCourse papIdQuesCourse=new PapIdQuesCourse();
        papIdQuesCourse.setPapid(papid);
        papIdQuesCourse.setQuestionCourse(questionCourse);
    }

    //显示所有班级记录
    @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);
                if (claName ==null){
                    log.error("找不到id为"+claId+"的班级");
                    continue;
                }
                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;

                ClaAcc claAcc=new ClaAcc();
                claAcc.setExamName(exaName);
                claAcc.setClaName(claName.getClasseName());
        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());
                for(String s:parameters){
                    parameter+=s;
                }
            }else {
                parameter = request.getParameter("optionsSelect" + qb.getQuestionId());
            }
            ans.add(parameter);
        }
        //核对答案得到成绩
        int k=0;    //哨兵
        Double y=0.0;    //正确数
        int score=0;    //得分
        int a=0;        //记录单选题个数
        int b=0;        //记录多选题个数
        int c=0;        //记录判断题个数
        int totalScore=0;
        for (QuestionPaper qb:questionPapers){
            //若为单选题则正确+单选题分数
            if(qb.getQuestion().getQuestionType().equals("x")){
                if(ans.get(k).equals(RightAns.get(k))){
                    score+=qb.getPaper().getScoreSin();
                    y++;
                }
                a++;
                k++;
            }else if(qb.getQuestion().getQuestionType().equals("y")){
                if(ans.get(k).equals(RightAns.get(k))){
        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());
        }
        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";
    }

//试题去修改页面

@Controller
public class LoginController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private PaperService paperService;
    @Autowired
    private ClasseService classeService;
    @Autowired
    private RecordService recordService;
    @RequestMapping("/")
    public String view(Model model){
        //查询所有用户
        int teas=teacherService.queryCountAll();
        int stus=studentService.queryCOuntALlstu();
        int alllogers=teas+stus;
        //统计试题
        int allQues=questionService.queryCountAllQues();
        //统计试卷
        int allPaps=paperService.queryCountALlPaps();
        model.addAttribute("allPaps",allPaps);
        model.addAttribute("allQues",allQues);
        model.addAttribute("alllogers",alllogers);
        return "stage/prexam";
    }
    //后台切换到前台登录
    @RequestMapping("/foreLogin")
    public String foreLogin(){
        return "stage/login";
    }
    //前台切换到后台登录
    @RequestMapping("/backLogin")
    public String backLogin(){
        return "stage/loginx";
    }

    //后台教师登录验证
    @ResponseBody
    @RequestMapping("/backLogin/check")
    public Object backCheck(Teacher teacher, HttpServletRequest request){

@Controller
public class LoginController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private PaperService paperService;
    @Autowired
    private ClasseService classeService;
    @Autowired
    private RecordService recordService;
    @RequestMapping("/")
    public String view(Model model){
        //查询所有用户
        int teas=teacherService.queryCountAll();
        int stus=studentService.queryCOuntALlstu();
        int alllogers=teas+stus;
        //统计试题
        int allQues=questionService.queryCountAllQues();
        //统计试卷
        int allPaps=paperService.queryCountALlPaps();
        model.addAttribute("allPaps",allPaps);
        model.addAttribute("allQues",allQues);
        model.addAttribute("alllogers",alllogers);
        return "stage/prexam";
    }
    //后台切换到前台登录
    @RequestMapping("/foreLogin")
    public String foreLogin(){
        return "stage/login";
        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";
    }

    //试题删除
    @RequestMapping("/deleteQuestion/{id}")
    public String deleteQuestionById(@PathVariable("id") Integer id){
        questionService.deleteQuestionById(id);
        return "redirect:/question/getAllQuestion";
    }

}

    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);
        model.addAttribute("teachers",teachers);
        model.addAttribute("classe",classe);
        return "classe/classeEdit";
    }

//修改具体操作
    @RequestMapping("/EditClasse")
    public String EditClasse(Classe classe){
        classeService.editClasse(classe);
        return "redirect:/classe/getAllClasse";
    }

//班级删除
    @RequestMapping("/deleteClasse/{id}")
    public String deleteClasseById(@PathVariable("id") Integer id){
        classeService.deleteClasseById(id);
        return "redirect:/classe/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);
        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);
            questionPapers.add(questionPaper);
        }
        int nums=questionService.AddAllQues(questionPapers);
        return "redirect:/paper/toManagerQuestion/"+papid;
    }

    @RequestMapping("/deleteAllQues/{id}")
    public String deleteAllQues(@PathVariable ("id") Integer papid,Integer []ques){
        int nums=questionService.queryIdByPapQue(ques);
        return "redirect:/paper/toManagerQuestion/"+papid;
    }
}
    }

}

@Controller
public class LoginController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private PaperService paperService;
    @Autowired
    private ClasseService classeService;
    @Autowired
    private RecordService recordService;
    @RequestMapping("/")
    public String view(Model model){
        //查询所有用户
        int teas=teacherService.queryCountAll();
        int stus=studentService.queryCOuntALlstu();
        int alllogers=teas+stus;
        //统计试题
        int allQues=questionService.queryCountAllQues();
        //统计试卷
        int allPaps=paperService.queryCountALlPaps();
        model.addAttribute("allPaps",allPaps);
        model.addAttribute("allQues",allQues);
        model.addAttribute("alllogers",alllogers);
        return "stage/prexam";
    }
    //后台切换到前台登录
    @RequestMapping("/foreLogin")
    public String foreLogin(){
    @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
public class LoginController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private PaperService paperService;
    @Autowired
    private ClasseService classeService;
    @Autowired
    private RecordService recordService;
    //教师去修改页面
    @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";
    }

}

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private ClasseMapper classeMapper;
    @Autowired
    private StudentService studentService;
    //查看所有学生
    @RequestMapping("/getAllStudent")
    public String getAllStudent(Model model){
        List<Student> students = studentService.getAll();
        model.addAttribute("students",students);
        return "student/studentList";
    }

    }
    @RequestMapping("/deleteExam/{id}")
    public String toEditExam(@PathVariable ("id") Integer id,Model model){
        examService.deleteById(id);
        return "redirect:/exam/getAllExam";
    }
}

@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";
    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查找试卷和答题记录
        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);
                if (claName ==null){
                    log.error("找不到id为"+claId+"的班级");
                    continue;
                }
                RecordExam recordExam=new RecordExam();
                recordExam.setClaId(claId);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值