caozixuan 4 жил өмнө
parent
commit
de4a992974

+ 26 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/AnswerDetailBean.java

@@ -3,6 +3,7 @@ package com.qmth.teachcloud.report.business.bean.dto;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 /**
  * @Description: answerDetailBean
@@ -25,6 +26,12 @@ public class AnswerDetailBean implements Serializable {
     @ApiModelProperty(value = "试卷类型")
     private String paperType;
 
+    @ApiModelProperty(value = "作答分数")
+    private BigDecimal answerScore;
+
+    @ApiModelProperty(value = "试卷题目分数")
+    private BigDecimal fullScore;
+
     @ApiModelProperty(value = "得分率")
     private Double scoreRate;
 
@@ -37,11 +44,13 @@ public class AnswerDetailBean implements Serializable {
     @ApiModelProperty(value = "学院id")
     private Long collegeId;
 
-    public AnswerDetailBean(Long teacherId, String teacherName, Long paperId, String paperType, Double scoreRate, String difficult, String collegeName, Long collegeId) {
+    public AnswerDetailBean(Long teacherId, String teacherName, Long paperId, String paperType, BigDecimal answerScore, BigDecimal fullScore, Double scoreRate, String difficult, String collegeName, Long collegeId) {
         this.teacherId = teacherId;
         this.teacherName = teacherName;
         this.paperId = paperId;
         this.paperType = paperType;
+        this.answerScore = answerScore;
+        this.fullScore = fullScore;
         this.scoreRate = scoreRate;
         this.difficult = difficult;
         this.collegeName = collegeName;
@@ -83,6 +92,22 @@ public class AnswerDetailBean implements Serializable {
         this.paperType = paperType;
     }
 
+    public BigDecimal getAnswerScore() {
+        return answerScore;
+    }
+
+    public void setAnswerScore(BigDecimal answerScore) {
+        this.answerScore = answerScore;
+    }
+
+    public BigDecimal getFullScore() {
+        return fullScore;
+    }
+
+    public void setFullScore(BigDecimal fullScore) {
+        this.fullScore = fullScore;
+    }
+
     public Double getScoreRate() {
         return scoreRate;
     }

+ 17 - 15
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -964,9 +964,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                             .filter(e -> paperId.equals(e.getPaperId()) && interpret.equals(e.getDifficult()))
                             .collect(Collectors.toList());
 
-                    double schAvgScoreRate = answerDetailForSch.stream()
-                            .collect(Collectors.summarizingDouble(AnswerDetailBean::getScoreRate))
-                            .getAverage();
+                    double schAvgScoreRate = 0;
+                    if (answerDetailForSch.size() > 0) {
+                        schAvgScoreRate = answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                    }
 
                     // 学院id集合
                     List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
@@ -983,10 +984,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                         List<AnswerDetailBean> answerDetailForCol = answerDetailForSch.stream()
                                 .filter(e -> collegeId.equals(e.getCollegeId())).collect(Collectors.toList());
 
-                        double colAvgScoreRate = answerDetailForCol.stream()
-                                .collect(Collectors.summarizingDouble(AnswerDetailBean::getScoreRate))
-                                .getAverage();
-
+                        double colAvgScoreRate = 0;
+                        if (answerDetailForCol.size() > 0){
+                            colAvgScoreRate = answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                        }
                         // 得分率保留2位小数处理
                         Integer count = questionList.size();
 
@@ -1032,7 +1033,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             List<TBCommonLevelConfig> configLevelDatasource = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
                     .eq(TBCommonLevelConfig::getExamId, examId)
                     .eq(TBCommonLevelConfig::getCourseCode, effectiveCourseCode)
-                    .eq(TBCommonLevelConfig::getLevelType,"难度等级"));// 该科目试题难度情况数据源
+                    .eq(TBCommonLevelConfig::getLevelType, "难度等级"));// 该科目试题难度情况数据源
 
             List<TAPaperStruct> questionDatasource = taPaperStructService.list(new QueryWrapper<TAPaperStruct>().lambda()
                     .eq(TAPaperStruct::getExamId, examId).eq(TAPaperStruct::getCourseCode, effectiveCourseCode));// 该科目试题情况数据源
@@ -1053,9 +1054,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                             .filter(e -> paperId.equals(e.getPaperId()) && interpret.equals(e.getDifficult()))
                             .collect(Collectors.toList());
 
-                    double schAvgScoreRate = answerDetailForSch.stream()
-                            .collect(Collectors.summarizingDouble(AnswerDetailBean::getScoreRate))
-                            .getAverage();
+                    double schAvgScoreRate = 0;
+                    if (answerDetailForSch.size() > 0) {
+                        schAvgScoreRate = answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                    }
 
                     // 教师id集合
                     List<Long> teacherIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
@@ -1072,13 +1074,13 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                         List<AnswerDetailBean> answerDetailForTea = answerDetailForSch.stream()
                                 .filter(e -> teacherId.equals(e.getTeacherId())).collect(Collectors.toList());
 
-                        double teaAvgScoreRate = answerDetailForTea.stream()
-                                .collect(Collectors.summarizingDouble(AnswerDetailBean::getScoreRate))
-                                .getAverage();
+                        double teaAvgScoreRate = 0;
+                        if (answerDetailForTea.size() > 0) {
+                            teaAvgScoreRate = answerDetailForTea.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForTea.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                        }
 
                         // 得分率保留2位小数处理
                         Integer count = questionList.size();
-
                         TAExamCourseTeacherDifficult taExamCourseTeacherDifficult = new TAExamCourseTeacherDifficult();
                         taExamCourseTeacherDifficult.setId(SystemConstant.getDbUuid());
                         taExamCourseTeacherDifficult.setExamId(examId);

+ 4 - 1
teachcloud-report-business/src/main/resources/mapper/TBAnswerMapper.xml

@@ -88,6 +88,8 @@
             struct.paper_id AS paperId,
             record.paper_type AS paperType,
             answer.score / struct.full_score AS scoreRate,
+            answer.score AS answerScore,
+            struct.full_score AS fullScore,
             struct.difficult AS difficult,
             college.name AS collegeName
         FROM
@@ -102,6 +104,7 @@
         WHERE
             record.exam_id = #{examId}
           AND record.course_code = #{courseCode}
-          AND record.absent = 0 ;
+          AND record.absent = 0
+          AND record.student_current = 1;
     </select>
 </mapper>

+ 14 - 0
teachcloud-report/src/test/java/com/qmth/teachcloud/report/AnalyzeForStudentServiceTest.java

@@ -75,6 +75,12 @@ public class AnalyzeForStudentServiceTest {
         System.out.println(analyzeForReportService.buildExamPaperDifficult(examId,null));
     }
 
+    @Test
+    public void buildExamPaperTeacherDifficult(){
+        Long examId = 1L;
+        System.out.println(analyzeForReportService.buildExamPaperTeacherDifficult(examId,null));
+    }
+
     @Test
     public void buildAnalyzeExamTotal() {
         Long examId = 1L;
@@ -102,6 +108,14 @@ public class AnalyzeForStudentServiceTest {
         analyzeForReportService.buildExamPaperTeacherDifficult(examId,null);
     }
 
+    @Test
+    public void buildDifficult(){
+        Long examId = 1L;
+        String courseCode = null;
+        analyzeForReportService.buildExamPaperDifficult(examId,courseCode);
+        analyzeForReportService.buildExamPaperTeacherDifficult(examId,courseCode);
+    }
+