流程.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #必要步骤
  2. (修改本地化:dbName和账号、试卷前缀)
  3. 1、将云开数据库 导入 本地
  4. 2、建要处理的科目临时表
  5. CREATE TABLE `temp_subject` (
  6. `ec_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  7. `yun_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  8. `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
  10. 学校提供待导入的科目,将Excel填入该表
  11. 3、检查是否有包含公式的题
  12. select q.id,q.question_type,q.topic,q.answer,an.answer_text
  13. from wq_question_bank_subject t left join wq_subject sub on t.subject_id=sub.id
  14. left join wq_question_bank b on t.question_bank_id=b.id
  15. left join wq_question_question_bank f on t.question_bank_id=f.question_bank_id
  16. left join wq_question q on f.question_id=q.id
  17. left join wq_question_answer_item an on q.id=an.question_id
  18. where 1=1
  19. and sub.subject_code in (select yun_code from temp_subject)
  20. and b.rent_id=811 and b.is_deleted=0 and q.is_deleted=0 and q.rent_id=811
  21. and (q.topic like '%$$%' or q.answer like '%$$%' or an.answer_text like '%$$%');
  22. 若存在 公式题 则继续执行下面继续处理步骤;若无,则忽略公式处理。
  23. {
  24. 处理公式的临时表
  25. CREATE TABLE `temp_gs` (
  26. `id` bigint NOT NULL,
  27. `content1` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  28. `content2` text COLLATE utf8mb4_bin,
  29. `content3` text COLLATE utf8mb4_bin,
  30. `content4` text COLLATE utf8mb4_bin,
  31. PRIMARY KEY (`id`)
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
  33. 查询 存在公式关键字的字段,并将结果集导出至Excel,使用公式处理工具“formula-analysis 1.0.1.exe”
  34. 将Excel的内容执行处理后,复制至临时表“temp_gs”,然后执行update语句。
  35. 查询
  36. select id,topic from wq_question where topic like '%$$%';
  37. 修改
  38. update wq_question INNER JOIN temp_gs on wq_question.id=temp_gs.id
  39. set wq_question.topic= CONCAT_WS('',temp_gs.content1,temp_gs.content2,temp_gs.content3,temp_gs.content4);
  40. 执行完update后,清空“temp_gs”。
  41. 同上
  42. 查询
  43. select id,answer from wq_question where answer like '%$$%';
  44. 修改
  45. update wq_question INNER JOIN temp_gs on wq_question.id=temp_gs.id
  46. set wq_question.answer= CONCAT_WS('',temp_gs.content1,temp_gs.content2,temp_gs.content3,temp_gs.content4);
  47. 同上
  48. 查询
  49. select id,answer_text from wq_question_answer_item where answer_text like '%$$%';
  50. 修改
  51. update wq_question_answer_item INNER JOIN temp_gs on wq_question_answer_item.id=temp_gs.id
  52. set wq_question_answer_item.answer_text= CONCAT_WS('',temp_gs.content1,temp_gs.content2,temp_gs.content3,temp_gs.content4);
  53. }
  54. 4、云开数据库中 本地化的表“wq_knowledge_system”需要新加的字段root_id,
  55. 再在yunkai-export代码“FillRootId.java”中更新属性树
  56. 5、检查是否存在 非标准格式的 套题,若存在,直接当作 单独的题 处理,执行以下分析脚本。
  57. insert into wq_question_question_bank (question_bank_id,question_id)
  58. select f.question_bank_id,t.id
  59. from wq_question t left join wq_question_question_bank f on t.question_id=f.question_id
  60. where t.question_id!=-1 and t.rent_id=811
  61. and f.question_bank_id is not null;
  62. 6、执行yunkai-export代码“ExportProperty.java”
  63. 学校存放的文件目录 提前置入 相关Excel文件 ,然后才可执行!!!
  64. 7、执行yunkai-export代码“ExportPaperByCourseCode.java”
  65. MyConsumer.java内的paperDir需要修改正确 ,然后才可执行!!!
  66. 8、执行yunkai-import代码“ExportPaperByCourseCode.java”
  67. {
  68. a、云平台管理端导入课程
  69. b、导入课程属性,执行ImportPropByCourse(修改sourceDir、host、rootOrgId、key、token)
  70. c、导入试卷,执行ImportPaperByCourse(修改sourceDir、host、rootOrgId、key、token)
  71. }
  72. 9、执行去重 examcloud-oe-tool
  73. End
  74. ===============================================================================
  75. 辅助分析脚本:
  76. #查询wq_question表中question_id!=-1的数据,将有效的question补入wq_question_question_bank。将套题作为单独的题处理
  77. #insert into wq_question_question_bank (question_bank_id,question_id)
  78. #select question_bank_id,question_id from temp_childer;
  79. 选项就一个的查询
  80. var total=0;
  81. db.getCollection('question').find({
  82. "orgId":"17351",
  83. "questionType":{"$in":["SINGLE_ANSWER_QUESTION","MULTIPLE_ANSWER_QUESTION"]},
  84. "$or":[
  85. {"quesOptions":{"$eq":null}},
  86. {"quesOptions":{"$size":0}},
  87. {"quesOptions":{"$size":1}}
  88. ]
  89. }).forEach(function(ques){
  90. total++;
  91. //print(ques._id+" "+ques.questionType+" "+ques.course.code);
  92. db.getCollection('paperDetailUnit').find({
  93. "question.$id":ques._id,
  94. "paperType":"IMPORT"
  95. }).forEach(function(unit){
  96. print(unit._id+","+ques._id+","+ques.questionType+","+ques.course.code);
  97. });
  98. });
  99. print("total:" + total);
  100. 选项就一个的查询,数量
  101. db.getCollection('question').count({
  102. "orgId":"17351",
  103. "questionType":{"$in":["SINGLE_ANSWER_QUESTION","MULTIPLE_ANSWER_QUESTION"]},
  104. //"quesOptions":{"$ne":null,"$not":{"$size":0}}
  105. //"quesOptions":{"$ne":null,"$size":1}
  106. //"quesOptions":{"$eq":[]}
  107. "$or":[
  108. {"quesOptions":{"$eq":null}},
  109. {"quesOptions":{"$size":0}},
  110. {"quesOptions":{"$size":1}}
  111. ]
  112. });
  113. select k.* from wq_knowledge_system k where k.root_id in(select DISTINCT ss.root_id
  114. from wq_question_bank_subject t
  115. left join wq_question_bank b on t.question_bank_id=b.id
  116. left join wq_question_question_bank f on t.question_bank_id=f.question_bank_id
  117. left join wq_question q on f.question_id=q.id
  118. left join wq_question_knowledge_system s on f.question_id=s.question_id
  119. left join wq_knowledge_system ss on s.knowledge_system_id=ss.id
  120. where t.subject_id=622 and b.rent_id=811 and b.is_deleted=0
  121. and q.is_deleted=0 and q.rent_id=811)
  122. select DISTINCT f.id,f.subject_name,f.subject_code
  123. from temp_subject tem
  124. INNER JOIN wq_subject f on tem.subject_code=f.subject_code
  125. INNER JOIN wq_question_bank_subject t on f.id=t.subject_id
  126. where f.is_deleted=0 and f.rent_id=811
  127. order by f.id
  128. update wq_question INNER JOIN temp_old_data on wq_question.id=temp_old_data.id
  129. set wq_question.topic= temp_old_data.content;
  130. update wq_question_answer_item INNER JOIN temp_old_data on wq_question_answer_item.id=temp_old_data.id
  131. set wq_question_answer_item.answer_text= temp_old_data.content;