十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
學(xué)生模塊功能比較少,就是進(jìn)行考試和查看自己成績(jī)兩個(gè)大的功能。
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到善左網(wǎng)站設(shè)計(jì)與善左網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都做網(wǎng)站、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋善左地區(qū)。
學(xué)生進(jìn)行考試的功能比較復(fù)雜(首先做了校驗(yàn),不在考試時(shí)間范圍內(nèi),不能進(jìn)行考試)
考試試題是數(shù)據(jù)庫(kù)根據(jù)發(fā)布考試時(shí)的條件隨機(jī)產(chǎn)生的一套試題。因?yàn)槊看慰荚囶}型題量都是不同的,因此我們繼續(xù)采用JSON的格式去保存數(shù)據(jù),當(dāng)狀態(tài)為1:表示正在考試;狀態(tài)為2:表示已經(jīng)考試結(jié)束;狀態(tài)為3:表示老師已經(jīng)閱完試卷
(1)當(dāng)考試考試的時(shí)候,會(huì)給考上隨機(jī)產(chǎn)生一套試題,并存儲(chǔ)到數(shù)據(jù)庫(kù)中,如果考試中電腦突然壞了可以保證重新打開(kāi)還是之前的試題
(2)考試時(shí)間結(jié)束會(huì)自動(dòng)提交考試,此時(shí)會(huì)將有學(xué)生成績(jī)的試題保存到數(shù)據(jù)庫(kù)中,老師批閱試卷就是從該JSON中讀取出來(lái)的
(3)老師批閱完試卷以后,狀態(tài)會(huì)變?yōu)?,JSON中會(huì)加上考生每道題的得分情況(考試倒計(jì)時(shí)根據(jù)考試考試時(shí)間和考試時(shí)間長(zhǎng)度進(jìn)行計(jì)算出來(lái)的,如果下午四點(diǎn)考試結(jié)束,學(xué)生三點(diǎn)半登錄系統(tǒng),就只有半個(gè)小時(shí)時(shí)間進(jìn)行考試)
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } @RequestMapping("/list") public String showExam(HttpServletRequest request,Integer curr, Model model){ if (curr == null){ curr = 1; } HttpSession session = request.getSession(); Student student = (Student) session.getAttribute("studentInfo"); Integer classesid = student.getClassesid(); if (classesid != null){ PageInfopublishexamList = publishExamService.selectAll(classesid, curr, 5); model.addAttribute("publishexamList", publishexamList); } model.addAttribute("studentInfo", student); return "/exam/list"; } //進(jìn)入考試頁(yè)面,初始化數(shù)據(jù) @SuppressWarnings("unchecked") @RequestMapping("/exam") public String exam(HttpServletRequest request,int id,Model model){ //0表示0.5小時(shí),1表示1小時(shí),2表示1.5小時(shí),3表示2小時(shí),4表示2.5小時(shí),5表示3小時(shí) //考試時(shí)間所對(duì)應(yīng)的毫秒數(shù) long[] dateLong = {30*60*1000, 60*60*1000, 90*60*1000, 120*60*1000, 150*60*1000, 180*60*1000}; PublishexamWithBLOBs publishexam = publishExamService.selectByKey(id); HttpSession session = request.getSession(); Student student = (Student) session.getAttribute("studentInfo"); //在考試記錄表中添加一條考試信息 Examhis examhis = examhisService.studentIsNotExam(student.getId(), publishexam.getSubjectId(), publishexam.getExamtime()); List textList = null; ArrayList list = JsonUtils.toBean(publishexam.getExam(), ArrayList.class, TextModel.class); Date date = new Date(); Date date2 = new Date(); date2.setTime(publishexam.getExamtime().getTime() + dateLong[publishexam.getExamlength()]); //當(dāng)前時(shí)間如果在考試時(shí)間之前,考試還未開(kāi)始 if (date.compareTo(publishexam.getExamtime()) <= 0){ model.addAttribute("message", "對(duì)不起當(dāng)前考試還未開(kāi)始!"); return "/message"; } /*1.當(dāng)前時(shí)間>考試時(shí)間+考試時(shí)長(zhǎng),考試已經(jīng)結(jié)束 2.examhis=null,則證明作者第一次點(diǎn)擊開(kāi)始考試 如果examhis不為空 狀態(tài)為1:表示正在考試 狀態(tài)為2:表示已經(jīng)考試結(jié)束, 狀態(tài)為3:表示老師已經(jīng)閱完試卷 */ if (date.compareTo(date2) >= 0 || (examhis != null && examhis.getStatus() != 1)){ model.addAttribute("message", "對(duì)不起當(dāng)前考試已經(jīng)結(jié)束!"); return "/message"; } if (examhis == null){ examhis = new Examhis(); examhis.setStudentid(student.getId()); examhis.setStudentname(student.getName()); examhis.setSubjectid(publishexam.getSubjectId()); examhis.setSubjectname(publishexam.getSubjectName()); examhis.setClassesid(student.getClassesid()); examhis.setClassesname(student.getClassesname()); examhis.setPublishexamid(id); examhis.setExamtime(publishexam.getExamtime()); examhis.setStatus(1); textList = new ArrayList (); for (TextModel textModel : list) { List text = textService.beginExam(textModel,publishexam.getSubjectId()); for (Text text2 : text) { text2.setTexId(textModel.getTextModelId()); } textList.addAll(text); } String json = JsonUtils.toJson(textList); examhis.setExamtest(json); examhisService.insert(examhis); }else{ textList = JsonUtils.toBean(examhis.getExamtest(), ArrayList.class, Text.class); } int sum = 0; for (TextModel textModel : list) { sum += textModel.getGrade()*textModel.getTextCount(); } List textModelList = textModelService.selectTextModel(list); model.addAttribute("textModelList", textModelList); model.addAttribute("studentInfo", student); model.addAttribute("textList", textList); model.addAttribute("publishexam", publishexam); model.addAttribute("sum", sum); model.addAttribute("examTimeLength", dateLong[publishexam.getExamlength()]/1000); model.addAttribute("examTime", (date2.getTime() - date.getTime())/1000); return "/exam/exam"; } //提交考試方法 @RequestMapping(value="/examEnd", method=RequestMethod.POST) @ResponseBody public AjaxResult examEnd(HttpServletRequest request, ExamList examList, int id){ PublishexamWithBLOBs publishexam = publishExamService.selectByKey(id); HttpSession session = request.getSession(); Student student = (Student) session.getAttribute("studentInfo"); //將考試信息轉(zhuǎn)成json,改變考試狀態(tài),更新到考試歷史記錄表中 Examhis examhis = examhisService.studentIsNotExam(student.getId(), publishexam.getSubjectId(), publishexam.getExamtime()); List list = examList.getExamList(); list.remove(0); for (Exam exam : list) { exam.setText(textService.selectOne(exam.getTextId())); if (exam.getAnswer() == null){ exam.setAnswer(" "); } } String json = JsonUtils.toJson(list); examhis.setExamtest(json); examhis.setStatus(2); examhisService.update(examhis); return AjaxResult.successInstance("您已成功提交考試"); }
因?yàn)椴樵兂煽?jī)比較簡(jiǎn)單,就是查詢出學(xué)生成績(jī),顯示到頁(yè)面上而已,正在進(jìn)行的考試成績(jī)?yōu)榭铡?/p>
總結(jié)
以上所述是小編給大家介紹的Java實(shí)現(xiàn)在線考試系統(tǒng)與設(shè)計(jì)(學(xué)生功能),希望對(duì)大家有所幫助!