Explorar el Código

完善知识点计算中的分值分布

tags/正式3.10.0
王宁 hace 1 año
padre
commit
578bf28b21

+ 11
- 1
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java Ver fichero

@@ -1175,7 +1175,8 @@ public class N_Utils {
1175 1175
         BigDecimal bScore = new BigDecimal(Double.toString(score));
1176 1176
         BigDecimal bNum = new BigDecimal(Integer.toString(num));
1177 1177
 
1178
-        BigDecimal avg = bScore.divide(bNum, 1, BigDecimal.ROUND_DOWN);
1178
+        //2023-07-04通过四舍五入进行计算,
1179
+        BigDecimal avg = bScore.divide(bNum, 1, BigDecimal.ROUND_HALF_UP);
1179 1180
         BigDecimal avgAllScore = avg.multiply(bNum);//平均分乘以数量得到的分值
1180 1181
         if (bScore.equals(avgAllScore)) {
1181 1182
             //说明整除
@@ -1187,4 +1188,13 @@ public class N_Utils {
1187 1188
             return new Double[]{avg.doubleValue(), lastScore.doubleValue()};
1188 1189
         }
1189 1190
     }
1191
+
1192
+    public static void main(String[] args) {
1193
+        Double[] fz = getPointAvgScore(9, 20.0);
1194
+        Double[] jg = getPointAvgScore(9,17.0);
1195
+
1196
+        System.out.println("20÷9:" + fz[0] + ";" + fz[1]);
1197
+        System.out.println("17÷9:" + jg[0] + ";" + jg[1]);
1198
+
1199
+    }
1190 1200
 }

+ 18
- 13
sstudy/src/main/java/com/xhkjedu/sstudy/service/paperreport/PaperReportService.java Ver fichero

@@ -995,19 +995,24 @@ public class PaperReportService {
995 995
                 List<PaperPointStuScoreVo> gradepointstulist = gradestulist.stream().filter(s -> s.getPointid().equals(pointid)).collect(Collectors.toList());
996 996
 
997 997
                 List<PaperPointStuScoreVo> pointstuscorelist = new ArrayList<>(); // 知识点下多个试题,处理成单个学生总分值情况
998
-                Map<Integer, List<PaperPointStuScoreVo>> pointstuscoremap = gradepointstulist.stream().collect(Collectors.groupingBy(PaperPointStuScoreVo::getStudentid));
999
-                for (Map.Entry<Integer, List<PaperPointStuScoreVo>> entry : pointstuscoremap.entrySet()) {
1000
-                    List<PaperPointStuScoreVo> stuscorelist = entry.getValue();
1001
-                    Double stuscore = stuscorelist.stream().mapToDouble(PaperPointStuScoreVo::getStuscore).sum();
1002
-                    stuscore = N_Utils.formatDouble(stuscore, 1);
1003
-
1004
-                    PaperPointStuScoreVo sscorevofirst = stuscorelist.get(0);
1005
-                    PaperPointStuScoreVo sscorevo = new PaperPointStuScoreVo();
1006
-                    sscorevo.setStudentid(sscorevofirst.getStudentid());
1007
-                    sscorevo.setClassid(sscorevofirst.getClassid());
1008
-                    sscorevo.setStuscore(stuscore);
1009
-                    sscorevo.setSchoolid(sscorevofirst.getSchoolid());
1010
-                    pointstuscorelist.add(sscorevo);
998
+                //先按照班级进行分组,防止一个学生在多个班级收到多份作业
999
+                Map<Integer,List<PaperPointStuScoreVo>> pointclassscoremap = gradepointstulist.stream().collect(Collectors.groupingBy(PaperPointStuScoreVo::getClassid));
1000
+                for(Map.Entry<Integer, List<PaperPointStuScoreVo>> classEntry : pointclassscoremap.entrySet()){
1001
+                    List<PaperPointStuScoreVo> pointstuscoreList = classEntry.getValue();
1002
+                    Map<Integer, List<PaperPointStuScoreVo>> pointstuscoremap = pointstuscoreList.stream().collect(Collectors.groupingBy(PaperPointStuScoreVo::getStudentid));
1003
+                    for (Map.Entry<Integer, List<PaperPointStuScoreVo>> entry : pointstuscoremap.entrySet()) {
1004
+                        List<PaperPointStuScoreVo> stuscorelist = entry.getValue();
1005
+                        Double stuscore = stuscorelist.stream().mapToDouble(PaperPointStuScoreVo::getStuscore).sum();
1006
+                        stuscore = N_Utils.formatDouble(stuscore, 1);
1007
+
1008
+                        PaperPointStuScoreVo sscorevofirst = stuscorelist.get(0);
1009
+                        PaperPointStuScoreVo sscorevo = new PaperPointStuScoreVo();
1010
+                        sscorevo.setStudentid(sscorevofirst.getStudentid());
1011
+                        sscorevo.setClassid(sscorevofirst.getClassid());
1012
+                        sscorevo.setStuscore(stuscore);
1013
+                        sscorevo.setSchoolid(sscorevofirst.getSchoolid());
1014
+                        pointstuscorelist.add(sscorevo);
1015
+                    }
1011 1016
                 }
1012 1017
 
1013 1018
                 Map<Integer, List<PaperPointStuScoreVo>> schoolStuMap = pointstuscorelist.stream().collect(Collectors.groupingBy(PaperPointStuScoreVo::getSchoolid));

Loading…
Cancelar
Guardar