Browse Source

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

ywx
王宁 3 months ago
parent
commit
186dbe61af

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

1176
 
1176
 
1177
     //主观题处理题型
1177
     //主观题处理题型
1178
     public static int[] subjectiveList = new int[]{3,9,13,14,15};
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
     private static int[] simplelist = new int[]{1,2,4,5,6,7,8,10,16,17};
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
     //根据科目id获取试卷基础信息
44
     //根据科目id获取试卷基础信息
45
     MsPaper getPaperBaseByMsid(@Param("msid") Integer msid);
45
     MsPaper getPaperBaseByMsid(@Param("msid") Integer msid);
46
 
46
 
47
+    //获取试卷ID及考试模式
48
+    PExamSubjectVo getPaperAndMxammodeByMsid(@Param("msid") Integer msid);
49
+
47
     //根据考试id和科目id获取试卷信息
50
     //根据考试id和科目id获取试卷信息
48
     MsPaper getPaperByExamIdAndSubjectId(@Param("examId") Integer examId, @Param("subjectId") String subjectId);
51
     MsPaper getPaperByExamIdAndSubjectId(@Param("examId") Integer examId, @Param("subjectId") String subjectId);
49
 
52
 
52
 
55
 
53
     //根据考试科目ID获取试卷ID
56
     //根据考试科目ID获取试卷ID
54
     Integer getMpIdByMsId(@Param("msid") Integer msid);
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
 
27
 
28
     //清空试题难易度
28
     //清空试题难易度
29
     int updateComplexityByMpid(@Param("mpid")Integer mpid);
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
     //根据学生试卷ID清空作答及批阅信息
16
     //根据学生试卷ID清空作答及批阅信息
17
     int updateStudentBlockQuestionByMpsid(@Param("mpsid")Integer mpsid);
17
     int updateStudentBlockQuestionByMpsid(@Param("mpsid")Integer mpsid);
18
 
18
 
19
+    //u清空试卷下所有学生作答及批阅信息
20
+    int updateStudentBlockQuestionByMpid(@Param("mpid")Integer mpid);
21
+
19
     //获取学生题块试题
22
     //获取学生题块试题
20
     List<MsPaperStudentBlock> listPaperStuBlockQuestions(@Param("mpsid")Integer mpsid);
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
     Integer getSubjectStateByMpsid(@Param("mpsid")Integer mpsid);
52
     Integer getSubjectStateByMpsid(@Param("mpsid")Integer mpsid);
53
     //学生考试-提交试卷
53
     //学生考试-提交试卷
54
     Integer updateStudentPaper(@Param("ps")MsPaperStudent ps);
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
     private Integer ptype;
29
     private Integer ptype;
30
     //试题数量
30
     //试题数量
31
     private Integer pnum;
31
     private Integer pnum;
32
+    //合并后试题数量
33
+    private Integer mergepnum;
32
     //试卷总分
34
     //试卷总分
33
     private Double pscore;
35
     private Double pscore;
34
     //是否设置正确答案0未设置1已设置
36
     //是否设置正确答案0未设置1已设置

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

132
             p.setSubjectid(s.getSubjectid());
132
             p.setSubjectid(s.getSubjectid());
133
             p.setPtype(0);
133
             p.setPtype(0);
134
             p.setPnum(0);
134
             p.setPnum(0);
135
+            p.setMergepnum(0);
135
             p.setPscore(0.0);
136
             p.setPscore(0.0);
136
             p.setAnswered(0);
137
             p.setAnswered(0);
137
             p.setHasfile(0);
138
             p.setHasfile(0);

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

1
 package com.xhkjedu.smarking.service.paper;
1
 package com.xhkjedu.smarking.service.paper;
2
 
2
 
3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
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
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
7
 import com.xhkjedu.smarking.model.paper.MsPaperBlock;
9
 import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
8
 import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
9
+import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion;
10
 import com.xhkjedu.smarking.vo.paper.MsPaperParams;
10
 import com.xhkjedu.smarking.vo.paper.MsPaperParams;
11
+import com.xhkjedu.smarking.vo.paper.PExamSubjectVo;
11
 import com.xhkjedu.utils.N_Utils;
12
 import com.xhkjedu.utils.N_Utils;
12
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
13
 import org.springframework.transaction.annotation.Transactional;
14
 import org.springframework.transaction.annotation.Transactional;
31
     private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
32
     private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
32
     @Resource
33
     @Resource
33
     private MsSubjectMapper msSubjectMapper;
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
      * @Description 获取试卷所有题块
43
      * @Description 获取试卷所有题块
54
      **/
61
      **/
55
     @Transactional(rollbackFor = Exception.class)
62
     @Transactional(rollbackFor = Exception.class)
56
     public Integer save(MsPaperParams params){
63
     public Integer save(MsPaperParams params){
57
-        MsPaper paper = msPaperMapper.getPaperBaseByMsid(params.getMsid());
64
+        PExamSubjectVo paper = msPaperMapper.getPaperAndMxammodeByMsid(params.getMsid());
58
         Integer mpid = paper.getMpid();
65
         Integer mpid = paper.getMpid();
59
-        //先删除已存在题块
60
-        msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
61
 
66
 
62
-        Integer createid = paper.getCreateid();
67
+        Integer createid = params.getCreateid();
63
         Integer timestamp = N_Utils.getSecondTimestamp();
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
         List<MsPaperBlock> blocks = params.getBlocks();
107
         List<MsPaperBlock> blocks = params.getBlocks();
65
         for(MsPaperBlock block : blocks){
108
         for(MsPaperBlock block : blocks){
66
             block.setBlocktype(2);
109
             block.setBlocktype(2);
67
             block.setMpid(mpid);
110
             block.setMpid(mpid);
68
             block.setCreateid(createid);
111
             block.setCreateid(createid);
69
             block.setCreatetime(timestamp);
112
             block.setCreatetime(timestamp);
113
+            papernum += block.getBqnum();
70
         }
114
         }
71
         msPaperBlockMapper.insertList(blocks);
115
         msPaperBlockMapper.insertList(blocks);
72
-
73
-        List<MsPaperBlockQuestion> questions = new ArrayList<>();
116
+        //保存题块下试题
74
         for(MsPaperBlock block : blocks){
117
         for(MsPaperBlock block : blocks){
75
             List<MsPaperBlockQuestion> bqs = block.getQuestions();
118
             List<MsPaperBlockQuestion> bqs = block.getQuestions();
76
             for(MsPaperBlockQuestion bq : bqs){
119
             for(MsPaperBlockQuestion bq : bqs){
83
         }
126
         }
84
 
127
 
85
         msPaperBlockQuestionMapper.insertList(questions);
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
         return mpid;
142
         return mpid;

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

21
     private Integer exammode;
21
     private Integer exammode;
22
     //考试状态0未开始1已开始2已结束3已生成报告
22
     //考试状态0未开始1已开始2已结束3已生成报告
23
     private Integer examstate;
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
     <select id="getPaperBaseByMsid" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
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}
81
         select p.* from ms_paper p left join ms_subject s on s.msid=p.msid where s.msid=#{msid}
82
     </select>
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
     <!--根据考试id和科目id获取试卷信息-->
87
     <!--根据考试id和科目id获取试卷信息-->
84
     <select id="getPaperByExamIdAndSubjectId" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
88
     <select id="getPaperByExamIdAndSubjectId" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
85
         select mpid, examid, msid, subjectid, ptype, pnum, pscore, answered, hasfile, hearnum, hearfile
89
         select mpid, examid, msid, subjectid, ptype, pnum, pscore, answered, hasfile, hearnum, hearfile
94
     <select id="getMpIdByMsId" resultType="java.lang.Integer">
98
     <select id="getMpIdByMsId" resultType="java.lang.Integer">
95
         select mpid from ms_paper where msid=#{msid}
99
         select mpid from ms_paper where msid=#{msid}
96
     </select>
100
     </select>
101
+
102
+    <!--修改题块设置后试卷中试题数量-->
103
+    <update id="updaePaperMeregpnumByMpid">
104
+        update ms_paper set mergepnum=#{mergepnum} where mpid=#{mpid}
105
+    </update>
106
+
97
 </mapper>
107
 </mapper>

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

71
     <update id="updateComplexityByMpid">
71
     <update id="updateComplexityByMpid">
72
         update ms_paper_qtype_question set complexity=null where mpid=#{mpid}
72
         update ms_paper_qtype_question set complexity=null where mpid=#{mpid}
73
     </update>
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
 </mapper>
83
 </mapper>

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

13
         q.hasbad=0,q.hasproblem=0,q.problemtype=0,q.problemcomm=null
13
         q.hasbad=0,q.hasproblem=0,q.problemtype=0,q.problemcomm=null
14
         where b.mpsid = #{mpsid}
14
         where b.mpsid = #{mpsid}
15
     </update>
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
     <resultMap id="stuBlockQuestions" type="com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock">
29
     <resultMap id="stuBlockQuestions" type="com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock">

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

207
         where mpsid=#{ps.mpsid}
207
         where mpsid=#{ps.mpsid}
208
     </update>
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