deason 5 years ago
parent
commit
54c000e759

+ 32 - 4
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_exam_student_score/ExportExamStudentScore.java

@@ -4,7 +4,6 @@ import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamQues
 import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamRecordQuestionVO;
 import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamStudentVO;
 import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ScoreVO;
-import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -49,7 +48,6 @@ public class ExportExamStudentScore {
          */
         HashMap<Long, List<Long>> examMaps = new HashMap<>();
         // examMaps.put(1L, Lists.list(1L, 2L, 3L));
-        examMaps.put(10L, Lists.list());
 
         // examMaps.put(808L, Lists.list());
         // examMaps.put(815L, Lists.list());
@@ -90,7 +88,7 @@ public class ExportExamStudentScore {
                 this.export(entry.getKey(), courseId, markingType, orgNameMaps, courseNameMaps);
             }
 
-            log.info("===> export finished, examId = " + entry.getKey());
+            log.info("===> export finished, examId = " + entry.getKey() + "\n");
         }
     }
 
@@ -210,7 +208,11 @@ public class ExportExamStudentScore {
             List<String> curDynamicColumnValues = new ArrayList<>();// Excel动态列当前值
             for (ExamQuestionVO question : examQuestionEntities) {
                 if ("SINGLE_CHOICE".equals(question.getQuestionType()) || "MULTIPLE_CHOICE".equals(question.getQuestionType()) || "TRUE_OR_FALSE".equals(question.getQuestionType())) {
-                    curDynamicColumnValues.add(question.getStudentAnswer());
+                    if ("TRUE_OR_FALSE".equals(question.getQuestionType())) {
+                        curDynamicColumnValues.add(this.convertTrueFalse(question.getStudentAnswer()));
+                    } else {
+                        curDynamicColumnValues.add(this.convertChar(question.getStudentAnswer()));
+                    }
                     curDynamicColumnValues.add(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
                 } else {
                     curDynamicColumnValues.add(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
@@ -388,4 +390,30 @@ public class ExportExamStudentScore {
         }
     }
 
+    private String convertChar(String value) {
+        if (StringUtils.isBlank(value)) {
+            return "";
+        }
+        return value.replaceAll("0", "A")
+                .replaceAll("1", "B")
+                .replaceAll("2", "C")
+                .replaceAll("3", "D")
+                .replaceAll("4", "E")
+                .replaceAll("5", "F")
+                .replaceAll("6", "G")
+                .replaceAll("7", "H")
+                .replaceAll("8", "I")
+                .replaceAll("9", "J");
+    }
+
+    private String convertTrueFalse(String value) {
+        if ("1".equals(value)) {
+            return "对";
+        } else if ("0".equals(value)) {
+            return "错";
+        } else {
+            return "";
+        }
+    }
+
 }