運行環境:jdk1.8、Mysql5.7、Tomcat8.5、IDEA/Eclipse
功能簡介:在線考試、歷史回顧、個人成績查詢等,
管理員和教師功能有:學院管理、班級管理、課程管理、教師、學生管理、統計分析、試卷試題管理、考試安排管理、歷史考試管理等






學生資訊控制層:
@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";
}
//修改編輯功能,先獲取該id得學生資訊
@RequestMapping("/{id}")
public String updateStudent(@PathVariable("id") Integer id,Model model){
Student student=studentService.getStudentById(id);
List<Classe> classes = classeMapper.queryAll();
model.addAttribute("classes",classes);
model.addAttribute("student",student);
return "student/studentEdit";
}
//更改學生資訊
@RequestMapping("/editStudent")
public String EditStudent(Student student){
studentService.EditStudent(student);
return "redirect:/student/getAllStudent";
}
//洗掉學生
@RequestMapping("/deleteStudent/{id}")
public String deleteStudent(@PathVariable("id") Integer id){
studentService.deleteById(id);
return "redirect:/student/getAllStudent";
}
}
登錄資訊控制層:
@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("/zhao")
public String zhao(){
return "stage/zhao";
}
}
試題控制層:
@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";
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/375993.html
標籤:其他
上一篇:顯示所有注冊用戶的帖子和關注
