——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明





基于javaweb的SSM在线考试系统(java+ssm+jsp+js+mysql)
管理员:
admin 123456
老师
1001 123456
1002 123456
学生
2019001 123456
2019002 123456
2019003 123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| putRequestValue("list", clazzService.selectAll(Clazz.class, "id desc")); SimpleUser bean = service.get(uid); request.setAttribute("modifybean", bean);
request.setAttribute("actionname", actionname); request.setAttribute("actionclass", actionclass); return "modifySimpleUser"; } catch (Exception e) { e.printStackTrace(); MessageUtil.addMessage(request, "获取信息失败."); return ERROR; } }
@RequestMapping(value = "/deleteSimpleUser.do") public String delete(String ids) { try { service.deleteSimpleUser(ids); MessageUtil.addRelMessage(request, "删除信息成功.", "mainquery"); return SUCCESS; } catch (Exception e) { e.printStackTrace(); MessageUtil.addMessage(request, "删除信息失败."); return ERROR; } }
@RequestMapping(value = "/addSimpleUser.do") public String add(SimpleUser bean) { try { service.addSimpleUser(bean); MessageUtil.addMessage(request, "添加成功."); return SUCCESS; } catch (Exception e) { e.printStackTrace(); MessageUtil.addMessage(request, "添加失败."); return ERROR; }
}
@RequestMapping(value = "/updateSimpleUser.do") public String update(SimpleUser bean) { try { bean.setPhoto(getUpdateFileField("photo")); service.updateSimpleUser(bean); if (getSessionUser() instanceof SimpleUser) { if (getSimpleUser().getId().equals(bean.getId())) { SessionBean sb = (SessionBean) getSessionValue(Constant.SESSION_BEAN); sb.setUser(service.get(getSimpleUser().getId())); } } MessageUtil.addMessage(request, "更新成功.");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| case "单选题": danxuanlist.add(p); break; case "多选题": duoxuanlist.add(p); break; case "判断题": panduanlist.add(p); break; case "填空题": tiankonglist.add(p); break; case "简答题": jiandalist.add(p); break; } } putRequestValue("danxuanlist", danxuanlist); putRequestValue("duoxuanlist", duoxuanlist); putRequestValue("panduanlist", panduanlist); putRequestValue("tiankonglist", tiankonglist); putRequestValue("jiandalist", jiandalist);
} catch (Exception e) { e.printStackTrace(); } return "forward:/qiantai/studentExam.jsp"; }
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| * @param sheet * 工作表 * @param list * 数据源 * @param fieldMap * 中英文字段对应关系的Map * @param firstIndex * 开始索引 * @param lastIndex * 结束索引 */ private static <T> void fillSheet(WritableSheet sheet, List<T> list, LinkedHashMap<String, String> fieldMap, int firstIndex, int lastIndex) throws Exception {
String[] enFields = new String[fieldMap.size()]; String[] cnFields = new String[fieldMap.size()];
int count = 0; for (Entry<String, String> entry : fieldMap.entrySet()) { enFields[count] = entry.getKey(); cnFields[count] = entry.getValue(); count++; } for (int i = 0; i < cnFields.length; i++) { Label label = new Label(i, 0, cnFields[i]); sheet.addCell(label); }
int rowNo = 1; for (int index = firstIndex; index <= lastIndex; index++) { T item = list.get(index); for (int i = 0; i < enFields.length; i++) { Object objValue = getFieldValueByNameSequence(enFields[i], item); String fieldValue = objValue == null ? "" : objValue.toString(); Label label = new Label(i, rowNo, fieldValue); sheet.addCell(label); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| count = studentExamService.getScoreCount(uid, 60, 70); putRequestValue("count2", count = count == null ? 0 : count);
count = studentExamService.getScoreCount(uid, 70, 90); putRequestValue("count3", count = count == null ? 0 : count);
count = studentExamService.getScoreCount(uid, 90, 100); putRequestValue("count4", count = count == null ? 0 : count);
} catch (Exception e) { e.printStackTrace(); } return "anlExamScore"; }
@RequestMapping(value = "/finishExam.do") public String finishExam(int uid) { try { Paper paper1 = (Paper) getSessionValue("paper"); if (paper1 == null) { getHttpSession().setAttribute("VoteErrorMessage", "提交答卷失败"); putRequestValue("closeable", true); return "forward:/qiantai/exam.jsp"; } SimpleUser student = getSimpleUser(); Paper paper = paperService.get(uid);
StudentExam exam = new StudentExam(); exam.setAddDate(DateUtil.getCurrentTime()); exam.setPaperId(paper.getId()); exam.setFinished("未阅卷"); exam.setCheckTeacherId(paper.getCourse().getTeacherId()); exam.setCourseId(paper.getCourseId()); exam.setStudentId(student.getId());
List<StudentExamQuestion> questexamList = new ArrayList<StudentExamQuestion>();
List<PaperQuestion> list = paperQuestionService.selectAll(PaperQuestion.class, MapUtil.createMap("paperId", paper.getId())); for (PaperQuestion pques : list) { Question ques = pques.getQuestion(); int score = pques.getQuestionScore(); StudentExamQuestion temp = new StudentExamQuestion(); temp.setQuestionId(ques.getId()); temp.setQuestionScore(score); String answer = "";
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| ans = new String(ary); bean.setAnswer(ans); } if (bean.getQuesType().equals("判断题")) { if (!bean.getAnswer().trim().equals("1")) { bean.setAnswer("0"); } } service.update(bean); MessageUtil.addMessage(request, "更新成功."); return SUCCESS; } catch (Exception e) { e.printStackTrace(); MessageUtil.addMessage(request, "更新失败."); return ERROR; } }
@RequestMapping(value = "/queryQuestion.do") public String query() { try { LinkedList<String> parmnames = new LinkedList<String>(); LinkedList<Object> parmvalues = new LinkedList<Object>(); Page p = FieldUtil.createPage(request, Question.class, parmnames, parmvalues);
parmnames.add("teacherId"); parmvalues.add(getTeacher().getId());
Page page = service.selectPage(p, Question.class); session.setAttribute(Constant.SESSION_PAGE, page);
request.setAttribute("actionname", actionname); request.setAttribute("actionclass", actionclass);
putRequestValue("list", courseService.selectAll(Course.class, MapUtil.createMap("teacherId", getTeacher().getId())));
return "listQuestion"; } catch (Exception e) { e.printStackTrace(); return ERROR; } }
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public String updateStudentExam(int uid) { try { StudentExam temp = studentExamService.get(uid); putRequestValue("modifybean", temp);
List<StudentExamQuestion> jiandalist = studentExamQuestionService.selectAll(StudentExamQuestion.class, MapUtil.createMap("examId", uid));
int zhuguan = 0; for (StudentExamQuestion jianda : jiandalist) { if (jianda.getQuestion().getQuesType().equals("简答题")) { String answer = getHttpServletRequest().getParameter("item_" + jianda.getId()); jianda.setJiandascore(Integer.valueOf(answer)); zhuguan += jianda.getJiandascore(); studentExamQuestionService.update(jianda); } } temp.setFinished("已阅卷"); temp.setZhuguan(zhuguan); temp.setZong(temp.getKeguan() + temp.getZhuguan()); studentExamService.update(temp);
getHttpSession().setAttribute("VoteErrorMessage", "阅卷提交成功"); } catch (Exception e) { e.printStackTrace(); getHttpSession().setAttribute("VoteErrorMessage", "阅卷提交失败"); } return "redirect:/sys/getStudentExam.do?uid=" + uid; }
@SuppressWarnings("unchecked") @RequestMapping(value = "/getStudentExam.do") public String getStudentExam(int uid) { try { StudentExam temp = studentExamService.get(uid); putRequestValue("modifybean", temp);
List<StudentExamQuestion> allqList = studentExamQuestionService.selectAll(StudentExamQuestion.class, MapUtil.createMap("examId", uid)); List<StudentExamQuestion> danxuanlist = new ArrayList<StudentExamQuestion>(); List<StudentExamQuestion> duoxuanlist = new ArrayList<StudentExamQuestion>(); List<StudentExamQuestion> panduanlist = new ArrayList<StudentExamQuestion>();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=041623412808201cw
https://javayms.pages.dev?id=041623412808201cw