Browse Source

优化举一反三试题列表

tags/正式3.2.0
雍文秀 2 years ago
parent
commit
4fc3ed993d

+ 6
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionClassMapper.java View File

@@ -71,4 +71,10 @@ public interface QuestionClassMapper extends TkMapper<TQuestionClass> {
71 71
 
72 72
     //根据试题id获取答题卡信息
73 73
     QuestionClassVo getScantronById(String questionid);
74
+
75
+    //获取试题是否被某人收藏
76
+    Integer getCollected(String questionid, Integer userid);
77
+
78
+    //获取试题关联知识点
79
+    String getPointName(String questionid);
74 80
 }

+ 9
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionClassService.java View File

@@ -341,6 +341,14 @@ public class QuestionClassService {
341 341
     public List<Map> listJYFSQuestion(String questionid, Integer userid, Integer schoolid) {
342 342
         String pointIds = questionClassMapper.getPointIds(questionid);
343 343
         if (N_Utils.isEmpty(pointIds)) return new ArrayList<>();
344
-        return questionClassMapper.listJYFSQuestion(pointIds, questionid, userid, schoolid);
344
+        List<Map> list = questionClassMapper.listJYFSQuestion(pointIds, questionid, userid, schoolid);
345
+        for (Map map : list) {
346
+            questionid = map.get("questionid").toString();
347
+            Integer collected = questionClassMapper.getCollected(questionid, userid);
348
+            map.put("collected",collected);
349
+            String pointname = questionClassMapper.getPointName(questionid);
350
+            map.put("pointname",pointname);
351
+        }
352
+        return list;
345 353
     }
346 354
 }

+ 10
- 4
sstudy/src/main/resources/mapper/question/QuestionClassMapper.xml View File

@@ -248,15 +248,21 @@
248 248
     <!--举一反三试题列表(随机返回3条)-->
249 249
     <select id="listJYFSQuestion" resultType="java.util.Map">
250 250
         select q.questionid,q.qtypeid,q.qtypename,q.complexity,q.count,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.ctype
251
-        ,(select count(*) from t_question_collect qc where qc.questionid=q.questionid)collected
252
-        ,group_concat(p.pointname)pointname
253 251
         from t_question_point qp left join t_question q on qp.questionid=q.questionid
254
-        left join t_question_point tqp on q.questionid=tqp.questionid
255
-        left join t_point p on tqp.pointid=p.pointid
256 252
         where qp.pointid in(${pointIds}) and qp.questionid!=#{questionid} and q.qstate=1
257 253
         and (q.belong in(1,2) or (q.schoolid=#{schoolid} and q.belong=3) or (q.createid=#{userid} and q.belong=4))
258 254
         group by qp.questionid order by rand() limit 3
259 255
     </select>
256
+    <!--获取试题是否被某人收藏-->
257
+    <select id="getCollected" resultType="java.lang.Integer">
258
+        select count(*) from t_question_collect qc where qc.questionid=#{questionid} and qc.userid=#{userid}
259
+    </select>
260
+    <!--获取试题关联知识点-->
261
+    <select id="getPointName" resultType="java.lang.String">
262
+        select group_concat(p.pointname)
263
+        from t_question_point qp left join t_point p on qp.pointid=p.pointid
264
+        where qp.questionid=#{questionid}
265
+    </select>
260 266
 
261 267
     <!-- 根据作业id获取作业附件 -->
262 268
     <select id="listObjsByPaperid" resultType="java.util.Map">

Loading…
Cancel
Save