|
@@ -22,12 +22,12 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
public class MyConsumer extends Consumer<PaperExportDto> {
|
|
|
- private static String[] sucStr = new String[] { "对", "正确", "√", "是", "True" };
|
|
|
- private static String[] errStr = new String[] { "错", "错误", "×", "不正确", "否", "False" };
|
|
|
+// private static String[] sucStr = new String[] { "对", "正确", "√", "是", "True" };
|
|
|
+// private static String[] errStr = new String[] { "错", "错误", "×", "不正确", "否", "False" };
|
|
|
// private static String paperSuff = "(231205)";
|
|
|
private int maxqc = 200;
|
|
|
|
|
|
- private static String paperDir = "d:/yunkai/paper/";
|
|
|
+ private static String paperDir = "d:/guangkai/paper/";
|
|
|
|
|
|
private Pattern imgPat = Pattern.compile("<img[^<]+src=\"([^<\"]+)\"[^<]*>");
|
|
|
|
|
@@ -39,7 +39,7 @@ public class MyConsumer extends Consumer<PaperExportDto> {
|
|
|
try {
|
|
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
|
|
|
|
|
- String url = "jdbc:mysql://localhost:3306/"+dto.getDbName()+"?serverTimezone=GMT%2B8";
|
|
|
+ String url = "jdbc:mysql://localhost:3306/" + dto.getDbName() + "?serverTimezone=GMT%2B8";
|
|
|
|
|
|
String user = "root";
|
|
|
|
|
@@ -59,34 +59,162 @@ public class MyConsumer extends Consumer<PaperExportDto> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<KdQuestion> getQuestion(Connection connect, String courseCode) throws SQLException, IOException {
|
|
|
- List<KdQuestion> qs = new ArrayList<>();
|
|
|
+ private List<KdQuestion> of(List<QuestionVo> vos,List<QuestionVo> subvosList) {
|
|
|
+ List<KdQuestion> ret=new ArrayList<>();
|
|
|
+ Map<String,List<QuestionVo>> submap=new HashMap<>();
|
|
|
+ if(CollectionUtils.isNotEmpty(subvosList)) {
|
|
|
+ for(QuestionVo vo:subvosList) {
|
|
|
+ List<QuestionVo> tem=submap.get(vo.getPid());
|
|
|
+ if(tem==null) {
|
|
|
+ tem=new ArrayList<>();
|
|
|
+ submap.put(vo.getPid(), tem);
|
|
|
+ }
|
|
|
+ tem.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(QuestionVo vo:vos) {
|
|
|
+ KdQuestion q=of(vo);
|
|
|
+ ret.add(q);
|
|
|
+ if(QuesStructType.NESTED_ANSWER_QUESTION.equals(q.getQuesStructType())) {
|
|
|
+ List<QuestionVo> subvos=submap.get(q.getId());
|
|
|
+ q.setScore((double)subvos.size());
|
|
|
+ List<Double> subScores=new ArrayList<>();
|
|
|
+ List<KdQuestion> subQues=new ArrayList<>();
|
|
|
+ q.setSubScores(subScores);
|
|
|
+ q.setSubQuestions(subQues);
|
|
|
+ int num=0;
|
|
|
+ for(QuestionVo subvo:subvos) {
|
|
|
+ num++;
|
|
|
+ subScores.add(1.0);
|
|
|
+ KdQuestion subq=of(subvo);
|
|
|
+ subq.setId(null);
|
|
|
+ if(CusQuesStructType.cloze.equals(q.getCusType())&&StringUtils.isBlank(subq.getBody())) {
|
|
|
+ subq.setBody("___"+num+"___");
|
|
|
+ }
|
|
|
+ subQues.add(subq);
|
|
|
+ }
|
|
|
+ if(CusQuesStructType.cloze.equals(q.getCusType())) {
|
|
|
+ q.setBody(changeCloze(q.getBody()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String changeCloze(String text) {
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ String regex = "<fillblank/>";
|
|
|
+
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(text);
|
|
|
+ // 使用find()方法查找匹配项
|
|
|
+ int num=0;
|
|
|
+ while (matcher.find()) {
|
|
|
+ num++;
|
|
|
+ matcher.appendReplacement(buffer, "___"+num+"___");
|
|
|
+ }
|
|
|
+ matcher.appendTail(buffer);
|
|
|
+ return buffer.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private KdQuestion of(QuestionVo vo) {
|
|
|
+ KdQuestion q=new KdQuestion();
|
|
|
+ q.setCusType(vo.getqType());
|
|
|
+ q.setQuesStructType(QuesStructType.getQuesStructTypeById(vo.getqType().getTypeId()));
|
|
|
+ if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(q.getQuesStructType())) {
|
|
|
+ List<KdQuesOption> options=new ArrayList<>();
|
|
|
+ q.setOptions(options);
|
|
|
+ int num=0;
|
|
|
+ boolean cel=false;
|
|
|
+ for(String a:vo.getAnswer().getSubArea()) {
|
|
|
+ num++;
|
|
|
+ KdQuesOption o=new KdQuesOption();
|
|
|
+ options.add(o);
|
|
|
+ o.setNumber(num);
|
|
|
+ o.setBody(a);
|
|
|
+ o.setSelect(vo.getAnswer().getAnswer().contains(""+(num-1)));
|
|
|
+ if(o.getSelect()) {
|
|
|
+ cel=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!cel) {
|
|
|
+ throw new StatusException("没有答案");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!QuesStructType.NESTED_ANSWER_QUESTION.equals(q.getQuesStructType())) {
|
|
|
+ q.setAnswer(StringUtils.join(vo.getAnswer().getAnswer(),""));
|
|
|
+ }
|
|
|
+ q.setTypeId(vo.getTypeId());
|
|
|
+ q.setDetailName(vo.getTypeName());
|
|
|
+ q.setBody(vo.getBody());
|
|
|
+ q.setDifficulty(YunkaiDifficulty.ZHONGDENG);
|
|
|
+ q.setHaveAudio(false);
|
|
|
+ q.setId(vo.getQid());
|
|
|
+ q.setScore(1.0);
|
|
|
+ return q;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<QuestionVo> getQuestion(Connection connect, String courseCode) throws SQLException, IOException {
|
|
|
+ List<QuestionVo> qs = new ArrayList<>();
|
|
|
PreparedStatement preState = null;
|
|
|
ResultSet resultSet = null;
|
|
|
try {
|
|
|
- String sql = " select q.id,q.question_type,q.topic,q.difficulty,q.answer "
|
|
|
- + " from wq_question_bank_subject t " + " left join wq_subject sub on t.subject_id=sub.id"
|
|
|
- + " left join wq_question_bank b on t.question_bank_id=b.id "
|
|
|
- + " left join wq_question_question_bank f on t.question_bank_id=f.question_bank_id "
|
|
|
- + " left join wq_question q on f.question_id=q.id " + " where sub.subject_code='" + courseCode
|
|
|
- + "' and b.rent_id=811 and b.is_deleted=0 " + " and q.is_deleted=0 and q.rent_id=811 ";
|
|
|
+ String sql = " select q.TYPE_ID typeId,f.name typeName,f.ANSWER_TYPE qType " + " ,q.ID qid,q.TITLE body,q.FATHER_ID pid "
|
|
|
+ + " ,q.answer,q.SHOW_ORDER seq " + " from pe_question_bank t "
|
|
|
+ + " INNER JOIN pe_questions q on t.id=q.BANK_ID "
|
|
|
+ + " INNER JOIN pe_question_type f on f.id=q.TYPE_ID " + " where t.course_id=" + courseCode;
|
|
|
|
|
|
preState = connect.prepareStatement(sql);
|
|
|
|
|
|
resultSet = preState.executeQuery();
|
|
|
|
|
|
while (resultSet.next()) {
|
|
|
- KdQuestion q = new KdQuestion();
|
|
|
- q.setId(resultSet.getLong("id"));
|
|
|
- q.setBody(disposeImg(resultSet.getString("topic"), courseCode));
|
|
|
- q.setQst(YunkaiQuesStructType.getByYunKaiType(resultSet.getInt("question_type")));
|
|
|
- q.setDifficulty(YunkaiDifficulty.getByYunKaiType(resultSet.getInt("difficulty")));
|
|
|
-// if (!q.getQst().isObjective()) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// q.setDifficulty(YunkaiDifficulty.ZHONGDENG);
|
|
|
- q.setAnswer(disposeImg(resultSet.getString("answer"), courseCode));
|
|
|
- q.setObjective(q.getQst().isObjective());
|
|
|
+ QuestionVo q = new QuestionVo();
|
|
|
+ q.setQid(resultSet.getString("qid"));
|
|
|
+ q.setTypeId(resultSet.getString("typeId"));
|
|
|
+ q.setTypeName(resultSet.getString("typeName"));
|
|
|
+ q.setPid(resultSet.getString("pid"));
|
|
|
+ q.setqType(CusQuesStructType.valueOf(resultSet.getString("qType")));
|
|
|
+ q.setBody(disposeImg(resultSet.getString("body"), courseCode));
|
|
|
+ q.setAnswer(JSONObject.parseObject(resultSet.getString("answer"), AnswerVo.class));
|
|
|
+ q.setSeq(resultSet.getInt("seq"));
|
|
|
+ qs.add(q);
|
|
|
+ }
|
|
|
+ return qs;
|
|
|
+ } finally {
|
|
|
+ if (resultSet != null) {
|
|
|
+ resultSet.close();
|
|
|
+ }
|
|
|
+ if (preState != null) {
|
|
|
+ preState.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<QuestionVo> getSubQuestion(Connection connect, String courseCode, List<String> pids)
|
|
|
+ throws SQLException, IOException {
|
|
|
+ List<QuestionVo> qs = new ArrayList<>();
|
|
|
+ PreparedStatement preState = null;
|
|
|
+ ResultSet resultSet = null;
|
|
|
+ try {
|
|
|
+ String sql = " select f.name typeName,f.ANSWER_TYPE qType " + " ,q.ID qid,q.TITLE body,q.FATHER_ID pid "
|
|
|
+ + " ,q.answer,q.SHOW_ORDER seq " + " from pe_questions q "
|
|
|
+ + " INNER JOIN pe_question_type f on f.id=q.TYPE_ID " + " where q.FATHER_ID in ('"
|
|
|
+ + StringUtils.join(pids, "','") + "') order by q.SHOW_ORDER";
|
|
|
+
|
|
|
+ preState = connect.prepareStatement(sql);
|
|
|
+
|
|
|
+ resultSet = preState.executeQuery();
|
|
|
+
|
|
|
+ while (resultSet.next()) {
|
|
|
+ QuestionVo q = new QuestionVo();
|
|
|
+ q.setQid(resultSet.getString("qid"));
|
|
|
+ q.setTypeName(resultSet.getString("typeName"));
|
|
|
+ q.setPid(resultSet.getString("pid"));
|
|
|
+ q.setqType(CusQuesStructType.valueOf(resultSet.getString("qType")));
|
|
|
+ q.setBody(disposeImg(resultSet.getString("body"), courseCode));
|
|
|
+ q.setAnswer(JSONObject.parseObject(resultSet.getString("answer"), AnswerVo.class));
|
|
|
+ q.setSeq(resultSet.getInt("seq"));
|
|
|
qs.add(q);
|
|
|
}
|
|
|
return qs;
|
|
@@ -125,263 +253,35 @@ public class MyConsumer extends Consumer<PaperExportDto> {
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
- private List<QuestionProp> getQuestionProp(Connection connect, List<KdQuestion> qs) {
|
|
|
- List<QuestionProp> as = new ArrayList<>();
|
|
|
- List<Long> ids = qs.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
- String idsstr = StringUtils.join(ids, ",");
|
|
|
- PreparedStatement preState = null;
|
|
|
- ResultSet resultSet = null;
|
|
|
- try {
|
|
|
- String sql = " select t.knowledge_system_id,t.question_id " + " from wq_question_knowledge_system t "
|
|
|
- + " where t.question_id in (" + idsstr + ") ";
|
|
|
- preState = connect.prepareStatement(sql);
|
|
|
-
|
|
|
- resultSet = preState.executeQuery();
|
|
|
-
|
|
|
- while (resultSet.next()) {
|
|
|
- QuestionProp a = new QuestionProp();
|
|
|
- a.setKnowledgeId(resultSet.getLong("knowledge_system_id"));
|
|
|
- a.setQuestionId(resultSet.getLong("question_id"));
|
|
|
- as.add(a);
|
|
|
- }
|
|
|
- return as;
|
|
|
- } catch (Exception e1) {
|
|
|
- throw new RuntimeException(e1);
|
|
|
- } finally {
|
|
|
- if (resultSet != null) {
|
|
|
- try {
|
|
|
- resultSet.close();
|
|
|
- } catch (SQLException e1) {
|
|
|
- }
|
|
|
- }
|
|
|
- if (preState != null) {
|
|
|
- try {
|
|
|
- preState.close();
|
|
|
- } catch (SQLException e1) {
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void fillProp(Connection connect, List<KdQuestion> qs) {
|
|
|
- List<QuestionProp> qps = new BatchGetDataUtil<QuestionProp, KdQuestion>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- protected List<QuestionProp> getData(List<KdQuestion> paramList) {
|
|
|
- return getQuestionProp(connect, paramList);
|
|
|
- }
|
|
|
- }.getDataForBatch(qs, 200);
|
|
|
- if (CollectionUtils.isEmpty(qps)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<Long, KdQuestion> map = new HashMap<>();
|
|
|
- for (KdQuestion q : qs) {
|
|
|
- map.put(q.getId(), q);
|
|
|
- }
|
|
|
- for (QuestionProp qp : qps) {
|
|
|
- KdQuestion q = map.get(qp.getQuestionId());
|
|
|
- List<Long> qpids = q.getPropIds();
|
|
|
- if (qpids == null) {
|
|
|
- qpids = new ArrayList<>();
|
|
|
- q.setPropIds(qpids);
|
|
|
- }
|
|
|
- qpids.add(qp.getKnowledgeId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void fillAnswer(Connection connect, List<KdQuestion> qs, String courseCode) {
|
|
|
- List<Answer> qps = new BatchGetDataUtil<Answer, KdQuestion>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- protected List<Answer> getData(List<KdQuestion> paramList) {
|
|
|
- return getAnswerBatch(connect, paramList, courseCode);
|
|
|
- }
|
|
|
- }.getDataForBatch(qs, 200);
|
|
|
- if (CollectionUtils.isEmpty(qps)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, List<Answer>> map = new HashMap<>();
|
|
|
- for (Answer qp : qps) {
|
|
|
- List<Answer> list = map.get(qp.getQuestionId());
|
|
|
- if (list == null) {
|
|
|
- list = new ArrayList<>();
|
|
|
- map.put(qp.getQuestionId(), list);
|
|
|
- }
|
|
|
- list.add(qp);
|
|
|
- }
|
|
|
-
|
|
|
- for (KdQuestion q : qs) {
|
|
|
- if (YunkaiQuesStructType.DANXUAN.equals(q.getQst())) {
|
|
|
- List<KdQuesOption> ops = new ArrayList<>();
|
|
|
- q.setOptions(ops);
|
|
|
- int num = 0;
|
|
|
- for (Answer a : map.get(q.getId())) {
|
|
|
- num++;
|
|
|
- KdQuesOption op = new KdQuesOption();
|
|
|
- ops.add(op);
|
|
|
- op.setNumber(num);
|
|
|
- op.setBody(a.getBody());
|
|
|
- op.setSelect(a.getRight() == 1);
|
|
|
- if (op.getSelect()) {
|
|
|
- q.setAnswer(getOptionNum(num));
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (YunkaiQuesStructType.DUOXUAN.equals(q.getQst())
|
|
|
- || YunkaiQuesStructType.BUDINGXIANG.equals(q.getQst())) {
|
|
|
- List<String> as = new ArrayList<>();
|
|
|
- List<KdQuesOption> ops = new ArrayList<>();
|
|
|
- q.setOptions(ops);
|
|
|
- int num = 0;
|
|
|
- for (Answer a : map.get(q.getId())) {
|
|
|
- num++;
|
|
|
- KdQuesOption op = new KdQuesOption();
|
|
|
- ops.add(op);
|
|
|
- op.setNumber(num);
|
|
|
- op.setBody(a.getBody());
|
|
|
- op.setSelect(a.getRight() == 1);
|
|
|
- if (op.getSelect()) {
|
|
|
- as.add(getOptionNum(num));
|
|
|
- }
|
|
|
- }
|
|
|
- q.setAnswer(StringUtils.join(as, ","));
|
|
|
- } else if (YunkaiQuesStructType.PANDUAN.equals(q.getQst())) {
|
|
|
- for (Answer a : map.get(q.getId())) {
|
|
|
- if (a.getRight() == 1) {
|
|
|
- q.setAnswer(getBool(a.getBody()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (YunkaiQuesStructType.TIANKONGTI.equals(q.getQst())) {
|
|
|
- q.setBody(relaceQuestionIdx(q.getBody()));
|
|
|
- if (map.get(q.getId()) != null) {
|
|
|
- List<String> as = new ArrayList<>();
|
|
|
- try {
|
|
|
- for (Answer a : map.get(q.getId())) {
|
|
|
- if (a.getRight() == 1) {
|
|
|
- as.add(a.getBody());
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- q.setAnswer(StringUtils.join(as, "##"));
|
|
|
- }
|
|
|
- } else {
|
|
|
- // nothing
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private String relaceQuestionIdx(String str) {
|
|
|
- StringBuffer sb = new StringBuffer("");
|
|
|
- Pattern pattern = Pattern.compile("__(\\d+)__");
|
|
|
-
|
|
|
- Matcher matcher = pattern.matcher(str);
|
|
|
-
|
|
|
- while (matcher.find()) {
|
|
|
- matcher.appendReplacement(sb, "###");
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isEmpty(sb.toString())) {
|
|
|
- return str;
|
|
|
- } else {
|
|
|
- matcher.appendTail(sb);
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 将数字1,2,3,4转化成A,B,C,D
|
|
|
- *
|
|
|
- * @param number
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String getOptionNum(int number) {
|
|
|
- char optionNum = (char) (65 + number);
|
|
|
- return String.valueOf(optionNum);
|
|
|
- }
|
|
|
-
|
|
|
- private String getBool(String val) {
|
|
|
- String valid = "错答案:正确";
|
|
|
- if (val.contains(valid)) {
|
|
|
- return "正确";
|
|
|
- }
|
|
|
- for (String suc : sucStr) {
|
|
|
- if (val.contains(suc)) {
|
|
|
- return "正确";
|
|
|
- }
|
|
|
- }
|
|
|
- for (String err : errStr) {
|
|
|
- if (val.contains(err)) {
|
|
|
- return "错误";
|
|
|
- }
|
|
|
- }
|
|
|
- return "正确";
|
|
|
- }
|
|
|
-
|
|
|
- private List<Answer> getAnswerBatch(Connection connect, List<KdQuestion> qs, String courseCode) {
|
|
|
- List<Answer> as = new ArrayList<>();
|
|
|
- List<Long> ids = qs.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
- String idsstr = StringUtils.join(ids, ",");
|
|
|
- PreparedStatement preState = null;
|
|
|
- ResultSet resultSet = null;
|
|
|
- try {
|
|
|
- String sql = " select t.question_id,t.answer_text,t.is_right " + " from wq_question_answer_item t "
|
|
|
- + " where t.question_id in (" + idsstr + ") " + " order by t.question_id,t.sequence ";
|
|
|
- preState = connect.prepareStatement(sql);
|
|
|
-
|
|
|
- resultSet = preState.executeQuery();
|
|
|
-
|
|
|
- while (resultSet.next()) {
|
|
|
- Answer a = new Answer();
|
|
|
- a.setBody(disposeImg(resultSet.getString("answer_text"), courseCode));
|
|
|
- a.setRight(resultSet.getInt("is_right"));
|
|
|
- a.setQuestionId(resultSet.getLong("question_id"));
|
|
|
- as.add(a);
|
|
|
- }
|
|
|
- return as;
|
|
|
- } catch (Exception e1) {
|
|
|
- throw new RuntimeException(e1);
|
|
|
- } finally {
|
|
|
- if (resultSet != null) {
|
|
|
- try {
|
|
|
- resultSet.close();
|
|
|
- } catch (SQLException e1) {
|
|
|
- }
|
|
|
- }
|
|
|
- if (preState != null) {
|
|
|
- try {
|
|
|
- preState.close();
|
|
|
- } catch (SQLException e1) {
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private void exportPaper(Connection connect, PaperExportDto dto) throws Exception {
|
|
|
- List<KdQuestion> qs = getQuestion(connect, dto.getCourseCode());
|
|
|
- if (qs.size() == 0) {
|
|
|
+ List<QuestionVo> vos = getQuestion(connect, dto.getCourseCode());
|
|
|
+ if (CollectionUtils.isEmpty(vos)) {
|
|
|
return;
|
|
|
}
|
|
|
- fillProp(connect, qs);
|
|
|
- fillAnswer(connect, qs, dto.getCourseCode());
|
|
|
-
|
|
|
- Map<YunkaiQuesStructType, List<KdQuestion>> qmap = new HashMap<>();
|
|
|
+ List<String> pids = vos.stream().filter(e -> e.getqType().getTypeId() == 6).map(QuestionVo::getQid)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<QuestionVo> subvos = getSubQuestion(connect, dto.getCourseCode(),pids);
|
|
|
+ List<KdQuestion> qs=of(vos,subvos);
|
|
|
+// fillProp(connect, qs);
|
|
|
+// fillAnswer(connect, qs, dto.getCourseCode());
|
|
|
+
|
|
|
+ Map<DetailDto, List<KdQuestion>> qmap = new HashMap<>();
|
|
|
for (KdQuestion q : qs) {
|
|
|
- List<KdQuestion> list = qmap.get(q.getQst());
|
|
|
+ DetailDto tem=new DetailDto(q.getTypeId(), q.getDetailName());
|
|
|
+ List<KdQuestion> list = qmap.get(tem);
|
|
|
if (list == null) {
|
|
|
list = new ArrayList<>();
|
|
|
- qmap.put(q.getQst(), list);
|
|
|
+ qmap.put(tem, list);
|
|
|
}
|
|
|
list.add(q);
|
|
|
}
|
|
|
- for (YunkaiQuesStructType qt : qmap.keySet()) {
|
|
|
+ for (DetailDto qt : qmap.keySet()) {
|
|
|
createPapers(qmap.get(qt), qt, dto);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void createPapers(List<KdQuestion> qs, YunkaiQuesStructType qt, PaperExportDto dto) {
|
|
|
+ private void createPapers(List<KdQuestion> qs, DetailDto qt, PaperExportDto dto) {
|
|
|
if (qs == null || qs.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -400,26 +300,39 @@ public class MyConsumer extends Consumer<PaperExportDto> {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void createPaper(List<KdQuestion> qs, YunkaiQuesStructType qt, PaperExportDto dto, int indx) {
|
|
|
+ private void createPaper(List<KdQuestion> qs, DetailDto qt, PaperExportDto dto, int indx) {
|
|
|
if (qs.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
- String detailName = qt.getYunKaiDesc();
|
|
|
+ double score=0.0;
|
|
|
+ int unit=0;
|
|
|
+ for(KdQuestion q:qs) {
|
|
|
+ if(CollectionUtils.isNotEmpty(q.getSubQuestions())) {
|
|
|
+ unit=unit+q.getSubQuestions().size();
|
|
|
+ }else {
|
|
|
+ unit++;
|
|
|
+ }
|
|
|
+ score=Calculator.add(score, q.getScore(),1);
|
|
|
+ }
|
|
|
+ String detailName = qt.getTypeName();
|
|
|
KdPaper paper = new KdPaper();
|
|
|
- paper.setTotalScore((double) qs.size());
|
|
|
+ paper.setDetailCount(1);
|
|
|
+ paper.setUnitCount(unit);
|
|
|
+ paper.setTotalScore(score);
|
|
|
paper.setName(dto.getPaperSuff() + detailName + "_" + indx);
|
|
|
paper.setCourseCode(dto.getCourseCode());
|
|
|
List<KdDetail> des = new ArrayList<>();
|
|
|
KdDetail d = new KdDetail();
|
|
|
d.setName(detailName);
|
|
|
d.setNumber(1);
|
|
|
- d.setQuestionCount(qs.size());
|
|
|
- d.setTotalScore((double) qs.size());
|
|
|
+ d.setQuestionCount(unit);
|
|
|
+ d.setTotalScore(score);
|
|
|
d.setQuestions(qs);
|
|
|
des.add(d);
|
|
|
paper.setDetails(des);
|
|
|
paper.setDetailCount(1);
|
|
|
- File paperdir = new File(paperDir + dto.getCourseCode() + "/" + qt.getYunKaiType() + "/");
|
|
|
+ paper.setUnitCount(qs.size());
|
|
|
+ File paperdir = new File(paperDir + dto.getCourseCode() + "/" + qt.getTypeId()+ "/");
|
|
|
paperdir.mkdirs();
|
|
|
try {
|
|
|
FileUtil.writeFile(paperdir.getAbsolutePath(), "/paper_" + indx + ".json", JSONObject.toJSONString(paper));
|