瀏覽代碼

生成考试报告

ywx
雍文秀 2 週之前
父節點
當前提交
9c4409d33f

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsPaper.java 查看文件

@@ -64,5 +64,8 @@ public class MsPaper extends BaseBean {
64 64
     //试题
65 65
     @Transient
66 66
     private List<MsPaperQtypeQuestion> questions;
67
+    @Transient
68
+    //科目名称
69
+    private String subjectname;
67 70
 
68 71
 }

+ 3
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportother/MsrExam.java 查看文件

@@ -21,7 +21,9 @@ public class MsrExam extends BaseBean {
21 21
     private Integer examid;
22 22
     //班级数量
23 23
     private Integer classnum;
24
-    //学生数量
24
+    //总人数
25
+    private Integer totalnum;
26
+    //实考人数(参考人数)
25 27
     private Integer stunum;
26 28
     //缺考数量
27 29
     private Integer missnum;

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubject.java 查看文件

@@ -23,6 +23,8 @@ public class MsrSubject extends BaseBean {
23 23
     private String subjectid;
24 24
     //科目名称
25 25
     private String subjectname;
26
+    //满分
27
+    private Double fullscore;
26 28
     //最高分
27 29
     private Double maxscore;
28 30
     //最低分

+ 35
- 4
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java 查看文件

@@ -7,7 +7,9 @@ import com.xhkjedu.smarking.model.exam.*;
7 7
 import com.xhkjedu.smarking.model.paper.MsPaper;
8 8
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
9 9
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
10
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
10 11
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
12
+import com.xhkjedu.smarking.utils.MarkingUtil;
11 13
 import com.xhkjedu.utils.N_Utils;
12 14
 import org.springframework.stereotype.Service;
13 15
 
@@ -53,8 +55,9 @@ public class MsrExamService {
53 55
         List<MsPaperStudent> paperStudents = paperStudentMapper.listPaperStudentByExamId(examid, mpids);//试学生成绩列表
54 56
 
55 57
         Integer classnum = N_Utils.obj2Int(classes.stream().map(MsClass::getClassid).distinct().count());
56
-        Integer stunum = N_Utils.obj2Int(students.stream().map(MsClassStudent::getStudentid).distinct().count());
57
-        Integer sknum = N_Utils.obj2Int(paperStudents.stream().filter(s -> s.getSstate().equals(2)).map(MsPaperStudent::getStudentid).distinct().count());
58
+        Integer totalnum = N_Utils.obj2Int(students.stream().map(MsClassStudent::getStudentid).distinct().count());
59
+        Integer stunum = N_Utils.obj2Int(paperStudents.stream().filter(s -> s.getSstate().equals(2)).map(MsPaperStudent::getStudentid).distinct().count());
60
+        Integer missnum = totalnum - stunum;
58 61
         List<MsrStudent> schoolStudents = new ArrayList<>();//学校学生成绩
59 62
         List<MsrStudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
60 63
         List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩
@@ -130,20 +133,48 @@ public class MsrExamService {
130 133
         double schoolStatisticsMax = N_Utils.handleInfinity(schoolStatistics.getMax());
131 134
         //最低分均不包括0分
132 135
         double schoolStatisticsMin = N_Utils.handleInfinity(schoolStudents2.stream().filter(s -> s.getStuscore() > 0).mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
133
-
136
+        double schoolStatisticsAverage = N_Utils.formatDouble(schoolStatistics.getAverage(), 2);
134 137
 
135 138
         //总体分析
136 139
         MsrExam msrExam = new MsrExam();
137 140
         msrExam.setExamid(examid);
138 141
         msrExam.setClassnum(classnum);
142
+        msrExam.setTotalnum(totalnum);
139 143
         msrExam.setStunum(stunum);
140
-        msrExam.setMissnum(stunum - sknum);
144
+        msrExam.setMissnum(missnum);
141 145
         msrExam.setSubjectnum(subjects.size());
142 146
         msrExam.setMaxscore(schoolStatisticsMax);
143 147
         msrExam.setMinscore(schoolStatisticsMin);
144 148
         msrExam.setCreatetime(N_Utils.getSecondTimestamp());
145 149
         msrExamMapper.insert(msrExam);
146 150
 
151
+        //科目分析
152
+        Map<String, List<MsPaperStudent>> subjectCollect = paperStudents.stream().collect(Collectors.groupingBy(MsPaperStudent::getSubjectid));
153
+        double fullscore = subjects.stream().mapToDouble(MsPaper::getPscore).sum();
154
+        List<MsrSubject> msrSubjects = new ArrayList<>();
155
+        MsrSubject msrSubject = new MsrSubject();
156
+        msrSubject.setExamid(examid);
157
+        msrSubject.setSubjectid("zf");
158
+        msrSubject.setSubjectname("总分");
159
+        msrSubject.setFullscore(fullscore);
160
+        msrSubject.setMaxscore(schoolStatisticsMax);
161
+        msrSubject.setMinscore(schoolStatisticsMin);
162
+        msrSubject.setAvgscore(schoolStatisticsAverage);
163
+        msrSubject.setScorerate(N_Utils.getDoubleDivideAndMulitiply(schoolStatisticsAverage, fullscore));
164
+        msrSubject.setTotalnum(totalnum);
165
+        msrSubject.setStunum(stunum);
166
+        msrSubject.setMissnum(missnum);
167
+        msrSubjects.add(msrSubject);
168
+        for (MsPaper subject : subjects) {
169
+            msrSubject = new MsrSubject();
170
+            msrSubject.setExamid(examid);
171
+            msrSubject.setSubjectid(subject.getSubjectid());
172
+            msrSubject.setSubjectname(subject.getSubjectname());
173
+            msrSubject.setFullscore(subject.getPscore());
174
+            List<MsPaperStudent> studentList = subjectCollect.get(subject.getSubjectid());
175
+            msrSubjects.add(msrSubject);
176
+        }
177
+
147 178
         examMapper.updateExamState(examid, 3);
148 179
     }
149 180
 

+ 22
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java 查看文件

@@ -363,6 +363,28 @@ public class MarkingUtil {
363 363
         return result;
364 364
     }
365 365
 
366
+    //方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
367
+    public static double fc(List<Double> x) {
368
+        if (N_Utils.isListEmpty(x)) return 0;
369
+        int m = x.size();
370
+        double sum = 0;
371
+        for (int i = 0; i < m; i++) {//求和
372
+            sum += x.get(i);
373
+        }
374
+        double dAve = sum / m;//求平均值
375
+        double dVar = 0;
376
+        for (int i = 0; i < m; i++) {//求方差
377
+            dVar += (x.get(i) - dAve) * (x.get(i) - dAve);
378
+        }
379
+        return dVar / m;
380
+    }
381
+
382
+    //标准差σ=sqrt(s^2)
383
+    public static double bzc(List<Double> x) {
384
+        if (N_Utils.isListEmpty(x)) return 0;
385
+        return N_Utils.formatDouble(Math.sqrt(fc(x)), 2);
386
+    }
387
+
366 388
     public static void main(String[] args) {
367 389
         String str = "ADAC-D-(C)(AB)(CD)(ACB)BB";
368 390
 

+ 1
- 1
smarking/src/main/resources/mapper/exam/MsSubjectMapper.xml 查看文件

@@ -167,7 +167,7 @@
167 167
     </select>
168 168
     <!--考试报告科目列表-->
169 169
     <select id="listReportSubject" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
170
-        select s.subjectid,p.mpid,p.pnum,p.mergepnum,p.pscore,p.correcttype
170
+        select s.subjectid,s.subjectname,p.mpid,p.pnum,p.mergepnum,p.pscore,p.correcttype
171 171
         from ms_subject s inner join ms_paper p on s.msid=p.msid
172 172
         where s.examid=#{examid}
173 173
         <if test="exammode!=3">

Loading…
取消
儲存