作者主页:Java毕设网
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
一、相关文档
作为考试系统,为了更好的对系统进行运行以及维护,采用用户权限判断验证的方式,对该平台进行系统性的管控。然后通过用户进行登录注册,将用户信息提交到数据库并进行比对,通过该用户的身份权限来控制该平台为用户展示所需的界面信息。
学生作为该考试平台的主体,是该平台的重要角色之一。该模块是在用户进行正确登录之后,系统对于该用户的权限判断为学生时所进入的功能模块。通过上述的需求分析,学生模块主要的功能是参加考试,以及自己参与的考试记录。
教师作为该平台的主要角色之一,部分涵盖了管理员的权限,教师与管理员共同使用同一可视化界面,在前端对该教师的权限进行判断,然后分别展示所涵盖的功能,对于无权限操作的功能不予展示或者进行错误信息提示。
二、项目介绍
学生在线考试管理系统,分为管理员与老师、学生三种角色;
教师/管理员主要功能:
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/8.0等版本均可;
四、技术栈
1. 后端:SpringBoot+Mybatis
2. 前端:Thymleaf+BootStrap+Html
五、使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 访问地址:http://localhost:8080
六、运行截图
七、相关代码
登录管理控制器
@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){
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);
}
return result;
}
//前台登录到展示页面
@RequestMapping("/indexprexam")
public String indexprexam(){
return "stage/prexamed";
}
//退出系统
@RequestMapping(value = {"*/logout","/logout","teacher/logout"})
public String logout(HttpSession session) {
//session里可能不止存放一个数据,移除麻烦,所以让其失效跟直接
session.invalidate();
return "redirect:/";
}
//学生注册
//去添加页面
@RequestMapping("/prexam/toAddStudent")
public String toAddStudent(Model model){
List<Classe> allClasees = classeService.getAll();
model.addAttribute("allClasees",allClasees);
return "stage/studentAdd";
}
//添加具体操作
@RequestMapping("/prexam/AddStudent")
public String AddStudent(Student student){
studentService.AddStudent(student);
return "redirect:/foreLogin";
}
@RequestMapping("/about")
public String help(){
return "stage/about";
}
}
试题管理控制器
@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());
}
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";
}
//试题删除
@RequestMapping("/deleteQuestion/{id}")
public String deleteQuestionById(@PathVariable("id") Integer id){
questionService.deleteQuestionById(id);
return "redirect:/question/getAllQuestion";
}
}