Kaynağa Gözat

试题栏中试题

tags/正式版本
王宁 2 yıl önce
ebeveyn
işleme
0fea6e9764

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java Dosyayı Görüntüle

@@ -93,4 +93,7 @@ public interface QuestionMapper extends TkMapper<TQuestion> {
93 93
      * @Date 2022/7/25 16:55
94 94
      **/
95 95
     void saveBathQuestion(@Param("list") List<TQuestion> list);
96
+
97
+    //获取科目下听力题数量
98
+    Integer getQuestionHasHearNum(@Param("subjectid")String subjectid);
96 99
 }

+ 5
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionService.java Dosyayı Görüntüle

@@ -371,6 +371,11 @@ public class QuestionService {
371 371
         question.setCreatetime(timestamp);
372 372
         String questionid = StudyUtil.getId();
373 373
         question.setQuestionid(questionid);
374
+
375
+        if(question.getHashear() == null){
376
+            question.setHashear(0);
377
+        }
378
+
374 379
         saveQues.add(question);
375 380
         map.put("questionid",questionid);
376 381
 

+ 40
- 5
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/UserBasketService.java Dosyayı Görüntüle

@@ -2,6 +2,7 @@ package com.xhkjedu.sstudy.service.question;
2 2
 
3 3
 import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
4 4
 import com.xhkjedu.sstudy.mapper.question.UserBasketMapper;
5
+import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
5 6
 import com.xhkjedu.sstudy.model.question.TUserBasket;
6 7
 import com.xhkjedu.utils.N_Utils;
7 8
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
@@ -9,6 +10,7 @@ import com.xhkjedu.sstudy.vo.question.UserBasketVo;
9 10
 import org.springframework.stereotype.Service;
10 11
 
11 12
 import javax.annotation.Resource;
13
+import java.util.ArrayList;
12 14
 import java.util.List;
13 15
 import java.util.stream.Collectors;
14 16
 
@@ -24,6 +26,8 @@ public class UserBasketService {
24 26
     private UserBasketMapper userBasketMapper;
25 27
     @Resource
26 28
     private QuestionMapper questionMapper;
29
+    @Resource
30
+    private SubjectMapper subjectMapper;
27 31
 
28 32
     //添加
29 33
     public Integer save(TUserBasket model) {
@@ -57,11 +61,42 @@ public class UserBasketService {
57 61
     //获取列表
58 62
     public List <UserBasketVo> findAll(Integer userid, String subjectid) {
59 63
         List<UserBasketVo> baskets = userBasketMapper.findAll(userid, subjectid);
60
-        for (UserBasketVo b : baskets) {
61
-            List<QuestionVo> questions = b.getQuestions();
62
-            b.setPtnum(questions.size());
63
-            Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
64
-            b.setPtscore(scoretotal);
64
+        String sujectname = subjectMapper.getSubjectnameById(subjectid);
65
+        //英语学科时处理听力题
66
+        if(sujectname.contains("英语")){
67
+            List<QuestionVo> hearqs  = new ArrayList<>();
68
+            for (UserBasketVo b : baskets) {
69
+                List<QuestionVo> questions = b.getQuestions();
70
+
71
+                List<QuestionVo> tllist = questions.stream().filter( o -> o.getHashear() ==1).collect(Collectors.toList());
72
+                if(N_Utils.isNotEmpty(tllist)){
73
+                    hearqs.addAll(tllist);
74
+
75
+                    questions = questions.stream().filter( o -> o.getHashear() ==0).collect(Collectors.toList());
76
+                }
77
+                b.setPtnum(questions.size());
78
+                Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
79
+                b.setPtscore(scoretotal);
80
+                b.setQuestions(questions);
81
+            }
82
+
83
+            if(N_Utils.isNotEmpty(hearqs)){
84
+                UserBasketVo tlvo = new UserBasketVo();
85
+                tlvo.setQtypename("听力题");
86
+                tlvo.setPtnum(hearqs.size());
87
+                Double scoretotal = hearqs.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
88
+                tlvo.setPtscore(scoretotal);
89
+                tlvo.setQuestions(hearqs);
90
+                baskets.add(0,tlvo);
91
+
92
+            }
93
+        }else{
94
+            for (UserBasketVo b : baskets) {
95
+                List<QuestionVo> questions = b.getQuestions();
96
+                b.setPtnum(questions.size());
97
+                Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
98
+                b.setPtscore(scoretotal);
99
+            }
65 100
         }
66 101
         return baskets;
67 102
     }

+ 8
- 5
sstudy/src/main/java/com/xhkjedu/sstudy/service/subjectbook/SubjectQuestiontypeService.java Dosyayı Görüntüle

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sstudy.service.subjectbook;
2 2
 
3
+import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
3 4
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
4 5
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectQuestiontypeMapper;
5 6
 import com.xhkjedu.sstudy.model.subjectbook.TSubjectQuestiontype;
@@ -9,6 +10,7 @@ import com.xhkjedu.sstudy.vo.subjectbook.SubjectQuestiontypeVo;
9 10
 import org.springframework.beans.factory.annotation.Autowired;
10 11
 import org.springframework.stereotype.Service;
11 12
 
13
+import javax.annotation.Resource;
12 14
 import java.util.HashMap;
13 15
 import java.util.List;
14 16
 import java.util.Map;
@@ -25,6 +27,8 @@ public class SubjectQuestiontypeService {
25 27
     private SubjectQuestiontypeMapper subjectQuestiontypeMapper;
26 28
     @Autowired
27 29
     private SubjectMapper subjectMapper;
30
+    @Resource
31
+    private QuestionMapper questionMapper;
28 32
 
29 33
     /**
30 34
      *功能描述 获取科目下所有题型
@@ -109,15 +113,14 @@ public class SubjectQuestiontypeService {
109 113
         String  subjectname = subjectMapper.getSubjectnameById(sqtype.getSubjectid());
110 114
         if(subjectname.contains("英语")){
111 115
             //如果是英语题获取英语题对应试题包含听力题的题型
112
-            List<Map> heartypes = subjectQuestiontypeMapper.listQtypesHasHear(sqtype);
113
-            if(heartypes!=null && heartypes.size()>0){
116
+//            List<Map> heartypes = subjectQuestiontypeMapper.listQtypesHasHear(sqtype);//获取有听力题的题型
117
+            Integer hearnum = questionMapper.getQuestionHasHearNum(sqtype.getSubjectid());
118
+            if(hearnum!=null && hearnum >0){
114 119
                 Map tlmap = new HashMap();
115 120
                 tlmap.put("qtypename","听力题");
116
-                tlmap.put("qtypes",heartypes);
117 121
                 list.add(0,tlmap);
118 122
             }
119 123
         }
120 124
         return list;
121 125
     }
122
-
123
-    }
126
+}

+ 5
- 0
sstudy/src/main/resources/mapper/question/QuestionMapper.xml Dosyayı Görüntüle

@@ -313,4 +313,9 @@
313 313
         </foreach>
314 314
     </insert>
315 315
 
316
+    <!--获取科目下听力题数量-->
317
+    <select id="getQuestionHasHearNum" resultType="java.lang.Integer">
318
+        select count(*) from t_question where hashear=1 and qstate=1 and subjectid=#{subjectid}
319
+    </select>
320
+
316 321
 </mapper>

+ 3
- 1
sstudy/src/main/resources/mapper/question/UserBasketMapper.xml Dosyayı Görüntüle

@@ -21,6 +21,8 @@
21 21
             <result property="count" column="count"></result>
22 22
             <result property="qlevel" column="qlevel"></result>
23 23
             <result property="snum" column="snum"></result>
24
+            <result property="hashear" column="hashear"></result>
25
+            <result property="hearfile" column="hearfile"></result>
24 26
             <collection property="points" ofType="com.xhkjedu.sstudy.vo.subjectbook.PointVo">
25 27
                 <result property="pointid" column="pointid"></result>
26 28
                 <result property="pointname" column="pointname"></result>
@@ -53,7 +55,7 @@
53 55
     </resultMap>
54 56
     <select id="findAll" resultMap="basketResult">
55 57
         select ub.*,q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.createtime
56
-        ,q.count,qp.pointid,p.pointname,q.qlevel,q.snum
58
+        ,q.count,qp.pointid,p.pointname,q.qlevel,q.snum,q.hashear,q.hearfile
57 59
         from t_user_basket ub left join t_subject_questiontype tsq on ub.qtypeid = tsq.qtypeid
58 60
         left join t_question q on ub.questionid = q.questionid
59 61
         left join t_question_point qp on q.questionid = qp.questionid

Loading…
İptal
Kaydet