deason 4 gadi atpakaļ
vecāks
revīzija
35ec6dcc9a

+ 57 - 0
src/main/java/cn/com/qmth/examcloud/question/commons/core/question/AnswerType.java

@@ -0,0 +1,57 @@
+package cn.com.qmth.examcloud.question.commons.core.question;
+
+/**
+ * 作答类型
+ *
+ * @author WANGWEI
+ * @date 2019年5月9日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public enum AnswerType {
+
+    STRICT("S", "严格作答(可程序判分.如判断,单选...)"),
+    //
+    DIVERSIFIED_TEXT("DT", "多元化文本(不可程序判分.如非严格填空,简答...)"),
+    //
+    SINGLE_VIDEO("SV", "单个视频"),
+    //
+    SINGLE_AUDIO("SA", "单个音频"),
+    //
+    SINGLE_FILE("SF", "单个文件"),
+    //
+    SINGLE_PICTURE("SP", "单个照片"),
+    //
+    MULTIPLE_PICTURES("MP", "多个照片");
+
+    // ===========================================================================
+
+    /**
+     * 简码
+     */
+    private String code;
+
+    /**
+     * 描述
+     */
+    private String desc;
+
+    /**
+     * 构造函数
+     *
+     * @param code
+     * @param desc
+     */
+    private AnswerType(String code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+}

+ 60 - 0
src/main/java/cn/com/qmth/examcloud/question/commons/core/question/QuestionType.java

@@ -0,0 +1,60 @@
+package cn.com.qmth.examcloud.question.commons.core.question;
+
+/**
+ * 题型
+ *
+ * @author WANGWEI
+ * @date 2018年8月15日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public enum QuestionType {
+
+    /**
+     * 单选题
+     */
+    SINGLE_CHOICE("单选题"),
+
+    /**
+     * 多选题
+     */
+    MULTIPLE_CHOICE("多选题"),
+
+    /**
+     * 填空题
+     */
+    FILL_UP("填空题"),
+
+    /**
+     * 问答题
+     */
+    ESSAY("问答题"),
+
+    /**
+     * 判断题
+     */
+    TRUE_OR_FALSE("判断题");
+
+    // ===========================================================================
+
+    /**
+     * 描述
+     */
+    private String desc;
+
+    /**
+     * 构造函数
+     *
+     * @param desc
+     */
+    private QuestionType(String desc) {
+        this.desc = desc;
+    }
+
+    /**
+     * @return the desc
+     */
+    public String getDesc() {
+        return desc;
+    }
+
+}

+ 86 - 0
src/main/java/cn/com/qmth/examcloud/support/examing/ExamQuestion.java

@@ -0,0 +1,86 @@
+package cn.com.qmth.examcloud.support.examing;
+
+import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
+import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
+import lombok.Data;
+
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import java.io.Serializable;
+
+@Data
+public class ExamQuestion implements Serializable {
+
+    private static final long serialVersionUID = -6141069483774400912L;
+
+    /**
+     * 作答记录是否在mongo
+     */
+    private Boolean isInMongo;
+
+    /**
+     * 作答记录在mongo中的id
+     */
+    private String examQuestionTempId;
+
+    /**
+     * 考试记录Data Id
+     */
+    private Long examRecordDataId;
+    /**
+     * 大题号
+     */
+    private Integer mainNumber;
+    /**
+     * 原题ID
+     */
+    private String questionId;
+    /**
+     * 顺序
+     */
+    private Integer order;
+    /**
+     * 小题分数
+     */
+    private Double questionScore;
+    /**
+     * 小题类型
+     */
+    private QuestionType questionType;
+    /**
+     * 标准答案
+     */
+    private String correctAnswer;
+    /**
+     * 考生作答
+     */
+    private String studentAnswer;
+    /**
+     * 学生小题得分
+     */
+    private Double studentScore;
+    /**
+     * 是否作答
+     */
+    private Boolean isAnswer;
+    /**
+     * 是否标记
+     */
+    private Boolean isSign;
+
+    /**
+     * 选项排序值
+     */
+    private Integer[] optionPermutation;
+
+    /**
+     * 音频播放次数
+     */
+    private String audioPlayTimes;
+    /**
+     * 题目作答类型
+     */
+    @Enumerated(EnumType.STRING)
+    private AnswerType answerType;
+
+}

+ 74 - 1
src/main/java/cn/com/qmth/examcloud/tool/task/oe/InitExamEnvData.java

@@ -1,5 +1,13 @@
 package cn.com.qmth.examcloud.tool.task.oe;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
+import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
+import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
+import cn.com.qmth.examcloud.support.enums.HandInExamType;
+import cn.com.qmth.examcloud.support.enums.SyncStatus;
+import cn.com.qmth.examcloud.support.examing.ExamQuestion;
+import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.tool.config.RedisClient;
 import cn.com.qmth.examcloud.tool.task.Task;
 import org.slf4j.Logger;
@@ -7,6 +15,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 /**
  * 初始化考试环境检测数据
  */
@@ -21,8 +31,71 @@ public class InitExamEnvData implements Task {
     @Override
     public void start(String params) {
         log.info("task start... " + params);
-        // todo
+
+        /*  select * from ec_oe_exam_record_data where root_org_id=0 and exam_type = 'ONLINE' limit 1;  */
+
+        Long examRecordDataId = 1L; // dev
+        // Long examRecordDataId = 219245L; // test
+        // Long examRecordDataId = 4818250L; // prod
+
+        this.initExamRecordData(examRecordDataId);
+        this.initExamQuestion(examRecordDataId);
+
         log.info("task end...");
     }
 
+    private void initExamRecordData(Long examRecordDataId) {
+        ExamRecordData examRecordData = new ExamRecordData();
+        examRecordData.setId(examRecordDataId);
+        examRecordData.setExamStudentId(0L);
+        examRecordData.setStudentId(0L);
+
+        examRecordData.setBasePaperId("0");
+        examRecordData.setPaperType("X");
+        examRecordData.setQuestionCount(1);
+
+        examRecordData.setRootOrgId(0L);
+        examRecordData.setOrgId(0L);
+        examRecordData.setCourseId(0L);
+        examRecordData.setExamId(0L);
+        examRecordData.setExamType(ExamType.ONLINE);
+        examRecordData.setExamRecordStatus(ExamRecordStatus.EXAM_END);
+        examRecordData.setHandInExamType(HandInExamType.MANUAL);
+        examRecordData.setSyncStatus(SyncStatus.SYNCED);
+
+        examRecordData.setIsAllObjectivePaper(false);
+        examRecordData.setIsWarn(false);
+        examRecordData.setIsAudit(false);
+        examRecordData.setIsIllegality(false);
+        examRecordData.setIsContinued(false);
+        examRecordData.setContinuedCount(0);
+        examRecordData.setUsedExamTime(0L);
+
+        examRecordData.setStartTime(new Date());
+        examRecordData.setLastActiveTime(new Date());
+        examRecordData.setEnterExamTime(new Date());
+        examRecordData.setEndTime(new Date());
+
+        String key = "OE_ERD:" + examRecordData.getId();
+        redisClient.set(key, examRecordData);
+    }
+
+    private void initExamQuestion(Long examRecordDataId) {
+        ExamQuestion examQuestion = new ExamQuestion();
+        examQuestion.setExamRecordDataId(examRecordDataId);
+        examQuestion.setOrder(1);
+        examQuestion.setIsInMongo(false);
+
+        examQuestion.setMainNumber(1);
+        examQuestion.setQuestionType(QuestionType.ESSAY);
+        examQuestion.setQuestionScore(1.0);
+        examQuestion.setAnswerType(AnswerType.SINGLE_AUDIO);
+        examQuestion.setIsAnswer(false);
+        examQuestion.setExamQuestionTempId("1");
+        examQuestion.setQuestionId("1");
+
+        String key = "OE_ANSWER:" + examQuestion.getExamRecordDataId() + "_" + examQuestion.getOrder();
+        redisClient.set(key, examQuestion);
+    }
+
 }