Browse Source

试卷模板、题块信息

ywx
王宁 2 months ago
parent
commit
4e12a84e09
23 changed files with 417 additions and 156 deletions
  1. 4
    0
      scommons/src/main/java/com/xhkjedu/utils/N_Utils.java
  2. 34
    31
      smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBlockController.java
  3. 0
    57
      smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBlockQuestionController.java
  4. 14
    0
      smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperQtypeController.java
  5. 58
    2
      smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsTemplateController.java
  6. 9
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperBlockMapper.java
  7. 4
    1
      smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperMapper.java
  8. 4
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperQtypeMapper.java
  9. 4
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsTemplateBlockMapper.java
  10. 9
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsTemplateMapper.java
  11. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsPaperBlock.java
  12. 2
    0
      smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsTemplate.java
  13. 0
    41
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperBlockQuestionService.java
  14. 56
    12
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperBlockService.java
  15. 22
    1
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java
  16. 77
    4
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsTemplateService.java
  17. 24
    0
      smarking/src/main/java/com/xhkjedu/smarking/vo/paper/MsPaperParams.java
  18. 0
    3
      smarking/src/main/java/com/xhkjedu/smarking/vo/paper/MsPaperQtypeVo.java
  19. 30
    0
      smarking/src/main/resources/mapper/paper/MsPaperBlockMapper.xml
  20. 6
    1
      smarking/src/main/resources/mapper/paper/MsPaperMapper.xml
  21. 29
    2
      smarking/src/main/resources/mapper/paper/MsPaperQtypeMapper.xml
  22. 8
    0
      smarking/src/main/resources/mapper/paper/MsTemplateBlockMapper.xml
  23. 17
    1
      smarking/src/main/resources/mapper/paper/MsTemplateMapper.xml

+ 4
- 0
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java View File

@@ -1158,6 +1158,10 @@ public class N_Utils {
1158 1158
             return false;
1159 1159
         }
1160 1160
     }
1161
+
1162
+    //主观题处理题型
1163
+    public static int[] subjectiveList = new int[]{3,9,13,14,15};
1164
+
1161 1165
     //简单题进行分项展示
1162 1166
     private static int[] simplelist = new int[]{1,2,4,5,6,7,8,10,16,17};
1163 1167
     public static boolean isSimpleCheckQuestion(Integer ctype){

+ 34
- 31
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBlockController.java View File

@@ -1,14 +1,15 @@
1 1
 package com.xhkjedu.smarking.controller.paper;
2 2
 
3
-import com.github.pagehelper.PageHelper;
4
-import com.github.pagehelper.PageInfo;
3
+import com.xhkjedu.smarking.model.paper.MsPaper;
5 4
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
6 5
 import com.xhkjedu.smarking.service.paper.MsPaperBlockService;
6
+import com.xhkjedu.smarking.vo.paper.MsPaperParams;
7 7
 import com.xhkjedu.utils.N_Utils;
8
-import com.xhkjedu.utils.PageUtil;
9
-import com.xhkjedu.vo.PageResult;
10 8
 import com.xhkjedu.vo.ResultVo;
11
-import org.springframework.web.bind.annotation.*;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.RequestBody;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+import org.springframework.web.bind.annotation.RestController;
12 13
 
13 14
 import javax.annotation.Resource;
14 15
 import java.util.List;
@@ -24,34 +25,36 @@ public class MsPaperBlockController {
24 25
     @Resource
25 26
     private MsPaperBlockService msPaperBlockService;
26 27
 
27
-    /**
28
-     * @Description 新增
29
-     * @Param [msPaperBlock]
30
-     * @Author auto
31
-     * @Date 2024-10-15
32
-     * @return com.xhkjedu.vo.ResultVo
33
-     **/
34
-    @PostMapping("/save")
35
-    public ResultVo save(@RequestBody MsPaperBlock msPaperBlock) {
36
-        msPaperBlockService.add(msPaperBlock);
37
-        return new ResultVo(0, "保存成功!");
28
+    /*
29
+    * @Description 试卷题块试题
30
+    * @Date 2024/10/21 14:37:21
31
+    * @Author WN
32
+    * @Param [msPaper]
33
+    * @Return com.xhkjedu.vo.ResultVo
34
+    **/
35
+    @PostMapping("/list")
36
+    public ResultVo listPaperBlocks(@RequestBody MsPaper msPaper) {
37
+        N_Utils.validation(new Object[]{msPaper.getMsid(), "考试科目id"});
38
+        List<MsPaperBlock> list = msPaperBlockService.listPaperBlockQuestions(msPaper.getMsid());
39
+        return new ResultVo(0, "查询成功!", list);
38 40
     }
39 41
 
40
-    /**
41
-     * @Description 列表
42
-     * @Param [msPaperBlock]
43
-     * @Author auto
44
-     * @Date 2024-10-15
45
-     * @return com.xhkjedu.vo.ResultVo
42
+    /*
43
+     * @Description 保存题块
44
+     * @Date 2024/10/21 15:38:52
45
+     * @Author WN
46
+     * @Param [params]
47
+     * @Return com.xhkjedu.vo.ResultVo
46 48
      **/
47
-    @PostMapping("/list")
48
-    public ResultVo queryList(@RequestBody MsPaperBlock msPaperBlock) {
49
-        Integer page = msPaperBlock.getPage();
50
-        Integer size = msPaperBlock.getPageSize();
51
-        N_Utils.validation(new Object[]{page, "显示页码", 1, size, "显示条数", 1});
52
-        PageHelper.startPage(page, size);
53
-        List<MsPaperBlock> list = msPaperBlockService.queryList(msPaperBlock);
54
-        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
55
-        return new ResultVo(0, "查询成功!", pageResult);
49
+    @PostMapping("/save")
50
+    public ResultVo save(@RequestBody MsPaperParams params) {
51
+        N_Utils.validation(new Object[]{params.getMsid(), "考试科目id"});
52
+        if(params.getBlocks() == null || params.getBlocks().size() == 0){
53
+            return new ResultVo(1, "题块不能为空!");
54
+        }
55
+        Integer mpid = msPaperBlockService.save(params);
56
+        return new ResultVo(0, "保存成功!",mpid);
56 57
     }
58
+
59
+
57 60
 }

+ 0
- 57
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBlockQuestionController.java View File

@@ -1,57 +0,0 @@
1
-package com.xhkjedu.smarking.controller.paper;
2
-
3
-import com.github.pagehelper.PageHelper;
4
-import com.github.pagehelper.PageInfo;
5
-import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
6
-import com.xhkjedu.smarking.service.paper.MsPaperBlockQuestionService;
7
-import com.xhkjedu.utils.N_Utils;
8
-import com.xhkjedu.utils.PageUtil;
9
-import com.xhkjedu.vo.PageResult;
10
-import com.xhkjedu.vo.ResultVo;
11
-import org.springframework.web.bind.annotation.*;
12
-
13
-import javax.annotation.Resource;
14
-import java.util.List;
15
-
16
-/**
17
- * @Description 阅卷试卷题块试题表相关操作
18
- * @Author auto
19
- * @Date 2024-10-15
20
- */
21
-@RestController
22
-@RequestMapping("/msPaperBlockQuestion")
23
-public class MsPaperBlockQuestionController {
24
-    @Resource
25
-    private MsPaperBlockQuestionService msPaperBlockQuestionService;
26
-
27
-    /**
28
-     * @Description 新增
29
-     * @Param [msPaperBlockQuestion]
30
-     * @Author auto
31
-     * @Date 2024-10-15
32
-     * @return com.xhkjedu.vo.ResultVo
33
-     **/
34
-    @PostMapping("/save")
35
-    public ResultVo save(@RequestBody MsPaperBlockQuestion msPaperBlockQuestion) {
36
-        msPaperBlockQuestionService.add(msPaperBlockQuestion);
37
-        return new ResultVo(0, "保存成功!");
38
-    }
39
-
40
-    /**
41
-     * @Description 列表
42
-     * @Param [msPaperBlockQuestion]
43
-     * @Author auto
44
-     * @Date 2024-10-15
45
-     * @return com.xhkjedu.vo.ResultVo
46
-     **/
47
-    @PostMapping("/list")
48
-    public ResultVo queryList(@RequestBody MsPaperBlockQuestion msPaperBlockQuestion) {
49
-        Integer page = msPaperBlockQuestion.getPage();
50
-        Integer size = msPaperBlockQuestion.getPageSize();
51
-        N_Utils.validation(new Object[]{page, "显示页码", 1, size, "显示条数", 1});
52
-        PageHelper.startPage(page, size);
53
-        List<MsPaperBlockQuestion> list = msPaperBlockQuestionService.queryList(msPaperBlockQuestion);
54
-        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
55
-        return new ResultVo(0, "查询成功!", pageResult);
56
-    }
57
-}

+ 14
- 0
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperQtypeController.java View File

@@ -139,5 +139,19 @@ public class MsPaperQtypeController {
139 139
         return new ResultVo(0,"获取成功" ,map);
140 140
     }
141 141
 
142
+    /*
143
+     * @Description 试卷-主观题
144
+     * @Date 2024/10/21 13:53:38
145
+     * @Author WN
146
+     * @Param [subject]
147
+     * @Return com.xhkjedu.vo.ResultVo
148
+     **/
149
+    @PostMapping("/paper_sub")
150
+    public ResultVo listSubjectiveQuesitons(@RequestBody MsSubject subject){
151
+        N_Utils.validation(new Object[]{subject.getMsid(),"考试科目id",1});
152
+        List<Map<String,Object>> map =msPaperQtypeService.listPaperSubjectiveQuestions(subject.getMsid());
153
+        return new ResultVo(0,"获取成功" ,map);
154
+    }
155
+
142 156
 
143 157
 }

+ 58
- 2
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsTemplateController.java View File

@@ -3,6 +3,7 @@ package com.xhkjedu.smarking.controller.paper;
3 3
 import com.xhkjedu.smarking.model.paper.MsPaper;
4 4
 import com.xhkjedu.smarking.model.paper.MsTemplate;
5 5
 import com.xhkjedu.smarking.service.paper.MsTemplateService;
6
+import com.xhkjedu.smarking.vo.paper.MsPaperParams;
6 7
 import com.xhkjedu.utils.N_Utils;
7 8
 import com.xhkjedu.vo.ResultVo;
8 9
 import org.springframework.web.bind.annotation.PostMapping;
@@ -40,7 +41,7 @@ public class MsTemplateController {
40 41
     }
41 42
 
42 43
     /**
43
-     * @Description 新增
44
+     * @Description 模版-新增
44 45
      * @Param [msTemplate]
45 46
      * @Author auto
46 47
      * @Date 2024-10-15
@@ -49,9 +50,64 @@ public class MsTemplateController {
49 50
     @PostMapping("/save")
50 51
     public ResultVo save(@RequestBody MsTemplate msTemplate) {
51 52
         N_Utils.validation(new Object[]{msTemplate.getMpid(),"试卷id",1});
52
-        MsTemplate mt = msTemplateService.add(msTemplate);
53
+        MsTemplate mt = msTemplateService.save(msTemplate);
53 54
         return new ResultVo(0, "保存成功",mt);
54 55
     }
55 56
 
57
+    /*
58
+     * @Description 模版-设置
59
+     * @Date 2024/10/21 10:55:50
60
+     * @Author WN
61
+     * @Param [msTemplate]
62
+     * @Return com.xhkjedu.vo.ResultVo
63
+     **/
64
+    @PostMapping("/update")
65
+    public ResultVo updateTemplate(@RequestBody MsTemplate msTemplate) {
66
+        N_Utils.validation(new Object[]{msTemplate.getMpid(),"试卷id",1,msTemplate.getMtid(),"模板id",1});
67
+        MsTemplate mt = msTemplateService.updateTemplate(msTemplate);
68
+        return new ResultVo(0, "保存成功",mt);
69
+    }
70
+    /*
71
+     * @Description 模版-提交
72
+     * @Date 2024/10/21 10:55:50
73
+     * @Author WN
74
+     * @Param [msTemplate]
75
+     * @Return com.xhkjedu.vo.ResultVo
76
+     **/
77
+    @PostMapping("/commit")
78
+    public ResultVo commitTemplate(@RequestBody MsTemplate msTemplate) {
79
+        N_Utils.validation(new Object[]{msTemplate.getMpid(),"试卷id",1,msTemplate.getMtid(),"模板id",1});
80
+        MsTemplate mt = msTemplateService.updateTemplate(msTemplate);
81
+        return new ResultVo(0, "保存成功",mt);
82
+    }
83
+
84
+    /*
85
+     * @Description 保存模板主观题框选
86
+     * @Date 2024/10/21 17:44:35
87
+     * @Author WN
88
+     * @Param [params]
89
+     * @Return com.xhkjedu.vo.ResultVo
90
+     **/
91
+    @PostMapping("/save_sub")
92
+    public ResultVo saveSubjective(@RequestBody MsPaperParams params) {
93
+        N_Utils.validation(new Object[]{params.getMpid(),"试卷id",1,params.getMtid(),"模板id",1});
94
+        msTemplateService.saveSubjectiveQuestion(params);
95
+        return new ResultVo(0, "保存成功",params.getMtid());
96
+    }
97
+
98
+    /*
99
+     * @Description 删除模板
100
+     * @Date 2024/10/21 17:50:46
101
+     * @Author WN
102
+     * @Param [msTemplate]
103
+     * @Return com.xhkjedu.vo.ResultVo
104
+     **/
105
+    @PostMapping("/delete")
106
+    public ResultVo delete(@RequestBody MsTemplate msTemplate) {
107
+        N_Utils.validation(new Object[]{msTemplate.getMtid(),"模板id",1});
108
+        msTemplateService.deleteTemplate(msTemplate.getMtid());
109
+        return new ResultVo(0, "删除成功");
110
+    }
111
+
56 112
 
57 113
 }

+ 9
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperBlockMapper.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.smarking.mapper.paper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
5 8
 
6 9
 /**
7 10
  * @Description 阅卷试卷题块 Mapper 接口
@@ -9,4 +12,10 @@ import com.xhkjedu.smarking.model.paper.MsPaperBlock;
9 12
  * @Date 2024-10-15
10 13
  */
11 14
 public interface MsPaperBlockMapper extends TkMapper<MsPaperBlock> {
15
+
16
+    //获取题块及题块下试题
17
+    List<MsPaperBlock> listPaperBlockQuestions(@Param("msid")Integer msid,@Param("blocktype")Integer blocktype);
18
+
19
+    //根据试卷ID删除试卷题块
20
+    int deleteObjByMpidAndBlocktype(@Param("mpid")Integer mpid,@Param("blocktype")Integer blocktype);
12 21
 }

+ 4
- 1
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperMapper.java View File

@@ -23,7 +23,7 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
23 23
     int updatePaperAnswer(@Param("answered") Integer answered,@Param("mpid") Integer mpid);
24 24
 
25 25
     //获取试卷详情
26
-    Map<String,Object> getPaperInfoByEsid(@Param("msid") Integer msid);
26
+    Map<String,Object> getPaperInfoByMsid(@Param("msid") Integer msid);
27 27
 
28 28
     //获取考试科目对应考试状态信息
29 29
     PExamSubjectVo getExamSubjectForPaper(@Param("mpid")Integer mpid);
@@ -40,4 +40,7 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
40 40
 
41 41
     //根据试卷id获取考试状态
42 42
     Integer getExamStateByMpid(@Param("mpid") Integer mpid);
43
+
44
+    //根据科目id获取试卷基础信息
45
+    MsPaper getPaperBaseByMsid(@Param("msid") Integer msid);
43 46
 }

+ 4
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperQtypeMapper.java View File

@@ -6,6 +6,7 @@ import com.xhkjedu.smarking.vo.paper.MsPaperQtypeVo;
6 6
 import org.apache.ibatis.annotations.Param;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Map;
9 10
 
10 11
 /**
11 12
  * @Description 阅卷试卷题型表 Mapper 接口
@@ -23,4 +24,7 @@ public interface MsPaperQtypeMapper extends TkMapper<MsPaperQtype> {
23 24
 
24 25
     //附件试题详情
25 26
     List<MsPaperQtypeVo> listPaperQtypeQuesitonsForFj(@Param("mpid") Integer mpid);
27
+
28
+    //试卷主观题-附件
29
+    List<Map<String,Object>> listSubjectiveQuestionsFj(@Param("mpid") Integer mpid,@Param("ctypes")int[] ctypes);
26 30
 }

+ 4
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsTemplateBlockMapper.java View File

@@ -2,6 +2,7 @@ package com.xhkjedu.smarking.mapper.paper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.paper.MsTemplateBlock;
5
+import org.apache.ibatis.annotations.Param;
5 6
 
6 7
 /**
7 8
  * @Description 阅卷模块客观题定位区表 Mapper 接口
@@ -9,4 +10,7 @@ import com.xhkjedu.smarking.model.paper.MsTemplateBlock;
9 10
  * @Date 2024-10-15
10 11
  */
11 12
 public interface MsTemplateBlockMapper extends TkMapper<MsTemplateBlock> {
13
+
14
+    //删除模板中指定类型题块信息
15
+    int deleteByMtidAndMtype(@Param("mtid")Integer mtid, @Param("mtype")Integer mtype);
12 16
 }

+ 9
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsTemplateMapper.java View File

@@ -19,4 +19,13 @@ public interface MsTemplateMapper extends TkMapper<MsTemplate> {
19 19
 
20 20
     //设置试卷模板信息
21 21
     int updateTemplateForCurrstep(@Param("t") MsTemplate t);
22
+
23
+    //获取试卷未提交模版数量
24
+    int getUnCommitTemplateCount(@Param("mpid")Integer mpid);
25
+
26
+    //修改模板题块框选状态
27
+    int updateTemplateTbstate(@Param("mtid")Integer mtid, @Param("tbstate")Integer tbstate);
28
+
29
+    //获取试卷未框选主观题模板数量
30
+    int getUnSelTemplateCount(@Param("mpid")Integer mpid);
22 31
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsPaperBlock.java View File

@@ -5,6 +5,8 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
9
+import java.util.List;
8 10
 
9 11
 /**
10 12
  * @Description 阅卷试卷题块
@@ -33,4 +35,8 @@ public class MsPaperBlock extends BaseBean {
33 35
     private Integer createid;
34 36
     //创建时间
35 37
     private Integer createtime;
38
+
39
+    //题块下试题
40
+    @Transient
41
+    private List<MsPaperBlockQuestion> questions;
36 42
 }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsTemplate.java View File

@@ -53,6 +53,8 @@ public class MsTemplate extends BaseBean {
53 53
     private Integer currstep;
54 54
     //模板状态0未提交1已提交
55 55
     private Integer tstate;
56
+    //题块框选状态0默认1已提交
57
+    private Integer tbstate;
56 58
     //创建人ID
57 59
     private Integer createid;
58 60
     //创建时间

+ 0
- 41
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperBlockQuestionService.java View File

@@ -1,41 +0,0 @@
1
-package com.xhkjedu.smarking.service.paper;
2
-
3
-import com.xhkjedu.smarking.mapper.paper.MsPaperBlockQuestionMapper;
4
-import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
5
-import org.springframework.stereotype.Service;
6
-
7
-import javax.annotation.Resource;
8
-import java.util.List;
9
-
10
-/**
11
- * @Description 阅卷试卷题块试题表 服务实现类
12
- * @Author auto
13
- * @Date 2024-10-15
14
- */
15
-@Service
16
-public class MsPaperBlockQuestionService {
17
-    @Resource
18
-    private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
19
-
20
-    /**
21
-     * @Description 新增
22
-     * @Param [msPaperBlockQuestion]
23
-     * @Author auto
24
-     * @Date 2024-10-15
25
-     * @return void
26
-     **/
27
-    public void add(MsPaperBlockQuestion msPaperBlockQuestion){
28
-        msPaperBlockQuestionMapper.insert(msPaperBlockQuestion);
29
-    }
30
-
31
-    /**
32
-     * @Description 列表
33
-     * @Param [msPaperBlockQuestion]
34
-     * @Author auto
35
-     * @Date 2024-10-15
36
-     * @return java.util.List<com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion>
37
-     **/
38
-    public List<MsPaperBlockQuestion> queryList(MsPaperBlockQuestion msPaperBlockQuestion){
39
-        return msPaperBlockQuestionMapper.selectAll();
40
-    }
41
-}

+ 56
- 12
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperBlockService.java View File

@@ -1,10 +1,18 @@
1 1
 package com.xhkjedu.smarking.service.paper;
2 2
 
3 3
 import com.xhkjedu.smarking.mapper.paper.MsPaperBlockMapper;
4
+import com.xhkjedu.smarking.mapper.paper.MsPaperBlockQuestionMapper;
5
+import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
6
+import com.xhkjedu.smarking.model.paper.MsPaper;
4 7
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
8
+import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
9
+import com.xhkjedu.smarking.vo.paper.MsPaperParams;
10
+import com.xhkjedu.utils.N_Utils;
5 11
 import org.springframework.stereotype.Service;
12
+import org.springframework.transaction.annotation.Transactional;
6 13
 
7 14
 import javax.annotation.Resource;
15
+import java.util.ArrayList;
8 16
 import java.util.List;
9 17
 
10 18
 /**
@@ -16,26 +24,62 @@ import java.util.List;
16 24
 public class MsPaperBlockService {
17 25
     @Resource
18 26
     private MsPaperBlockMapper msPaperBlockMapper;
27
+    @Resource
28
+    private MsPaperMapper msPaperMapper;
29
+    @Resource
30
+    private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
19 31
 
20
-    /**
21
-     * @Description 新增
22
-     * @Param [msPaperBlock]
23
-     * @Author auto
24
-     * @Date 2024-10-15
25
-     * @return void
32
+    /*
33
+     * @Description 获取试卷所有题块
34
+     * @Date 2024/10/21 14:36:00
35
+     * @Author WN
36
+     * @Param [msid]
37
+     * @Return java.util.List<com.xhkjedu.smarking.model.paper.MsPaperBlock>
26 38
      **/
27
-    public void add(MsPaperBlock msPaperBlock){
28
-        msPaperBlockMapper.insert(msPaperBlock);
39
+    public List<MsPaperBlock> listPaperBlockQuestions(Integer msid){
40
+        Integer blocktype = 2;
41
+        return msPaperBlockMapper.listPaperBlockQuestions(msid,blocktype);
29 42
     }
30 43
 
44
+
31 45
     /**
32
-     * @Description 列表
46
+     * @Description 新增
33 47
      * @Param [msPaperBlock]
34 48
      * @Author auto
35 49
      * @Date 2024-10-15
36
-     * @return java.util.List<com.xhkjedu.smarking.model.paper.MsPaperBlock>
50
+     * @return void
37 51
      **/
38
-    public List<MsPaperBlock> queryList(MsPaperBlock msPaperBlock){
39
-        return msPaperBlockMapper.selectAll();
52
+    @Transactional(rollbackFor = Exception.class)
53
+    public Integer save(MsPaperParams params){
54
+        MsPaper paper = msPaperMapper.getPaperBaseByMsid(params.getMsid());
55
+        Integer mpid = paper.getMpid();
56
+        //先删除已存在题块
57
+        msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
58
+
59
+        Integer createid = paper.getCreateid();
60
+        Integer timestamp = N_Utils.getSecondTimestamp();
61
+        List<MsPaperBlock> blocks = params.getBlocks();
62
+        for(MsPaperBlock block : blocks){
63
+            block.setBlocktype(2);
64
+            block.setMpid(mpid);
65
+            block.setCreateid(createid);
66
+            block.setCreatetime(timestamp);
67
+        }
68
+        msPaperBlockMapper.insertList(blocks);
69
+
70
+        List<MsPaperBlockQuestion> questions = new ArrayList<>();
71
+        for(MsPaperBlock block : blocks){
72
+            List<MsPaperBlockQuestion> bqs = block.getQuestions();
73
+            for(MsPaperBlockQuestion bq : bqs){
74
+                bq.setMblockid(block.getId());
75
+                bq.setMpid(mpid);
76
+                bq.setCreateid(createid);
77
+                bq.setCreatetime(timestamp);
78
+                questions.add(bq);
79
+            }
80
+        }
81
+
82
+        msPaperBlockQuestionMapper.insertList(questions);
83
+        return mpid;
40 84
     }
41 85
 }

+ 22
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java View File

@@ -840,7 +840,7 @@ public class MsPaperQtypeService {
840 840
      **/
841 841
     public Map<String,Object> getPaperDetail(Integer msid){
842 842
         //获取试卷详情
843
-        Map<String,Object> paper = msPaperMapper.getPaperInfoByEsid(msid);
843
+        Map<String,Object> paper = msPaperMapper.getPaperInfoByMsid(msid);
844 844
         if(N_Utils.isEmpty((paper.get("ptype"))) || paper.get("ptype").equals("0")){
845 845
             return paper;
846 846
         }
@@ -867,4 +867,25 @@ public class MsPaperQtypeService {
867 867
         return paper;
868 868
 
869 869
     }
870
+
871
+
872
+    /*
873
+     * @Description 获取试卷中所有主观题(题型-试题)
874
+     * @Date 2024/10/21 13:50:54
875
+     * @Author WN
876
+     * @Param [mpid]
877
+     * @Return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
878
+     **/
879
+    public List<Map<String,Object>> listPaperSubjectiveQuestions(Integer mpid){
880
+        MsPaper paper = msPaperMapper.getPaperBaseByMsid(mpid);
881
+        int[] subjectivelist = N_Utils.subjectiveList;
882
+        // List<Map<String,Object>> rtnList = new ArrayList<>();
883
+        // if(paper.getPtype() == 1){
884
+        //
885
+        // }else{
886
+        //     rtnList = msPaperQtypeMapper.listSubjectiveQuestionsFj(mpid,subjectivelist);
887
+        // }
888
+
889
+        return msPaperQtypeMapper.listSubjectiveQuestionsFj(mpid,subjectivelist);
890
+    }
870 891
 }

+ 77
- 4
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsTemplateService.java View File

@@ -3,6 +3,7 @@ package com.xhkjedu.smarking.service.paper;
3 3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
4 4
 import com.xhkjedu.smarking.mapper.paper.*;
5 5
 import com.xhkjedu.smarking.model.paper.*;
6
+import com.xhkjedu.smarking.vo.paper.MsPaperParams;
6 7
 import com.xhkjedu.utils.N_Utils;
7 8
 import org.springframework.stereotype.Service;
8 9
 import org.springframework.transaction.annotation.Transactional;
@@ -54,9 +55,11 @@ public class MsTemplateService {
54 55
      * @return void
55 56
      **/
56 57
     @Transactional(rollbackFor = Exception.class)
57
-    public MsTemplate add(MsTemplate msTemplate){
58
+    public MsTemplate save(MsTemplate msTemplate){
58 59
         msTemplate.setCreatetime(N_Utils.getSecondTimestamp());
59 60
         msTemplate.setCurrstep(1);
61
+        msTemplate.setTstate(0);
62
+        msTemplate.setTbstate(0);
60 63
         msTemplateMapper.insertUseGeneratedKeys(msTemplate);
61 64
         int mtid = msTemplate.getId();
62 65
         msTemplate.setMtid(mtid);
@@ -66,24 +69,44 @@ public class MsTemplateService {
66 69
         return msTemplate;
67 70
     }
68 71
 
72
+    /*
73
+     * @Description 设置模版
74
+     * @Date 2024/10/21 10:47:00
75
+     * @Author WN
76
+     * @Param [msTemplate]
77
+     * @Return com.xhkjedu.smarking.model.paper.MsTemplate
78
+     **/
69 79
     @Transactional(rollbackFor = Exception.class)
70 80
     public MsTemplate updateTemplate(MsTemplate msTemplate){
71 81
         msTemplateMapper.updateTemplateForCurrstep(msTemplate);
72
-        Integer mpid = msTemplate.getMpid();
73 82
         //如果当前保存为6,则需要保存客观题信息
74 83
         if(msTemplate.getCurrstep() == 6){
75 84
             //模版题块信息
76 85
             List<MsTemplateBlock> tblocks = msTemplate.getTblocks();
77
-            savePaperBlock(tblocks,msTemplate);
86
+            savePaperBlockAndTemplate(tblocks,msTemplate);
87
+        }
88
+
89
+        if(msTemplate.getTstate()!=null && msTemplate.getTstate() == 1){
90
+            Integer mpid = msTemplate.getMpid();
91
+            //代表提交,获取试卷对应所有的模块状态,如果均是已提交,则更改科目表中状态
92
+            Integer uncommit = msTemplateMapper.getUnCommitTemplateCount(mpid);
93
+            if(uncommit == 0){
94
+                msSubjectMapper.updatePtstateByMpid(mpid,2);
95
+            }
78 96
         }
79 97
         return msTemplate;
80 98
     }
81 99
 
82
-    private void savePaperBlock(List<MsTemplateBlock> tblocks,MsTemplate msTemplate){
100
+    //保存客观题题块和模版信息
101
+    private void savePaperBlockAndTemplate(List<MsTemplateBlock> tblocks,MsTemplate msTemplate){
83 102
         Integer mpid = msTemplate.getMpid();
84 103
         Integer timestamp = N_Utils.getSecondTimestamp();
85 104
         Integer createid = msTemplate.getCreateid();
86 105
 
106
+        //保存之前先清除已保存的信息
107
+        msTemplateBlockMapper.deleteByMtidAndMtype(msTemplate.getMtid(),1);
108
+        msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,1);
109
+
87 110
         //客观题题块试题信息
88 111
         List<MsPaperBlockQuestion> savePbquestions = new ArrayList<>();
89 112
         //客观题模块试题信息
@@ -151,4 +174,54 @@ public class MsTemplateService {
151 174
     }
152 175
 
153 176
 
177
+    /*
178
+     * @Description 保存模板主观题框选
179
+     * @Date 2024/10/21 17:41:42
180
+     * @Author WN
181
+     * @Param [params]
182
+     * @Return void
183
+     **/
184
+    @Transactional(rollbackFor = Exception.class)
185
+    public void saveSubjectiveQuestion(MsPaperParams params){
186
+        Integer mtid = params.getMtid();
187
+        Integer mpid = params.getMpid();
188
+        Integer createid = params.getCreateid();
189
+        Integer timestamp = N_Utils.getSecondTimestamp();
190
+        List<MsTemplateBlock> templateBlocks = params.getTblocks();
191
+        //删除模块中题块定位数据
192
+        msTemplateBlockMapper.deleteByMtidAndMtype(mtid,2);
193
+
194
+        for (MsTemplateBlock templateBlock : templateBlocks){
195
+            templateBlock.setMtid(mtid);
196
+            templateBlock.setMttype(2);
197
+            templateBlock.setCreateid(createid);
198
+            templateBlock.setCreatetime(timestamp);
199
+
200
+            msTemplateBlockMapper.insertList(templateBlocks);
201
+        }
202
+        //更改模版题块框选状态
203
+        msTemplateMapper.updateTemplateTbstate(mtid,1);
204
+        //获取试卷中所有模版题块框选状态
205
+        int tbnum = msTemplateMapper.getUnSelTemplateCount(mpid);
206
+        Integer pbstate = 0;
207
+        if(tbnum == 0){
208
+            pbstate = 2;
209
+        }else{
210
+            pbstate = 1;
211
+
212
+        }
213
+        //更改科目题块框选状态
214
+        msSubjectMapper.updatePbstateByMpid(mpid,pbstate);
215
+    }
216
+
217
+    /*
218
+     * @Description 删除模板
219
+     * @Date 2024/10/21 17:49:46
220
+     * @Author WN
221
+     * @Param [mtid]
222
+     * @Return void
223
+     **/
224
+    public void deleteTemplate(Integer mtid){
225
+        msTemplateMapper.deleteByPrimaryKey(mtid);
226
+    }
154 227
 }

+ 24
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/paper/MsPaperParams.java View File

@@ -0,0 +1,24 @@
1
+package com.xhkjedu.smarking.vo.paper;
2
+
3
+import com.xhkjedu.smarking.model.paper.MsPaperBlock;
4
+import com.xhkjedu.smarking.model.paper.MsTemplateBlock;
5
+import lombok.Data;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * @Description:试卷题块参数
11
+ * @Author: WN
12
+ * @Date: 2024/10/21 15:28:46
13
+ **/
14
+@Data
15
+public class MsPaperParams {
16
+
17
+    private Integer msid; //试卷科目ID
18
+    private Integer mpid;//试卷ID
19
+    private Integer createid;//创建人ID
20
+    private List<MsPaperBlock> blocks; //试卷题块列表
21
+
22
+    private Integer mtid;//模板ID
23
+    private List<MsTemplateBlock> tblocks; //模板题块列
24
+}

+ 0
- 3
smarking/src/main/java/com/xhkjedu/smarking/vo/paper/MsPaperQtypeVo.java View File

@@ -17,9 +17,6 @@ public class MsPaperQtypeVo {
17 17
     //考试试卷题型表
18 18
     private Integer mptid;
19 19
 
20
-    // //处理题型
21
-    // private Integer ctype;
22
-
23 20
     //题型名称
24 21
     private String mptname;
25 22
 

+ 30
- 0
smarking/src/main/resources/mapper/paper/MsPaperBlockMapper.xml View File

@@ -1,4 +1,34 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.paper.MsPaperBlockMapper">
4
+
5
+    <resultMap id="paperBlockResultMap" type="com.xhkjedu.smarking.model.paper.MsPaperBlock">
6
+        <result property="mblockid" column="mblockid"/>
7
+        <result property="mpid" column="mpid"/>
8
+        <result property="blockname" column="blockname"/>
9
+        <result property="blocktype" column="blocktype"/>
10
+        <result property="blockorder" column="blockorder"/>
11
+        <result property="bqnum" column="bqnum"/>
12
+        <result property="bqscore" column="bqscore"/>
13
+        <collection property="questions" ofType="java.util.Map" javaType="java.util.List"></collection>
14
+    </resultMap>
15
+
16
+    <!--获取题块及题块下试题-->
17
+    <select id="listPaperBlockQuestions" resultMap="paperBlockResultMap">
18
+        select b.mblockid,b.mpid,b.blockname,b.blocktype,b.blockorder,b.bqnum,b.bqscore,
19
+        q.mbqid,q.mbqtype,q.mptqid,q.bqn,q.bqscore,q.bqorder,q.mergeqid,q.mergeqn,q.scorestepway,q.scorestep
20
+        from ms_paper_block b
21
+        left join ms_paper_block_question q on b.mblockid=q.mblockid
22
+        left join ms_paper p on b.mpid=p.mpid
23
+        where p.msid = #{msid} and b.blocktype=#{blocktype} order by b.blockorder,q.bqorder
24
+    </select>
25
+
26
+    <!--根据试卷ID删除题块-->
27
+    <delete id="deleteObjByMpidAndBlocktype">
28
+        delete from ms_paper_block where mpid = #{mpid}
29
+        <if test="blocktype!=null and blocktype > 0">
30
+            and blocktype = #{blocktype}
31
+        </if>
32
+    </delete>
33
+
4 34
 </mapper>

+ 6
- 1
smarking/src/main/resources/mapper/paper/MsPaperMapper.xml View File

@@ -15,7 +15,7 @@
15 15
     </update>
16 16
 
17 17
     <!--获取试卷详细信息-->
18
-    <select id="getPaperInfoByEsid" resultType="java.util.Map">
18
+    <select id="getPaperInfoByMsid" resultType="java.util.Map">
19 19
         select s.examid,s.msid,s.subjectname,s.sdate,s.begintime,s.endtime,e.gradeid,e.examtype,
20 20
         p.ptype,p.pnum,p.pscore,u.username as teachername,u.username as handlename
21 21
         from ms_subject s left join ms_paper p on s.msid=p.msid
@@ -76,4 +76,9 @@
76 76
         select eb.examstate from ms_paper ep left join ms_exam eb on ep.examid = eb.examid where ep.mpid=#{mpid}
77 77
     </select>
78 78
 
79
+    <!--获取试卷基础信息-->
80
+    <select id="getPaperBaseByMsid" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
81
+        select p.* from ms_paper p left join ms_subject s on s.msid=p.msid where s.msid=#{msid}
82
+    </select>
83
+
79 84
 </mapper>

+ 29
- 2
smarking/src/main/resources/mapper/paper/MsPaperQtypeMapper.xml View File

@@ -86,7 +86,6 @@
86 86
     <resultMap id="fjtypeQuestions" type="com.xhkjedu.smarking.vo.paper.MsPaperQtypeVo">
87 87
         <result column="mptid" property="mptid"></result>
88 88
         <result column="mpid" property="mpid"></result>
89
-        <result column="ctype" property="ctype"></result>
90 89
         <result column="mptname" property="mptname"></result>
91 90
         <result column="mptnum" property="mptnum"></result>
92 91
         <result column="mptorder" property="mptorder"></result>
@@ -105,10 +104,38 @@
105 104
         </collection>
106 105
     </resultMap>
107 106
     <select id="listPaperQtypeQuesitonsForFj" resultMap="fjtypeQuestions">
108
-        select  t.mptid,t.mpid,t.ctype,t.mptname,t.mptnum,t.mptorder,t.mptscore,
107
+        select  t.mptid,t.mpid,t.mptname,t.mptnum,t.mptorder,t.mptscore,
109 108
                 q.mptqid,q.qtypeid,q.qtypename,q.ctype,q.qscore,q.qn,q.qorder,q.qanswer,q.optionnum
110 109
         from ms_paper_qtype_question q left join ms_paper_qtype t on t.mptid=q.mptid
111 110
         where t.mpid=#{mpid} order by t.mptorder,q.qorder
112 111
     </select>
113 112
 
113
+    <!--获取试卷所有主观题-->
114
+    <resultMap id="subjectiveQuestions" type="java.util.Map">
115
+        <result column="mptid" property="mptid" />
116
+        <result column="mptname" property="mptname" />
117
+        <result column="mptnum" property="mptnum" />
118
+        <result column="mptorder" property="mptorder" />
119
+        <result column="mptscore" property="mptscore" />
120
+        <collection property="questions" ofType="java.util.Map" javaType="java.util.List">
121
+            <result column="mptqid" property="mptqid" />
122
+            <result column="qscore" property="qscore" />
123
+            <result column="qorder" property="qorder" />
124
+            <result column="qtypeid" property="qtypeid" />
125
+            <result column="qtypename" property="qtypename" />
126
+            <result column="ctype" property="ctype" />
127
+            <result column="qn" property="qn" />
128
+        </collection>
129
+    </resultMap>
130
+    <select id="listSubjectiveQuestionsFj" resultMap="subjectiveQuestions">
131
+        select t.mptid,t.mptname,t.mptnum,t.mptorder,t.mptscore,
132
+        q.mptqid,q.qtypeid,q.qtypename,q.ctype,q.qscore,q.qn,q.qorder
133
+        from ms_paper_qtype_question q left join ms_paper_qtype t on t.mptid=q.mptid
134
+        where t.mpid=#{mpid} and q.ctype in
135
+        <foreach collection="ctypes" item="c" open="(" separator="," close=")">
136
+            #{c}
137
+        </foreach>
138
+        order by t.mptorder,q.qorder
139
+    </select>
140
+
114 141
 </mapper>

+ 8
- 0
smarking/src/main/resources/mapper/paper/MsTemplateBlockMapper.xml View File

@@ -1,4 +1,12 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.paper.MsTemplateBlockMapper">
4
+    
5
+    <!--删除模板中指定类型题块信息-->
6
+    <delete id="deleteByMtidAndMtype">
7
+        delete from ms_template_block where mtid = #{mtid}
8
+        <if test="mtype!=null and mtype > 0">
9
+            and mtype = #{mtype}
10
+        </if>
11
+    </delete>
4 12
 </mapper>

+ 17
- 1
smarking/src/main/resources/mapper/paper/MsTemplateMapper.xml View File

@@ -28,8 +28,24 @@
28 28
             ,misscoor=#{t.misscoor}
29 29
         </if>
30 30
         <if test="t.currstep == 8">
31
-            ,violatecoor=#{t.violatecoor},tstate=#{t.tstate}
31
+            ,violatecoor=#{t.violatecoor}
32
+            <if test="t.tstate!=null and t.tstate==1">,tstate=1</if>
32 33
         </if>
33 34
         where mtid=#{t.mtid}
34 35
     </update>
36
+
37
+    <!--获取试卷未提交模板数量-->
38
+    <select id="getUnCommitTemplateCount" resultType="java.lang.Integer">
39
+        select count(*) from ms_template where mpid=#{mpid} and tstate=0
40
+    </select>
41
+
42
+    <!--修改模板题块框选状态-->
43
+    <update id="updateTemplateTbstate">
44
+        update ms_template set tbstate=#{tbstate} where mtid=#{mtid}
45
+    </update>
46
+
47
+    <!--获取试卷未框选主观题模板数量-->
48
+    <select id="getUnSelTemplateCount" resultType="java.lang.Integer">
49
+        select count(*) from ms_template where mpid=#{mpid} and tbstate=0
50
+    </select>
35 51
 </mapper>

Loading…
Cancel
Save