运行环境:jdk1.8、Mysql5.7、Tomcat8.5、IDEA/Eclipse
功能简介:在线考试、历史回顾、个人成绩查询等。
管理员和教师功能有:学院管理、班级管理、课程管理、教师、学生管理、统计分析、试卷试题管理、考试安排管理、历史考试管理等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
@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();
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("/getAllExam")
public String getAllExam(Model model){
List<Exam> Exams = examService.getAllS();
model.addAttribute("Exams",Exams);
return "exam/backexamlist";
}
//去往考试添加页面
@RequestMapping("/toAddExam")
public String toAddExam(Model model){
List<Paper> papers = paperService.getAll();
model.addAttribute("papers",papers);
return "exam/AddExam";
}
//添加操作
@RequestMapping("/addExam")
public String addExam(Exam exam, String examBegins,String examEnds) throws ParseException {
String t1 = examBegins.replace("T", " ");
String t2 = examEnds.replace("T", " ");
record.setRecordScore(recordScore);
recordService.addRecord(record);
return "redirect:/exam/toExam";
}
/**
* 考试后台
* */
//查看所有考试安排后台
@RequestMapping("/getAllExam")
public String getAllExam(Model model){
List<Exam> Exams = examService.getAllS();
model.addAttribute("Exams",Exams);
return "exam/backexamlist";
}
//去往考试添加页面
@RequestMapping("/toAddExam")
public String toAddExam(Model model){
List<Paper> papers = paperService.getAll();
model.addAttribute("papers",papers);
return "exam/AddExam";
}
//添加操作
//默认查询所有
questionCourseresRes="all";
}else {
questionCourseresRes=questionCourseBef;
}
//若是第一次查询则用上次提交的表单中的类型、课程,若是第二次查询则延用上次类型
String questionTypeBef=question.getQuestionType();
String questionTypesRes="";
if(questionTypeBef==null){
//默认查询所有
questionTypesRes="k";
}else {
questionTypesRes=questionTypeBef;
}
List<Question> questionids=paperService.queryALlQuestionId();
}
//添加操作
@RequestMapping("/addExam")
public String addExam(Exam exam, String examBegins,String examEnds) throws ParseException {
String t1 = examBegins.replace("T", " ");
String t2 = examEnds.replace("T", " ");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date begin = sdf.parse(t1);
Date end = sdf.parse(t2);
exam.setExamBegin(begin);
exam.setExamEnd(end);
examService.AddExam(exam);
return "redirect:/exam/getAllExam";
}
@RequestMapping("/deleteExam/{id}")
Record record=new Record();
record.setRecordName(paperName);
record.setStudentId(studentId);
record.setPaperId(paperId);
record.setRecordAnswer(answer);
record.setRecordAcc(recordAcc);
record.setRecordScore(recordScore);
recordService.addRecord(record);
return "redirect:/exam/toExam";
}
/**
* 考试后台
* */
//查看所有考试安排后台
@RequestMapping("/getAllExam")
public String getAllExam(Model model){
List<Exam> Exams = examService.getAllS();
model.addAttribute("Exams",Exams);
return "exam/backexamlist";
}
//去往考试添加页面
@RequestMapping("/toAddExam")
public String toAddExam(Model model){
List<Paper> papers = paperService.getAll();
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("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;
}
// }
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());