基于javaweb的在线考试系统(java+ssm+mysql+jsp)

基于javaweb的在线考试系统(java+ssm+mysql+jsp)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

20220519002720

20220519002721

20220519002722

20220519002724

20220519002725

20220519002726

基于javaweb+jsp的在线考试系统(java+SSM+mysql+JSP)

运行环境:jdk1.8、Mysql5.7、Tomcat8.5、IDEA/Eclipse

功能简介:在线考试、历史回顾、个人成绩查询等。

管理员和教师功能有:学院管理、班级管理、课程管理、教师、学生管理、统计分析、试卷试题管理、考试安排管理、历史考试管理等

在线考试控制层:

@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 Exams = examService.getAll();

model.addAttribute(“Exams”,Exams);

return “exam/examplan”;

@RequestMapping(“/toError”)

public String toError(Model model){

List Exams = examService.getAll();

model.addAttribute(“Exams”,Exams);

return “exam/error”;

@RequestMapping(“/tomError”)

public String tomError(Model model){

List Exams = examService.getAll();

model.addAttribute(“Exams”,Exams);

return “exam/merror”;

@RequestMapping(“/toHist/{id}”)

public String toHist(@PathVariable (“id”) Integer id,Model model){

List 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,HttpServletRequest request){

HttpSession session=request.getSession();

Student stu = (Student) session.getAttribute(“loger”);

// if() {

// Record record=new Record();

// record.setStudentId(stu.getStudentId());

// record.setPaperId(id);

List ss= recordService.queryAllExamById(stu.getStudentId());

for (int i = 0; i < ss.size(); i++) {

if(ss.get(i).getPaperId() ==id ) {

return “redirect:/exam/tomError”;

// }

List 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 questionPapers = paperService.paperQueryALlQuestionByIdOrderByType(paperId);

List ans=new ArrayList<>();

List 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) {

return “redirect:/exam/toError”;

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(ans==null) {

break;

//若为单选题则正确+单选题分数

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))){

score+=qb.getPaper().getScoreChe();

y++;

b++;

k++;

}else {

if(ans.get(k).equals(RightAns.get(k))){

score+=qb.getPaper().getScoreJug();

y++;

c++;

k++;

int scoreSin1 = questionPapers.get(0).getPaper().getScoreSin();

int scoreChe1 = questionPapers.get(0).getPaper().getScoreChe();

int scoreJug1 = questionPapers.get(0).getPaper().getScoreJug();

int bool=recordService.queryBooleanToscore(paperId);

if (bool==0){

totalScore=scoreSin1a+scoreChe1b+scoreJug1*c; //得到每张试卷总分

Toscore toscore=new Toscore();

toscore.setPaperId(paperId);

toscore.setToscore(totalScore);

recordService.AddToScore(toscore);

//保存答题记录

String answer = String.join(“,”, ans);

Paper paper = paperService.queryPaperNameById(paperId);

String paperName = paper.getPaperName();

Double recordAcc=y/k;

int recordScore=score;

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 Exams = examService.getAllS();

model.addAttribute(“Exams”,Exams);

return “exam/backexamlist”;

//去往考试添加页面

@RequestMapping(“/toAddExam”)

public String toAddExam(Model model){

List 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”, " ");

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}”)

public String toEditExam(@PathVariable (“id”) Integer id,Model model){

examService.deleteById(id);

return “redirect:/exam/getAllExam”;

学生管理控制层:

@Controller

@RequestMapping(“/student”)

public class StudentController {

@Autowired

private ClasseMapper classeMapper;

@Autowired

private StudentService studentService;

//查看所有学生

@RequestMapping(“/getAllStudent”)

public String getAllStudent(Model model){

List 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 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

@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 questionCourses=questionService.queryAllCourse();

questionCourses.add(new Question(“bug”,“all”));

List 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 questionids=paperService.queryALlQuestionId();

List quesIds=new ArrayList<>();

for(Question qid:questionids){

quesIds.add(qid.getQuestionId());

model.addAttribute(“quesIds”,quesIds);

PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据

List questions = questionService.getAll(question);

PageInfo pageInfo = new PageInfo(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 questionCourses=questionService.queryAllCourse();

List 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 questionCourses=questionService.queryAllCourse();

List 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”;


  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、项目简介本课程演示的是一套基于SSM实现的在线考试系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。课程包含:1. 项目源码、项目文档、数据库脚本、软件工具等所有资料2. 带你从零开始部署运行本套系统3. 该项目附带的源码资料可作为毕设使用4. 提供技术答疑二、技术实现后台框架:Spring、SpringMVC、MyBatisUI界面:JSP、jQuery 、BootStrap数据库:MySQL 三、系统功能该在线考试系统基于B/S架构,采用SSM框架,运用JSP网页开发技术,并结合MySQL数据库,搭建一个高效、便捷的网络考试平台。 ​本系统分为前台考试模块和后台管理模块,包含学生、教师和管理员共三个角色,功能如下: 1.前台考试模块 学生注册、学生登陆、考试中心、参加考试、查看考试成绩、查看历史考卷、查看个人信息等功能。 2.后台管理模块 系统后台登陆、学生管理、教师管理、班级管理、年级管理、科目管理、试题管理、添加试题、导入试题、试卷管理、生成试卷、考试安排管理、添加考试计划、查看以往考试信息、考试成绩统计等功能。 教师主要完成试卷管理、试题管理、考试计划管理等一些与考试相关的操作;管理员具有最高权限,可以管理学生、老师、试题、题库、考试等信息,同时也可以与老师一样进行考试相关的操作。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 四、项目截图1)前台首面 2)历史试卷回顾 3)系统后台管理 4)试卷管理 5)试题管理  更多Java毕设项目请关注【毕设系列课程】https://edu.csdn.net/lecturer/2104   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值