Browse Source

线上题块设置及相关学生题块信息

ywx
王宁 2 months ago
parent
commit
186dbe61af

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

@@ -1176,6 +1176,8 @@ public class N_Utils {
1176 1176
 
1177 1177
     //主观题处理题型
1178 1178
     public static int[] subjectiveList = new int[]{3,9,13,14,15};
1179
+    //客观题题型处理
1180
+    public static int[] objectiveList = new int[]{1,2,4,5,6,7,8,10,16,17};
1179 1181
 
1180 1182
     //简单题进行分项展示
1181 1183
     private static int[] simplelist = new int[]{1,2,4,5,6,7,8,10,16,17};

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperMapper.java View File

@@ -44,6 +44,9 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
44 44
     //根据科目id获取试卷基础信息
45 45
     MsPaper getPaperBaseByMsid(@Param("msid") Integer msid);
46 46
 
47
+    //获取试卷ID及考试模式
48
+    PExamSubjectVo getPaperAndMxammodeByMsid(@Param("msid") Integer msid);
49
+
47 50
     //根据考试id和科目id获取试卷信息
48 51
     MsPaper getPaperByExamIdAndSubjectId(@Param("examId") Integer examId, @Param("subjectId") String subjectId);
49 52
 
@@ -52,4 +55,7 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
52 55
 
53 56
     //根据考试科目ID获取试卷ID
54 57
     Integer getMpIdByMsId(@Param("msid") Integer msid);
58
+
59
+    //修改题块设置后试卷中试题数量
60
+    Integer updaePaperMeregpnumByMpid(@Param("mpid") Integer mpid, @Param("meregpnum") Integer meregpnum);
55 61
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperQtypeQuestionMapper.java View File

@@ -27,4 +27,7 @@ public interface MsPaperQtypeQuestionMapper extends TkMapper<MsPaperQtypeQuestio
27 27
 
28 28
     //清空试题难易度
29 29
     int updateComplexityByMpid(@Param("mpid")Integer mpid);
30
+
31
+    //获取试卷中所有客观题
32
+    List<MsPaperQtypeQuestion> listObjectiveQuestionByMpid(@Param("mpid")Integer mpid, @Param("list")int[] objtypes);
30 33
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentBlockMapper.java View File

@@ -16,6 +16,9 @@ public interface MsPaperStudentBlockMapper extends TkMapper<MsPaperStudentBlock>
16 16
     //根据学生试卷ID清空作答及批阅信息
17 17
     int updateStudentBlockQuestionByMpsid(@Param("mpsid")Integer mpsid);
18 18
 
19
+    //u清空试卷下所有学生作答及批阅信息
20
+    int updateStudentBlockQuestionByMpid(@Param("mpid")Integer mpid);
21
+
19 22
     //获取学生题块试题
20 23
     List<MsPaperStudentBlock> listPaperStuBlockQuestions(@Param("mpsid")Integer mpsid);
21 24
 

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentMapper.java View File

@@ -52,4 +52,6 @@ public interface MsPaperStudentMapper extends TkMapper<MsPaperStudent> {
52 52
     Integer getSubjectStateByMpsid(@Param("mpsid")Integer mpsid);
53 53
     //学生考试-提交试卷
54 54
     Integer updateStudentPaper(@Param("ps")MsPaperStudent ps);
55
+    //修改学生试卷设置题块收试题数量
56
+    Integer updatePaperMergepnumByMpid(@Param("mpid")Integer mpid,@Param("mergepnum")Integer mergepnum);
55 57
 }

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

@@ -29,6 +29,8 @@ public class MsPaper extends BaseBean {
29 29
     private Integer ptype;
30 30
     //试题数量
31 31
     private Integer pnum;
32
+    //合并后试题数量
33
+    private Integer mergepnum;
32 34
     //试卷总分
33 35
     private Double pscore;
34 36
     //是否设置正确答案0未设置1已设置

+ 1
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/exam/MsExamService.java View File

@@ -132,6 +132,7 @@ public class MsExamService {
132 132
             p.setSubjectid(s.getSubjectid());
133 133
             p.setPtype(0);
134 134
             p.setPnum(0);
135
+            p.setMergepnum(0);
135 136
             p.setPscore(0.0);
136 137
             p.setAnswered(0);
137 138
             p.setHasfile(0);

+ 62
- 11
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperBlockService.java View File

@@ -1,13 +1,14 @@
1 1
 package com.xhkjedu.smarking.service.paper;
2 2
 
3 3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
4
-import com.xhkjedu.smarking.mapper.paper.MsPaperBlockMapper;
5
-import com.xhkjedu.smarking.mapper.paper.MsPaperBlockQuestionMapper;
6
-import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
7
-import com.xhkjedu.smarking.model.paper.MsPaper;
4
+import com.xhkjedu.smarking.mapper.paper.*;
5
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentBlockMapper;
6
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
8 7
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
9 8
 import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
9
+import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion;
10 10
 import com.xhkjedu.smarking.vo.paper.MsPaperParams;
11
+import com.xhkjedu.smarking.vo.paper.PExamSubjectVo;
11 12
 import com.xhkjedu.utils.N_Utils;
12 13
 import org.springframework.stereotype.Service;
13 14
 import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +32,12 @@ public class MsPaperBlockService {
31 32
     private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
32 33
     @Resource
33 34
     private MsSubjectMapper msSubjectMapper;
35
+    @Resource
36
+    private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
37
+    @Resource
38
+    private MsPaperStudentBlockMapper msPaperStudentBlockMapper;
39
+    @Resource
40
+    private MsPaperStudentMapper msPaperStudentMapper;
34 41
 
35 42
     /*
36 43
      * @Description 获取试卷所有题块
@@ -54,23 +61,59 @@ public class MsPaperBlockService {
54 61
      **/
55 62
     @Transactional(rollbackFor = Exception.class)
56 63
     public Integer save(MsPaperParams params){
57
-        MsPaper paper = msPaperMapper.getPaperBaseByMsid(params.getMsid());
64
+        PExamSubjectVo paper = msPaperMapper.getPaperAndMxammodeByMsid(params.getMsid());
58 65
         Integer mpid = paper.getMpid();
59
-        //先删除已存在题块
60
-        msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
61 66
 
62
-        Integer createid = paper.getCreateid();
67
+        Integer createid = params.getCreateid();
63 68
         Integer timestamp = N_Utils.getSecondTimestamp();
69
+        List<MsPaperBlockQuestion> questions = new ArrayList<>();//保存的题块下试题
70
+        int papernum = 0;//试卷中试题总数量
71
+        if(paper.getExammode() == 3){
72
+            //线上考试,删除所有题块
73
+            msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,null);
74
+            //保存客观题相关题块
75
+            List<MsPaperQtypeQuestion> objQues = msPaperQtypeQuestionMapper.listObjectiveQuestionByMpid(mpid,N_Utils.objectiveList);
76
+            papernum = objQues.size();
77
+            Double bqscore = objQues.stream().mapToDouble(MsPaperQtypeQuestion::getQscore).sum();
78
+            MsPaperBlock obBlock = new MsPaperBlock();
79
+            obBlock.setMpid(mpid);
80
+            obBlock.setBlockname("客观题题块1");
81
+            obBlock.setBlocktype(1);
82
+            obBlock.setBlockorder(objQues.get(0).getQorder());
83
+            obBlock.setBqnum(papernum);
84
+            obBlock.setBqscore(bqscore);
85
+            obBlock.setCreateid(createid);
86
+            obBlock.setCreatetime(timestamp);
87
+            msPaperBlockMapper.insertUseGeneratedKeys(obBlock);
88
+            Integer mblockid = obBlock.getId();
89
+            for(MsPaperQtypeQuestion q : objQues){
90
+                MsPaperBlockQuestion bq = new MsPaperBlockQuestion();
91
+                bq.setMblockid(mblockid);
92
+                bq.setMpid(mpid);
93
+                bq.setMbqtype(1);
94
+                bq.setMptqid(q.getMptqid());
95
+                bq.setBqn(q.getQn());
96
+                bq.setBqscore(q.getQscore());
97
+                bq.setBqorder(q.getQorder());
98
+                bq.setCreateid(createid);
99
+                bq.setCreatetime(timestamp);
100
+                questions.add(bq);
101
+            }
102
+        }else{
103
+            //先删除已存在主观题题块
104
+            msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
105
+        }
106
+
64 107
         List<MsPaperBlock> blocks = params.getBlocks();
65 108
         for(MsPaperBlock block : blocks){
66 109
             block.setBlocktype(2);
67 110
             block.setMpid(mpid);
68 111
             block.setCreateid(createid);
69 112
             block.setCreatetime(timestamp);
113
+            papernum += block.getBqnum();
70 114
         }
71 115
         msPaperBlockMapper.insertList(blocks);
72
-
73
-        List<MsPaperBlockQuestion> questions = new ArrayList<>();
116
+        //保存题块下试题
74 117
         for(MsPaperBlock block : blocks){
75 118
             List<MsPaperBlockQuestion> bqs = block.getQuestions();
76 119
             for(MsPaperBlockQuestion bq : bqs){
@@ -83,9 +126,17 @@ public class MsPaperBlockService {
83 126
         }
84 127
 
85 128
         msPaperBlockQuestionMapper.insertList(questions);
129
+        int pbsate = 1;
130
+        if(paper.getExammode() == 3){
131
+            pbsate = 2;//线上考试,设置完题块,科目题块状态变为已完成;线下考试需要为题块框选
132
+        }
86 133
         //更改科目题块框选状态
87
-        msSubjectMapper.updatePbstateByMpid(mpid,1);//题块状态变成设置中
134
+        msSubjectMapper.updatePbstateByMpid(mpid,pbsate);//题块状态变成设置中
135
+        //修改试卷中合并后试题数量
136
+        msPaperMapper.updaePaperMeregpnumByMpid(mpid,papernum);
137
+        msPaperStudentMapper.updatePaperMergepnumByMpid(mpid, papernum);
88 138
         //保存完题块后,需要清除之前已经生产的学生答案、批阅信息之类的数据,
139
+        msPaperStudentBlockMapper.updateStudentBlockQuestionByMpid(mpid);
89 140
         //知识点,难易度关联需要重新处理;新的题块试题需要绑定知识点,难度度如何处理?
90 141
 
91 142
         return mpid;

+ 1
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/paper/PExamSubjectVo.java View File

@@ -21,5 +21,6 @@ public class PExamSubjectVo {
21 21
     private Integer exammode;
22 22
     //考试状态0未开始1已开始2已结束3已生成报告
23 23
     private Integer examstate;
24
+    private Integer mpid;//试卷ID
24 25
 
25 26
 }

+ 10
- 0
smarking/src/main/resources/mapper/paper/MsPaperMapper.xml View File

@@ -80,6 +80,10 @@
80 80
     <select id="getPaperBaseByMsid" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
81 81
         select p.* from ms_paper p left join ms_subject s on s.msid=p.msid where s.msid=#{msid}
82 82
     </select>
83
+    <!--获取试卷ID及考试模式-->
84
+    <select id="getPaperAndMxammodeByMsid" resultType="com.xhkjedu.smarking.vo.paper.PExamSubjectVo">
85
+        select p.mpid,e.exammode from ms_paper p left join ms_exam e on p.examid=e.examidwhere p.msid=#{msid}
86
+    </select>
83 87
     <!--根据考试id和科目id获取试卷信息-->
84 88
     <select id="getPaperByExamIdAndSubjectId" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
85 89
         select mpid, examid, msid, subjectid, ptype, pnum, pscore, answered, hasfile, hearnum, hearfile
@@ -94,4 +98,10 @@
94 98
     <select id="getMpIdByMsId" resultType="java.lang.Integer">
95 99
         select mpid from ms_paper where msid=#{msid}
96 100
     </select>
101
+
102
+    <!--修改题块设置后试卷中试题数量-->
103
+    <update id="updaePaperMeregpnumByMpid">
104
+        update ms_paper set mergepnum=#{mergepnum} where mpid=#{mpid}
105
+    </update>
106
+
97 107
 </mapper>

+ 9
- 0
smarking/src/main/resources/mapper/paper/MsPaperQtypeQuestionMapper.xml View File

@@ -71,4 +71,13 @@
71 71
     <update id="updateComplexityByMpid">
72 72
         update ms_paper_qtype_question set complexity=null where mpid=#{mpid}
73 73
     </update>
74
+
75
+    <!--获取试卷中所有客观题-->
76
+    <select id="listObjectiveQuestionByMpid" resultType="com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion">
77
+        select * from ms_paper_qtype_question where mpid=#{mpid} and ctype in
78
+        <foreach collection="list" item="c" open="(" close=")" separator="," >
79
+            #{c}
80
+        </foreach>
81
+        order by qorder
82
+    </select>
74 83
 </mapper>

+ 11
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentBlockMapper.xml View File

@@ -13,6 +13,17 @@
13 13
         q.hasbad=0,q.hasproblem=0,q.problemtype=0,q.problemcomm=null
14 14
         where b.mpsid = #{mpsid}
15 15
     </update>
16
+    <!--清空试卷下所有学生作答及批阅信息-->
17
+    <update id="updateStudentBlockQuestionByMpid">
18
+        update ms_paper_student_block b join ms_paper_student_question_merge q
19
+        on b.mpsid=q.mpsid and b.mpsbid=q.mpsbid
20
+            set b.stuanswer=null,b.hasproblem=0,b.problemtype=0,b.problemcomm=null,b.hasgood=0,
21
+                b.hasbad=0,b.hasfinal=0,b.finalreason=0,
22
+                q.answered=0,q.answertype=0,q.stuanswer=null,q.converted=0,q.answertime=0,q.stuscore=0,
23
+                q.checked=0,q.firstcid=null,q.firstcime=null,q.firstccore=0,q.secondcid=null,q.secondctime=null,q.secondcscore=0,q.arbitrateid=null,q.arbitratetime=null,q.arbitratescore=0,q.hasgood=0,
24
+                q.hasbad=0,q.hasproblem=0,q.problemtype=0,q.problemcomm=null
25
+        where b.mpid = #{mpid}
26
+    </update>
16 27
 
17 28
     <!--获取学生题块试题-->
18 29
     <resultMap id="stuBlockQuestions" type="com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock">

+ 5
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentMapper.xml View File

@@ -207,6 +207,11 @@
207 207
         where mpsid=#{ps.mpsid}
208 208
     </update>
209 209
 
210
+    <!--修改学生试卷设置题块收试题数量-->
211
+    <update id="updatePaperMergepnumByMpid">
212
+        update ms_paper_student set mergepnum=#{mergepnum} where mpid=#{mpid}
213
+    </update>
214
+
210 215
 
211 216
 
212 217
 

Loading…
Cancel
Save