From bc52cd32f0878914669edfecee9a335455303c69 Mon Sep 17 00:00:00 2001 From: flower Date: Thu, 24 Jan 2019 00:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E7=BB=83=E4=B9=A0=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CmsExaminationController.java | 108 +----------------- .../cms/controller/CmsPracticeController.java | 1 + .../templates/web/examination/detail.html | 49 ++++---- .../templates/web/examination/list.html | 3 +- .../templates/web/practice/detail.html | 4 + .../templates/web/practice/list.html | 5 +- 6 files changed, 37 insertions(+), 133 deletions(-) diff --git a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsExaminationController.java b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsExaminationController.java index 8d3146f1f..844edd703 100644 --- a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsExaminationController.java +++ b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsExaminationController.java @@ -62,112 +62,10 @@ public class CmsExaminationController { @RequestMapping("/examination/start/{id}") @GetMapping() public String start(@PathVariable String id, ModelMap mmap) { - ExamExamination examExamination = examExaminationService.selectById( id ); -// SysUser sysUser = sysUserService.selectUserByLoginName( JwtUtil.getLoginName() ); -// Integer userId = Integer.parseInt( sysUser.getUserId().toString() ); - //考试类型 - String type = examExamination.getType(); - //试卷ID - Integer examPaperId = examExamination.getExamPaperId(); - //考试次数 - Integer examNumber = examExamination.getExamNumber(); - //考试时长 - Integer timeLength = examExamination.getTimeLength(); - //考试记录ID + ExamExamination examExamination = examExaminationService.selectById(id); Integer examUserExaminationId = -1; -// if(1==1){ -// mmap.put("error","已超过" + examNumber + "次考试"); -// return prefix + "list"; -// } - ExamUserExamination insert = new ExamUserExamination(); - //正式考试 - if (type.equals( "2" )) { - ExamUserExamination examUserExamination = new ExamUserExamination(); - examUserExamination.setVipUserId( 1 ); - examUserExamination.setExamPaperId( examPaperId ); - examUserExamination.setExamExaminationId( Integer.parseInt( id ) ); - //考试记录集合 - List userExamination = examUserExaminationService.selectLastOne( examUserExamination ); - // 最后一次考试 - ExamUserExamination last; - - //超过考试次数 - if (userExamination.size() >= examNumber) { - - last = userExamination.get( 0 ); - //最后一次考试已交卷,直接返回 - if (last.getUpdateDate() != null && !last.getUpdateDate().equals( "" )) { - throw new BaseException("已超过" + examNumber + "次考试,"); -// return error( 500, "已超过" + examNumber + "次考试," ); - } else { - // 最后一次考试未交卷,但超过考试时长,直接返回 - if (last.getCreateDate().getTime() + timeLength * 60 * 1000 < new Date().getTime()) { - throw new BaseException( "已超过" + examNumber + "次考试," ); - } - } - - } - - if (userExamination.size() <= 0 //考试次数小于0 - || userExamination.get( 0 ).getUpdateDate() != null //最后一次考试已交卷 - || userExamination.get( 0 ).getCreateDate().getTime() + timeLength * 60 * 1000 < new Date().getTime()//最后一次考试,已超过考过时长 - ) { - insert.setExamExaminationId( Integer.parseInt( id ) ); - insert.setVipUserId( 1 ); - insert.setCreateDate( new Date() ); - insert.setExamPaperId( examPaperId ); - insert.setDelFlag( "0" ); - insert.setScore( 0 ); - examUserExaminationService.insertOne( insert ); - examUserExaminationId = insert.getId(); - } else { - examUserExaminationId = userExamination.get( 0 ).getId(); - } - - } - ExamPaper examPaper = examPaperService.selectById(examPaperId); - List data = new ArrayList<>(); - List list = examPaperService.selectQuestionAndItemByPaperId( examPaperId ); - //随机试卷 - if(examPaper.getType().equals("2")){ - Collections.shuffle( list ); - ExamPaperTypeNumber examPaperTypeNumber = new ExamPaperTypeNumber(); - examPaperTypeNumber.setExamPaperId(examPaperId); - List examPaperTypeNumbers = examPaperTypeNumberService.selectList(examPaperTypeNumber); - //三种题型的数量 - int one=0,two=0,three=0; - for (ExamPaperTypeNumber item : examPaperTypeNumbers) { - if(item.getExamQuestionType()==1){ - one = item.getNumber(); - } - if(item.getExamQuestionType()==2){ - two = item.getNumber(); - } - if(item.getExamQuestionType()==3){ - three = item.getNumber(); - } - } - for (ExamQuestionVO item : list) { - if(item.getType().equals("1")&&one>0){ - data.add(item); - one--; - } - if(item.getType().equals("2")&&two>0){ - data.add(item); - two--; - } - if(item.getType().equals("3")&&three>0){ - data.add(item); - three--; - } - } - }else{ - data = list; - } - //是否乱序 - if (examExamination.getQuestionDisorder().equals( "2" )) { - Collections.shuffle( list ); - } + List data = examExaminationService.queryExaminationQuestion(examExamination,examUserExaminationId); + Integer examPaperId = examExamination.getExamPaperId(); mmap.put( "data", data ); mmap.put( "examUserExaminationId", examUserExaminationId ); diff --git a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsPracticeController.java b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsPracticeController.java index 3df391dd2..ea4194b87 100644 --- a/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsPracticeController.java +++ b/ruoyi-cms/src/main/java/com/ruoyi/cms/controller/CmsPracticeController.java @@ -51,6 +51,7 @@ public class CmsPracticeController { Collections.shuffle(result); } mmap.put("data", result); + mmap.put("practice",examPracticeService.selectById(id)); return prefix + "detail"; } } diff --git a/ruoyi-cms/src/main/resources/templates/web/examination/detail.html b/ruoyi-cms/src/main/resources/templates/web/examination/detail.html index b977d519d..b22dfd236 100644 --- a/ruoyi-cms/src/main/resources/templates/web/examination/detail.html +++ b/ruoyi-cms/src/main/resources/templates/web/examination/detail.html @@ -16,7 +16,10 @@
-
+
+ [[${examExamination.name}]] +
+
[[${questionStat.index+1}]]: (单选) @@ -34,18 +37,18 @@ - - - + + + - - + +
- +
@@ -53,7 +56,6 @@
-
@@ -78,26 +80,23 @@ document.write(unescape("%3Cspan id='cnzz_stat_icon_30088308'%3E%3C/span%3E%3Csc }) + function endPaper() { - var userAnswer = $("." + id + "useranswer:checked").val(); - if (userAnswer != answer) { - layer.msg('回答错误', {icon: 2}); + var data = []; + $(".question").each(function(){ - $.ajax({ - type: 'post', - url: "/api/v1/practice/answer", - contentType: "application/json", - data: "[" + id + "]", - success: function (result) { - if (result.code != web_status.SUCCESS) { - $.modal.msgError(result.msg); - } + }) + $.ajax({ + type: 'post', + url: "/api/v1/examination/finish/"+[[${examUserExaminationId}]]+"/"+[[${examExamination.id}]]+"/"+[[${paperId}]], + contentType: "application/json", + data: JSON.stringify(data), + success: function (result) { + if (result.code != web_status.SUCCESS) { + $.modal.msgError(result.msg); } - }); - - - } - $("#" + id + "answer").show() + } + }); } diff --git a/ruoyi-cms/src/main/resources/templates/web/examination/list.html b/ruoyi-cms/src/main/resources/templates/web/examination/list.html index a022fe90f..bb427bffb 100644 --- a/ruoyi-cms/src/main/resources/templates/web/examination/list.html +++ b/ruoyi-cms/src/main/resources/templates/web/examination/list.html @@ -74,7 +74,8 @@ ,limitName: 'pageSize' //每页数据量的参数名,默认:limit } ,response: { - statusCode: 200 //规定成功的状态码,默认:0 + statusCode: 200, + countName: 'total'//规定成功的状态码,默认:0 } ,page: true }); diff --git a/ruoyi-cms/src/main/resources/templates/web/practice/detail.html b/ruoyi-cms/src/main/resources/templates/web/practice/detail.html index 10373f8da..043339d77 100644 --- a/ruoyi-cms/src/main/resources/templates/web/practice/detail.html +++ b/ruoyi-cms/src/main/resources/templates/web/practice/detail.html @@ -12,6 +12,10 @@
+
+ [[${practice.name}]] +
+
[[${questionStat.index+1}]]: (单选) diff --git a/ruoyi-cms/src/main/resources/templates/web/practice/list.html b/ruoyi-cms/src/main/resources/templates/web/practice/list.html index ae0647359..de2984ee1 100644 --- a/ruoyi-cms/src/main/resources/templates/web/practice/list.html +++ b/ruoyi-cms/src/main/resources/templates/web/practice/list.html @@ -43,11 +43,12 @@ ,{title: '操作',toolbar: '#barDemo'} ] ] ,request: { - pageName: 'pageNumber' //页码的参数名称,默认:page + pageName: 'pageNum' //页码的参数名称,默认:page ,limitName: 'pageSize' //每页数据量的参数名,默认:limit } ,response: { - statusCode: 200 //规定成功的状态码,默认:0 + statusCode: 200 + ,countName: 'total' } ,page: true });