|
|
|
@ -1,15 +1,15 @@
|
|
|
|
|
package com.ibeetl.jlw.entity.dto;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.util.ArrayUtil.join;
|
|
|
|
|
import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.PRE_SUBMIT;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -36,7 +36,7 @@ public class QuestionLogAddDTO {
|
|
|
|
|
* 附件上传:需要传递questionLogMap参数的value值,支持多个文件上传。Key值传不传无所谓,后台不取这个值。
|
|
|
|
|
*/
|
|
|
|
|
@NotEmpty(message = "提交答案不能为空")
|
|
|
|
|
private Map<String, TreeSet<String>> questionLogMap;
|
|
|
|
|
private Map<String, String> questionLogMap;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交时间(前端传)
|
|
|
|
@ -54,4 +54,30 @@ public class QuestionLogAddDTO {
|
|
|
|
|
// 默认值
|
|
|
|
|
setQuestionLogAddType(PRE_SUBMIT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 答案去重排序, 主要用于单选,多选,判断题的直接获取得分信息
|
|
|
|
|
* @param answersText
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String answerDistinctSort(@NotEmpty(message = "题目答案不能为空!") String answersText) {
|
|
|
|
|
return join(new TreeSet<>(Arrays.asList(answersText.split(","))).toArray(), ",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 字符串答案的排序去重,直接在Setting里面写
|
|
|
|
|
* @param questionLogMap
|
|
|
|
|
*/
|
|
|
|
|
public void setQuestionLogMap(Map<String, String> questionLogMap) {
|
|
|
|
|
this.questionLogMap = questionLogMap;
|
|
|
|
|
|
|
|
|
|
// 处理答案排序去重
|
|
|
|
|
if (ObjectUtil.isNotEmpty(questionLogMap)) {
|
|
|
|
|
Map<String, String> result = new HashMap<>(6);
|
|
|
|
|
questionLogMap.forEach((snapId, answersText) -> {
|
|
|
|
|
result.put(snapId, answerDistinctSort(answersText));
|
|
|
|
|
});
|
|
|
|
|
this.questionLogMap = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|