Browse Source

课堂活跃度最后统一计算

tags/正式版本
雍文秀 2 years ago
parent
commit
9c88c75a66

+ 4
- 38
sclass/src/main/java/com/xhkjedu/sclass/controller/classroom/ClassroomController.java View File

@@ -3,28 +3,12 @@ package com.xhkjedu.sclass.controller.classroom;
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.github.pagehelper.PageHelper;
5 5
 import com.github.pagehelper.PageInfo;
6
-import com.xhkjedu.sclass.model.classroom.TClassroom;
7
-import com.xhkjedu.sclass.model.classroom.TClassroomActivestudent;
8
-import com.xhkjedu.sclass.model.classroom.TClassroomAskstudent;
9
-import com.xhkjedu.sclass.model.classroom.TClassroomAskteacher;
10
-import com.xhkjedu.sclass.model.classroom.TClassroomFile;
11
-import com.xhkjedu.sclass.model.classroom.TClassroomPaper;
12
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperFile;
13
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperQtype;
14
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperScantron;
15
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudent;
16
-import com.xhkjedu.sclass.model.classroom.TClassroomSign;
6
+import com.xhkjedu.sclass.model.classroom.*;
17 7
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudent;
18 8
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudentScantron;
19 9
 import com.xhkjedu.sclass.service.classroom.ClassroomPaperService;
20 10
 import com.xhkjedu.sclass.service.classroom.ClassroomService;
21
-import com.xhkjedu.sclass.vo.classroom.ObjectiveVo;
22
-import com.xhkjedu.sclass.vo.classroom.ReportEQuestionVo;
23
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectCallVo;
24
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectExamVo;
25
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectVo;
26
-import com.xhkjedu.sclass.vo.classroom.RoomVo;
27
-import com.xhkjedu.sclass.vo.classroom.SubjectiveVo;
11
+import com.xhkjedu.sclass.vo.classroom.*;
28 12
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
29 13
 import com.xhkjedu.sclass.vo.paperstudent.StudentVo;
30 14
 import com.xhkjedu.sclass.vo.room.RoomPVo;
@@ -71,7 +55,6 @@ public class ClassroomController {
71 55
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
72 56
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
73 57
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
74
-        List<TClassroomActivestudent> activestudentList = new ArrayList<>();//结束课堂集合
75 58
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
76 59
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
77 60
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
@@ -98,17 +81,9 @@ public class ClassroomController {
98 81
                 } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
99 82
                     TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
100 83
                     askstudentList.add(student);
101
-                    TClassroomActivestudent as = new TClassroomActivestudent();
102
-                    as.setRoomid(student.getRoomid());
103
-                    as.setStudentid(student.getStudentid());
104
-                    activestudentList.add(as);
105 84
                 } else if (rtype.equals("sign")) {//学生--签到
106 85
                     TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
107 86
                     signList.add(sign);
108
-                    TClassroomActivestudent as = new TClassroomActivestudent();
109
-                    as.setRoomid(sign.getRoomid());
110
-                    as.setStudentid(sign.getUserid());
111
-                    activestudentList.add(as);
112 87
                 } else if (rtype.equals("paper")) {//堂测--发布
113 88
                     TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
114 89
 
@@ -159,7 +134,7 @@ public class ClassroomController {
159 134
             });
160 135
         });
161 136
         return classroomService.batchSaveClass(startclassList, stopclassList, savefileList
162
-                , askteacherList, askstudentList, signList, activestudentList
137
+                , askteacherList, askstudentList, signList
163 138
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
164 139
     }
165 140
 
@@ -183,7 +158,6 @@ public class ClassroomController {
183 158
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
184 159
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
185 160
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
186
-        List<TClassroomActivestudent> activestudentList = new ArrayList<>();//结束课堂集合
187 161
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
188 162
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
189 163
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
@@ -207,17 +181,9 @@ public class ClassroomController {
207 181
             } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
208 182
                 TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
209 183
                 askstudentList.add(student);
210
-                TClassroomActivestudent as = new TClassroomActivestudent();
211
-                as.setRoomid(student.getRoomid());
212
-                as.setStudentid(student.getStudentid());
213
-                activestudentList.add(as);
214 184
             } else if (rtype.equals("sign")) {//学生--签到
215 185
                 TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
216 186
                 signList.add(sign);
217
-                TClassroomActivestudent as = new TClassroomActivestudent();
218
-                as.setRoomid(sign.getRoomid());
219
-                as.setStudentid(sign.getUserid());
220
-                activestudentList.add(as);
221 187
             } else if (rtype.equals("paper")) {//堂测--发布
222 188
                 TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
223 189
 
@@ -267,7 +233,7 @@ public class ClassroomController {
267 233
             }
268 234
         }
269 235
         return classroomService.saveClass(startclass, stopclass, savefileList
270
-                , askteacherList, askstudentList, signList, activestudentList
236
+                , askteacherList, askstudentList, signList
271 237
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
272 238
     }
273 239
 

+ 7
- 0
sclass/src/main/java/com/xhkjedu/sclass/mapper/classroom/ClassroomActivestudentMapper.java View File

@@ -44,4 +44,11 @@ public interface ClassroomActivestudentMapper extends TkMapper<TClassroomActives
44 44
 
45 45
     //批量更新活跃值排名
46 46
     void updateBatchActiveRank(@Param("roomids") List<Long> roomids);
47
+
48
+    //根据课堂id获取互动ids
49
+    String getAsktidsByRoomId(@Param("roomid") Long roomid);
50
+
51
+    //课堂学生
52
+    List<TClassroomActivestudent> listRoomStu(@Param("roomid") Long roomid, @Param("classid") Integer classid
53
+            ,@Param("asktids") String asktids);
47 54
 }

+ 43
- 51
sclass/src/main/java/com/xhkjedu/sclass/service/classroom/ClassroomService.java View File

@@ -1,40 +1,10 @@
1 1
 package com.xhkjedu.sclass.service.classroom;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
-import com.xhkjedu.sclass.mapper.classroom.ClassroomActivestudentMapper;
5
-import com.xhkjedu.sclass.mapper.classroom.ClassroomAskstudentMapper;
6
-import com.xhkjedu.sclass.mapper.classroom.ClassroomAskteacherMapper;
7
-import com.xhkjedu.sclass.mapper.classroom.ClassroomFileMapper;
8
-import com.xhkjedu.sclass.mapper.classroom.ClassroomMapper;
9
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperFileMapper;
10
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperMapper;
11
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperQtypeMapper;
12
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperScantronMapper;
13
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperStudentMapper;
14
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperStudentScantronMapper;
15
-import com.xhkjedu.sclass.mapper.classroom.ClassroomSignMapper;
16
-import com.xhkjedu.sclass.model.classroom.TClassroom;
17
-import com.xhkjedu.sclass.model.classroom.TClassroomActivestudent;
18
-import com.xhkjedu.sclass.model.classroom.TClassroomAskstudent;
19
-import com.xhkjedu.sclass.model.classroom.TClassroomAskteacher;
20
-import com.xhkjedu.sclass.model.classroom.TClassroomFile;
21
-import com.xhkjedu.sclass.model.classroom.TClassroomPaper;
22
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperFile;
23
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperQtype;
24
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperScantron;
25
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudent;
26
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudentScantron;
27
-import com.xhkjedu.sclass.model.classroom.TClassroomSign;
4
+import com.xhkjedu.sclass.mapper.classroom.*;
5
+import com.xhkjedu.sclass.model.classroom.*;
28 6
 import com.xhkjedu.sclass.utils.ArithUtil;
29
-import com.xhkjedu.sclass.vo.classroom.ObjectiveVo;
30
-import com.xhkjedu.sclass.vo.classroom.ReportEQuestionVo;
31
-import com.xhkjedu.sclass.vo.classroom.ReportExamVo;
32
-import com.xhkjedu.sclass.vo.classroom.ReportRoomVo;
33
-import com.xhkjedu.sclass.vo.classroom.RoomAskTeacherVo;
34
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectCallVo;
35
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectExamVo;
36
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectVo;
37
-import com.xhkjedu.sclass.vo.classroom.SubjectiveVo;
7
+import com.xhkjedu.sclass.vo.classroom.*;
38 8
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
39 9
 import com.xhkjedu.utils.N_Utils;
40 10
 import com.xhkjedu.vo.ResultVo;
@@ -46,10 +16,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
46 16
 import org.springframework.util.CollectionUtils;
47 17
 
48 18
 import javax.annotation.Resource;
49
-import java.util.ArrayList;
50
-import java.util.Arrays;
51
-import java.util.List;
52
-import java.util.Map;
19
+import java.util.*;
53 20
 import java.util.stream.Collectors;
54 21
 
55 22
 @Slf4j
@@ -556,7 +523,7 @@ public class ClassroomService {
556 523
      *
557 524
      * @return com.xhkjedu.vo.ResultVo
558 525
      * @Param [startclassList, stopclassList, savefileList, askteacherList, askstudentList, signList
559
-     * , activestudentList, paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
526
+     * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
560 527
      * @Author ywx
561 528
      * @Date 2022/6/28 16:51
562 529
      **/
@@ -564,7 +531,7 @@ public class ClassroomService {
564 531
     public ResultVo batchSaveClass(List<TClassroom> startclassList, List<TClassroom> stopclassList
565 532
             , List<TClassroomFile> savefileList
566 533
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList
567
-            , List<TClassroomSign> signList, List<TClassroomActivestudent> activestudentList
534
+            , List<TClassroomSign> signList
568 535
             , List<TClassroomPaper> paperList, List<TClassroomPaperStudent> stupaperList
569 536
             , List<TClassroomPaperFile> paperFileList, List<TClassroomPaperQtype> paperQtypeList
570 537
             , List<TClassroomPaperScantron> paperScantronList) {
@@ -577,16 +544,12 @@ public class ClassroomService {
577 544
             Map<Integer, Integer> classMap = classList.stream().collect(Collectors.toMap(TClassroom::getClassid, TClassroom::getClassnum));
578 545
             startclassList.forEach(r -> r.setClassnum(classMap.get(r.getClassid())));
579 546
             classroomMapper.batchSave(startclassList);//批量保存课堂
580
-            classroomActivestudentMapper.batchSaveStuActive(startclassList);//批量添加学生课堂活跃度
581 547
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
582 548
 
583 549
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
584 550
             if (N_Utils.isListNotEmpty(askstudentList))
585 551
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
586 552
 
587
-            if (N_Utils.isListNotEmpty(activestudentList))
588
-                classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
589
-
590 553
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
591 554
 
592 555
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
@@ -608,7 +571,9 @@ public class ClassroomService {
608 571
 
609 572
             List<Long> roomids = startclassList.stream().map(TClassroom::getRoomid).collect(Collectors.toList());
610 573
             classroomMapper.updateBatchRoomRealStunum(roomids);//批量更新班级实际签到学生数量
611
-            classroomActivestudentMapper.updateBatchActiveRank(roomids);//批量更新活跃值排名
574
+            for (TClassroom c : startclassList) {
575
+                saveStuActive(c.getRoomid(), c.getClassid(), c.getSchoolid());
576
+            }
612 577
 
613 578
             classroomMapper.updateBatchRoomState(classids);//批量结束之前班级的课堂状态
614 579
             resultVo.setCode(0);
@@ -735,14 +700,14 @@ public class ClassroomService {
735 700
      * 保存单个课堂数据
736 701
      *
737 702
      * @return com.xhkjedu.vo.ResultVo
738
-     * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList, activestudentList
703
+     * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList
739 704
      * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
740 705
      * @Author ywx
741 706
      * @Date 2022/6/30 11:12
742 707
      **/
743 708
     public ResultVo saveClass(TClassroom startclass, TClassroom stopclass, List<TClassroomFile> savefileList
744 709
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList, List<TClassroomSign> signList
745
-            , List<TClassroomActivestudent> activestudentList, List<TClassroomPaper> paperList
710
+            , List<TClassroomPaper> paperList
746 711
             , List<TClassroomPaperStudent> stupaperList, List<TClassroomPaperFile> paperFileList
747 712
             , List<TClassroomPaperQtype> paperQtypeList, List<TClassroomPaperScantron> paperScantronList) {
748 713
         ResultVo resultVo = new ResultVo();
@@ -755,16 +720,12 @@ public class ClassroomService {
755 720
             Integer num = classroomMapper.getStudentNumById(classid);//根据班级id获取学生数量
756 721
             startclass.setClassnum(num);
757 722
             classroomMapper.save(startclass);//批量保存课堂
758
-            classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//批量添加学生课堂活跃度
759 723
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
760 724
 
761 725
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
762 726
             if (N_Utils.isListNotEmpty(askstudentList))
763 727
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
764 728
 
765
-            if (N_Utils.isListNotEmpty(activestudentList))
766
-                classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
767
-
768 729
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
769 730
 
770 731
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
@@ -785,7 +746,7 @@ public class ClassroomService {
785 746
             if (stopclass != null) classroomMapper.endClass(stopclass);//批量结束课堂
786 747
 
787 748
             classroomMapper.updateBatchRoomRealStunum(Arrays.asList(roomid));//批量更新班级实际签到学生数量
788
-            classroomActivestudentMapper.updateActiveRank(roomid);//批量更新活跃值排名
749
+            classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//更新学生活跃度
789 750
 
790 751
             classroomMapper.updateBatchRoomState(Arrays.asList(classid));//批量结束之前班级的课堂状态
791 752
             resultVo.setCode(0);
@@ -798,6 +759,37 @@ public class ClassroomService {
798 759
         return resultVo;
799 760
     }
800 761
 
762
+    //更新学生活跃度 2022/10/17 课堂活跃度最后统一计算
763
+    public void saveStuActive(Long roomid, Integer classid, Integer schoolid) {
764
+        String asktids = classroomActivestudentMapper.getAsktidsByRoomId(roomid);
765
+        List<TClassroomActivestudent> students = classroomActivestudentMapper.listRoomStu(roomid, classid, asktids);
766
+        if(N_Utils.isListEmpty(students)) return;
767
+        Map<Integer, Integer> rank=new HashMap<>();
768
+        setRank(students,rank);//计算排名
769
+        int timestamp = N_Utils.getSecondTimestamp();
770
+        students.forEach(s -> {
771
+            s.setRoomid(roomid);
772
+            s.setSchoolid(schoolid);
773
+            s.setActiverank(rank.get(s.getActivenum()));
774
+            s.setCreatetime(timestamp);
775
+        });
776
+        classroomActivestudentMapper.insertList(students);
777
+    }
778
+
779
+    //计算排名
780
+    private void setRank(List<TClassroomActivestudent> students, Map<Integer, Integer> rank) {
781
+        List<Map.Entry<Integer, List<TClassroomActivestudent>>> gslist2 = students.stream()
782
+                .collect(Collectors.groupingBy(TClassroomActivestudent::getActivenum)).entrySet()
783
+                .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
784
+        Integer index = 1;
785
+        for (Map.Entry<Integer, List<TClassroomActivestudent>> entry : gslist2) {
786
+            for (TClassroomActivestudent cs : entry.getValue()) {
787
+                rank.put(cs.getActivenum(), index);
788
+            }
789
+            index = index + entry.getValue().size();
790
+        }
791
+    }
792
+
801 793
     /**
802 794
      * 根据课堂id获取课堂名称
803 795
      *

+ 14
- 0
sclass/src/main/resources/mapper/classroom/ClassroomActivestudentMapper.xml View File

@@ -43,4 +43,18 @@
43 43
             s.classid=${r.classid}
44 44
         </foreach>
45 45
     </insert>
46
+    <!--根据课堂id获取互动ids-->
47
+    <select id="getAsktidsByRoomId" resultType="java.lang.String">
48
+        select group_concat(asktid) from t_classroom_askteacher where roomid=#{roomid}
49
+    </select>
50
+    <!--课堂学生-->
51
+    <select id="listRoomStu" resultType="com.xhkjedu.sclass.model.classroom.TClassroomActivestudent">
52
+        select cs.studentid,(
53
+            (select count(distinct s.userid) from t_classroom_sign s where s.roomid=#{roomid} and s.userid=cs.studentid)
54
+        <if test="asktids!=null and asktids!=''">
55
+            +(select count(*) from t_classroom_askstudent s where s.asktid in(${asktids}) and s.studentid=cs.studentid)
56
+        </if>
57
+        )activenum
58
+        from t_class_student cs where cs.classid=#{classid}
59
+    </select>
46 60
 </mapper>

Loading…
Cancel
Save