• 基于SSM实现前后端分离在线考试管理系统


    作者主页:编程指南针

    作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

    主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

    文末获取源码 

    项目编号:BS-XX-105

    前言:

    互联网的普及给人们带来的便利不需多说。因此如果把题库及试卷管理系统与互联网结合起来,利用My Eclipse编程软件建设题库及试卷管理系统,实现题库及试卷管理系统的网络化。则对于进一步提高教学发展定能起到不少的促进作用。

    题库及试卷管理系统能够通过互联网得到广泛的、全面的宣传,让尽可能多的学校了解和熟知学校的题库及试卷管理系统服务等,不仅为学校提供了服务,而且也推广了自己,让更多的学生了解自己。对于学校而言,若拥有自己的题库及试卷管理系统,通过题库及试卷管理系统让学校的宣传、营销提上一个新台阶,同时提升了学校形象。

    根据本系统的研究现状和发展趋势,系统从需求分析、结构设计、数据库设计,在到系统实现,分别为前端实现和后端实现。论文内容从系统描述、系统分析、系统设计、系统实现、系统测试来阐述系统的开发过程。本系统力求结合实际找出一种切实可行的开发方案,经过反复研究和学习,借助My Eclipse编程软件、SSM技术、MySQL数据库和Tomcat服务器来完成系统的所有功能,最后进行系统测试,来检测系统的权限和漏洞,从而将系统完善,达到符合标准。

    一,项目简介

    本项目主要实现SSM开发框架实现在线考试管理系统,采用前后端分离的方式开发实现,基于接口实现前后端开发对接,后端服务系统主要实现的管理功能有:试题管理、试卷管理、考试管理、用户管理、数据字典管理、系统设置管理。前端用户服务实现的功能有:试题练习、在线考试、会员中心、统计知识掌握情况、统计分析各种考试数据等功能。整体功能比较强大,也比较完整。

    根据前面的各项设计分析,按照系统开发的基本理念对系统进行分解,从模块上主要可分为用户模块和管理员模块。

    用户模块只要是让普通用户使用,包括题库及试卷管理,成绩查询等功能,管理员模块只要是让管理员使用,包括学生信息管理、教师信息管理、试卷管理等功能,可以对数据进行添加、删除、修改及查询等操作。

    系统总体功能结构图如下图所示。

    根据前面的各项设计分析,按照系统开发的基本理念对系统进行分解,从模块上主要可分为用户模块和管理员模块。

    用户模块只要是让普通用户使用,包括题库及试卷管理,成绩查询等功能,管理员模块只要是让管理员使用,包括学生信息管理、教师信息管理、试卷管理等功能,可以对数据进行添加、删除、修改及查询等操作。

    系统总体功能结构图如下图所示。

    二,环境介绍

    语言环境:Java:  jdk1.8

    数据库:Mysql: mysql5.7

    应用服务器:Tomcat:  tomcat8.5.31

    开发工具:IDEA或eclipse

    后台开发技术:SSM框架+SpringSecurity安全框架

    前台开发技术:Bootstrap+Ajax

    三,系统展示

    后台管理界面:

    管理首页

    试题管理

    试题添加

    试卷管理

    创建试卷

    考试管理

    用户管理

    通用数据管理

    系统设置

    教师登陆系统

    试卷管理

    前端用户服务系统

    试题练习

    答题模式

    背题模式

    在线考试

    在线考试

    会员中心

    个人设置

    四,核心代码展示

    1. package com.examstack.management.controller.action;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import org.springframework.beans.factory.annotation.Autowired;
    5. import org.springframework.security.core.context.SecurityContextHolder;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.ui.Model;
    8. import org.springframework.web.bind.annotation.PathVariable;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestMethod;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import com.examstack.common.domain.exam.ExamHistory;
    13. import com.examstack.common.domain.exam.ExamPaper;
    14. import com.examstack.common.domain.question.PointStatistic;
    15. import com.examstack.common.domain.question.Question;
    16. import com.examstack.common.domain.question.QuestionFilter;
    17. import com.examstack.common.domain.user.User;
    18. import com.examstack.common.util.Page;
    19. import com.examstack.management.security.UserInfo;
    20. import com.examstack.management.service.ExamPaperService;
    21. import com.examstack.management.service.ExamService;
    22. import com.examstack.management.service.QuestionService;
    23. import com.examstack.management.service.UserService;
    24. @Controller
    25. public class DashBoardAction {
    26. @Autowired
    27. private QuestionService questionService;
    28. @Autowired
    29. private UserService userService;
    30. @Autowired
    31. private ExamPaperService examPaperService;
    32. @Autowired
    33. private ExamService examService;
    34. @RequestMapping(value = "/secure/dashboard/baseinfo", method = RequestMethod.GET)
    35. public @ResponseBody List baseInfo(Model model) {
    36. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext()
    37. .getAuthentication()
    38. .getPrincipal();
    39. Page pageUser = new Page();
    40. pageUser.setPageNo(1);
    41. pageUser.setPageSize(1);
    42. userService.getUserListByRoleId(userInfo.getRoleMap().get("ROLE_STUDENT").getRoleId(), pageUser);
    43. Page pageQuestion = new Page();
    44. pageQuestion.setPageNo(1);
    45. pageQuestion.setPageSize(1);
    46. QuestionFilter qf = new QuestionFilter();
    47. qf.setFieldId(0);
    48. qf.setKnowledge(0);
    49. qf.setQuestionType(0);
    50. qf.setTag(0);
    51. qf.setSearchParam("-1");
    52. questionService.getQuestionList(pageQuestion, qf);
    53. Page pageExamPaper = new Page();
    54. pageExamPaper.setPageNo(1);
    55. pageExamPaper.setPageSize(1);
    56. examPaperService.getEnabledExamPaperList(userInfo.getUsername(), pageExamPaper);
    57. List l = new ArrayList();
    58. l.add(pageQuestion.getTotalRecord());
    59. l.add(pageExamPaper.getTotalRecord());
    60. l.add(pageUser.getTotalRecord());
    61. return l;
    62. }
    63. @RequestMapping(value = "/secure/dashboard/studentApprovedList", method = RequestMethod.GET)
    64. public @ResponseBody List studentApprovedList(Model model) {
    65. Page page = new Page();
    66. page.setPageNo(1);
    67. page.setPageSize(4);
    68. List histList = examService.getUserExamHistList(page, 0);
    69. return histList;
    70. }
    71. @RequestMapping(value = "/secure/dashboard/StudentMarkList", method = RequestMethod.GET)
    72. public @ResponseBody List studentMarkList(Model model) {
    73. Page page = new Page();
    74. page.setPageNo(1);
    75. page.setPageSize(4);
    76. List histList = examService.getUserExamHistList(page, 2);
    77. return histList;
    78. }
    79. @RequestMapping(value = "/secure/dashboard/chartinfo/{fieldId}", method = RequestMethod.GET)
    80. public @ResponseBody List chartInfo(Model model,@PathVariable("fieldId") int fieldId) {
    81. List pointStatisticList = questionService.getPointCount(fieldId, null);
    82. List l = new ArrayList();
    83. for(PointStatistic ps : pointStatisticList){
    84. FieldNumber fieldNumber = new FieldNumber();
    85. fieldNumber.name = ps.getPointName();
    86. fieldNumber.amount = ps.getAmount();
    87. l.add(fieldNumber);
    88. }
    89. return l;
    90. }
    91. class FieldNumber{
    92. private String name;
    93. private int amount;
    94. public String getName() {
    95. return name;
    96. }
    97. public void setName(String name) {
    98. this.name = name;
    99. }
    100. public int getAmount() {
    101. return amount;
    102. }
    103. public void setAmount(int amount) {
    104. this.amount = amount;
    105. }
    106. }
    107. }
    1. package com.examstack.management.controller.action;
    2. import java.util.List;
    3. import org.springframework.beans.factory.annotation.Autowired;
    4. import org.springframework.stereotype.Controller;
    5. import org.springframework.web.bind.annotation.PathVariable;
    6. import org.springframework.web.bind.annotation.RequestBody;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RequestMethod;
    9. import org.springframework.web.bind.annotation.ResponseBody;
    10. import com.examstack.common.domain.exam.AnswerSheet;
    11. import com.examstack.common.domain.exam.AnswerSheetItem;
    12. import com.examstack.common.domain.exam.ExamPaper;
    13. import com.examstack.common.domain.exam.Message;
    14. import com.examstack.management.service.ExamPaperService;
    15. import com.examstack.management.service.ExamService;
    16. import com.google.gson.Gson;
    17. @Controller
    18. public class ExamAction {
    19. @Autowired
    20. private ExamPaperService examPaperService;
    21. @Autowired
    22. private ExamService examService;
    23. @RequestMapping(value = "/api/exampaper/{id}", method = RequestMethod.GET)
    24. public @ResponseBody ExamPaper getExamPaper(@PathVariable("id") int id){
    25. ExamPaper paper = examPaperService.getExamPaperById(id);
    26. return paper;
    27. }
    28. @RequestMapping(value = "/api/answersheet", method = RequestMethod.POST)
    29. public @ResponseBody Message submitAnswerSheet(@RequestBody AnswerSheet answerSheet){
    30. List itemList = answerSheet.getAnswerSheetItems();
    31. //全部是客观题,则状态更改为已阅卷
    32. int approved = 3;
    33. for(AnswerSheetItem item : itemList){
    34. if(item.getQuestionTypeId() != 1 && item.getQuestionTypeId() != 2 && item.getQuestionTypeId() != 3){
    35. approved = 2;
    36. break;
    37. }
    38. }
    39. Gson gson = new Gson();
    40. examService.updateUserExamHist(answerSheet, gson.toJson(answerSheet),approved);
    41. return new Message();
    42. }
    43. }
    1. package com.examstack.management.controller.action;
    2. import java.io.FileNotFoundException;
    3. import java.util.ArrayList;
    4. import java.util.Date;
    5. import java.util.HashMap;
    6. import java.util.List;
    7. import javax.servlet.http.HttpServletRequest;
    8. import javax.servlet.http.HttpServletResponse;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.security.core.context.SecurityContextHolder;
    11. import org.springframework.security.core.userdetails.UserDetails;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.ui.Model;
    14. import org.springframework.web.bind.annotation.PathVariable;
    15. import org.springframework.web.bind.annotation.RequestBody;
    16. import org.springframework.web.bind.annotation.RequestMapping;
    17. import org.springframework.web.bind.annotation.RequestMethod;
    18. import org.springframework.web.bind.annotation.ResponseBody;
    19. import com.examstack.common.domain.exam.Message;
    20. import com.examstack.common.domain.question.KnowledgePoint;
    21. import com.examstack.common.domain.question.Question;
    22. import com.examstack.common.domain.question.QuestionTag;
    23. import com.examstack.common.util.file.FileUploadUtil;
    24. import com.examstack.management.security.UserInfo;
    25. import com.examstack.management.service.QuestionService;
    26. import com.google.gson.Gson;
    27. import com.google.gson.JsonElement;
    28. import com.google.gson.JsonParser;
    29. import com.google.gson.reflect.TypeToken;
    30. @Controller
    31. public class QuestionAction {
    32. @Autowired
    33. private QuestionService questionService;
    34. /**
    35. * 添加试题
    36. *
    37. * @param question
    38. * @return
    39. */
    40. @RequestMapping(value = "/secure/question/question-add", method = RequestMethod.POST)
    41. public @ResponseBody Message addQuestion(@RequestBody Question question) {
    42. UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    43. Message message = new Message();
    44. Gson gson = new Gson();
    45. question.setContent(gson.toJson(question.getQuestionContent()));
    46. question.setCreate_time(new Date());
    47. question.setCreator(userDetails.getUsername());
    48. try {
    49. questionService.addQuestion(question);
    50. } catch (Exception e) {
    51. // TODO Auto-generated catch block
    52. message.setResult("error");
    53. message.setMessageInfo(e.getClass().getName());
    54. e.printStackTrace();
    55. }
    56. return message;
    57. }
    58. /**
    59. * 获取试题的标签列表
    60. *
    61. * @param questionId
    62. * @return
    63. */
    64. @RequestMapping(value = "/secure/question/question-tag/{questionId}", method = RequestMethod.GET)
    65. public @ResponseBody Message getQuestionTag(@PathVariable("questionId") int questionId) {
    66. Message message = new Message();
    67. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    68. List tagList = questionService.getQuestionTagByQuestionIdAndUserId(questionId,
    69. userInfo.getUserid(), null);
    70. message.setObject(tagList);
    71. return message;
    72. }
    73. /**
    74. * 为试题添加标签
    75. *
    76. * @param questionId
    77. * @param questionTagList
    78. * @return
    79. */
    80. @RequestMapping(value = "/secure/question/add-question-tag", method = RequestMethod.POST)
    81. public @ResponseBody Message addQuestionTag(@RequestBody int questionId,
    82. @RequestBody List questionTagList) {
    83. Message message = new Message();
    84. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    85. try {
    86. questionService.addQuestionTag(questionId, userInfo.getUserid(), questionTagList);
    87. } catch (Exception e) {
    88. e.printStackTrace();
    89. message.setResult(e.getClass().getName());
    90. }
    91. return message;
    92. }
    93. /**
    94. * 获取试题详细信息
    95. * @param questionId
    96. * @return
    97. */
    98. @RequestMapping(value = "/secure/question/question-detail/{questionId}", method = RequestMethod.GET)
    99. public @ResponseBody Message getQuestionDetail(@PathVariable("questionId") int questionId) {
    100. Message message = new Message();
    101. //UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    102. try {
    103. Question question = questionService.getQuestionDetail(questionId, 0);
    104. message.setObject(question);
    105. } catch (Exception e) {
    106. // TODO Auto-generated catch block
    107. e.printStackTrace();
    108. message.setResult(e.getCause().getMessage());
    109. }
    110. return message;
    111. }
    112. /**
    113. * 修改试题知识点
    114. *
    115. * @param questionId
    116. * @param pointId
    117. * @param questionTagList
    118. * @return
    119. */
    120. @RequestMapping(value = "/secure/question/question-update/{questionId}/{pointId}", method = RequestMethod.POST)
    121. public @ResponseBody Message updateQuestionKnowledge(@PathVariable int questionId, @PathVariable int pointId,
    122. @RequestBody List questionTagList) {
    123. Message message = new Message();
    124. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    125. Question question = new Question();
    126. question.setId(questionId);
    127. List pointIdList = new ArrayList();
    128. pointIdList.add(pointId);
    129. question.setPointList(pointIdList);
    130. try {
    131. questionService.updateQuestionPoint(question, userInfo.getUserid(), questionTagList);
    132. } catch (Exception e) {
    133. message.setResult(e.getClass().getName());
    134. }
    135. return message;
    136. }
    137. @RequestMapping(value = "/secure/question/question-update", method = RequestMethod.POST)
    138. public @ResponseBody Message updateQuestion(@RequestBody String jsonStr){
    139. Message msg = new Message();
    140. Gson gson = new Gson();
    141. JsonParser parser = new JsonParser();
    142. JsonElement element = parser.parse(jsonStr);
    143. List questionTagList = gson.fromJson(element.getAsJsonObject().get("tags"), new TypeToken>(){}.getType());
    144. Question question = gson.fromJson(element.getAsJsonObject().get("question"), Question.class);
    145. try {
    146. questionService.updateQuestion(question, questionTagList);
    147. } catch (Exception e) {
    148. // TODO Auto-generated catch block
    149. e.printStackTrace();
    150. msg.setResult(e.getCause().getMessage());
    151. }
    152. //TO-DO:需要提交到数据库,保证在事务中提交
    153. return msg;
    154. }
    155. @RequestMapping(value = "/secure/question/get-knowledge-point/{fieldId}", method = RequestMethod.GET)
    156. public @ResponseBody Message getQuestionPointByFieldId(@PathVariable int fieldId) {
    157. Message message = new Message();
    158. HashMap pointMap = new HashMap();
    159. List pointList = questionService.getKnowledgePointByFieldId(fieldId, null);
    160. for (KnowledgePoint point : pointList) {
    161. pointMap.put(point.getPointId(), point.getPointName());
    162. }
    163. message.setObject(pointMap);
    164. return message;
    165. }
    166. @RequestMapping(value = "/secure/question/delete-question/{questionId}", method = RequestMethod.GET)
    167. public @ResponseBody Message deleteQuestion(Model model, @PathVariable("questionId") int questionId) {
    168. // UserDetails userDetails = (UserDetails)
    169. // SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    170. Message message = new Message();
    171. try {
    172. questionService.deleteQuestionByQuestionId(questionId);
    173. } catch (Exception ex) {
    174. message.setResult(ex.getClass().getName());
    175. }
    176. return message;
    177. }
    178. @RequestMapping(value = "/secure/upload-uploadify-img", method = RequestMethod.POST)
    179. public @ResponseBody String uploadImg(HttpServletRequest request, HttpServletResponse response) {
    180. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    181. List filePathList = new ArrayList();
    182. try {
    183. filePathList = FileUploadUtil.uploadImg(request, response, userInfo.getUsername());
    184. } catch (FileNotFoundException e) {
    185. // TODO Auto-generated catch block
    186. e.printStackTrace();
    187. } catch (Exception ex) {
    188. ex.printStackTrace();
    189. }
    190. if (filePathList.size() == 0) {
    191. return "系统错误";
    192. }
    193. return filePathList.get(0);
    194. }
    195. @RequestMapping(value = "/secure/upload-uploadify", method = RequestMethod.POST)
    196. public @ResponseBody String uploadFile(HttpServletRequest request, HttpServletResponse response) {
    197. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    198. List filePathList = new ArrayList();
    199. try {
    200. filePathList = FileUploadUtil.uploadFile(request, response, userInfo.getUsername());
    201. } catch (FileNotFoundException e) {
    202. // TODO Auto-generated catch block
    203. e.printStackTrace();
    204. } catch (Exception ex) {
    205. ex.printStackTrace();
    206. }
    207. if (filePathList.size() == 0) {
    208. return "系统错误";
    209. }
    210. return filePathList.get(0);
    211. }
    212. @RequestMapping(value = "/secure/question-import/{id}", method = RequestMethod.POST)
    213. public @ResponseBody Message courseImport(@RequestBody String filePath, @PathVariable("id") int id) {
    214. Message message = new Message();
    215. UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext()
    216. .getAuthentication().getPrincipal();
    217. if(id == 0){
    218. message.setResult("error");
    219. message.setMessageInfo("请选择题库");
    220. return message;
    221. }
    222. try{
    223. questionService.uploadQuestions(filePath, userInfo.getUsername(),id);
    224. }catch(RuntimeException e){
    225. message.setResult(e.getClass().getName() + ":" + e.getMessage());
    226. message.setMessageInfo(e.getMessage());
    227. }
    228. return message;
    229. }
    230. }

    五,项目总结

  • 相关阅读:
    Prompt工程师指南[从基础到进阶篇]:用于开发和优化提示,以有效地使用语言模型(LMs)进行各种应用和研究主题
    【深入理解Linux内核锁】六、信号量
    【ARM】使用Ubuntu-base构建根文件系统
    Docker-compose
    @selector() 与SEL 到底是啥
    Python机器视觉--OpenCV入门--OpenCV鼠标绘制图形
    含文档+PPT+源码等]精品微信小程序ssm超市购物系统小程序+后台管理系统|前后分离VUE[包运行成功]微信小程序项目源码Java毕业设计
    java项目-第99期基于spring+springmvc+hibernate的在线问卷答题系统-计算机毕业设计
    【网络编程】网络层——IP协议
    appium实现自动化测试原理
  • 原文地址:https://blog.csdn.net/whirlwind526/article/details/127576511