QuestionsMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.ie.mapper.QuestionsMapper">
  6. <resultMap type="Questions" id="QuestionsResult">
  7. <result property="id" column="id" />
  8. <result property="title" column="title" />
  9. <result property="title1" column="title1" />
  10. <result property="title0" column="title0" />
  11. <result property="options0" column="options0" />
  12. <result property="answer0" column="answer0" />
  13. <result property="parse0" column="parse0" />
  14. <result property="options" column="options" />
  15. <result property="optionA" column="option_a" />
  16. <result property="optionB" column="option_b" />
  17. <result property="optionC" column="option_c" />
  18. <result property="optionD" column="option_d" />
  19. <result property="optionE" column="option_e" />
  20. <result property="optionF" column="option_f" />
  21. <result property="optionG" column="option_g" />
  22. <result property="answers" column="answers" />
  23. <result property="answer1" column="answer1" />
  24. <result property="answer2" column="answer2" />
  25. <result property="parse" column="parse" />
  26. <result property="qtpye" column="qtpye" />
  27. <result property="diff" column="diff" />
  28. <result property="md5" column="md5" />
  29. <result property="subjectId" column="subjectId" />
  30. <result property="gradeId" column="gradeId" />
  31. <result property="knowledges" column="knowledges" />
  32. <result property="area" column="area" />
  33. <result property="year" column="year" />
  34. <result property="paperTpye" column="paperTpye" />
  35. <result property="source" column="source" />
  36. <result property="fromSite" column="fromSite" />
  37. <result property="isSub" column="isSub" />
  38. <result property="isSubType" column="isSubType" />
  39. <result property="isNormal" column="isNormal" />
  40. <result property="isKonw" column="isKonw" />
  41. <result property="tiid" column="tiid" />
  42. <result property="similarity" column="Similarity" />
  43. <result property="isunique" column="isunique" />
  44. <result property="md52" column="md52" />
  45. <result property="score" column="score" />
  46. <result property="paperTitle" column="paperTitle" />
  47. <result property="collect" column="collect" />
  48. <result property="seq" column="seq" />
  49. <result property="paperId" column="paper_id" />
  50. <result property="createTime" column="create_time" />
  51. </resultMap>
  52. <sql id="selectQuestionsVo">
  53. select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2, parse, qtpye, diff, md5, subjectId, gradeId, knowledges, area, year, paperTpye, source, fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52 from questions
  54. </sql>
  55. <select id="getQuestionsCountByChapterIds" resultType="int">
  56. select COUNT(*) num from chapter_question_id where 1 = 1
  57. and chapter_id in
  58. <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
  59. #{id}
  60. </foreach>
  61. </select>
  62. <select id="getPaperByKnowledgeLevelId" resultMap="QuestionsResult">
  63. select ques.* from questions ques where 1=1
  64. <if test="difficulty == 0">and ques.diff in (1,2)</if>
  65. <if test="difficulty == 1">and ques.diff = 3 </if>
  66. <if test="difficulty == 2">and ques.diff in (4,5)</if>
  67. and ques.id in (
  68. select question_id from question_knowledge_basic_id
  69. where knowledge_basic_id in
  70. <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
  71. #{id}
  72. </foreach>
  73. )
  74. and ques.qtpye = #{qtype}
  75. order by rand() limit 0,#{number}
  76. </select>
  77. <select id="getPaperByChapterId" resultMap="QuestionsResult">
  78. select * from questions where 1=1
  79. <if test="difficulty == 0">and diff in (1,2)</if>
  80. <if test="difficulty == 1">and diff = 3 </if>
  81. <if test="difficulty == 2">and diff in (4,5)</if>
  82. and id in (
  83. select question_id from chapter_question_id where chapter_id in
  84. <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
  85. #{id}
  86. </foreach>
  87. )
  88. and qtpye = #{qtype}
  89. order by rand() limit 0,#{number}
  90. </select>
  91. <select id="selectQuestionsByMxjbPaperId" parameterType="map" resultMap="QuestionsResult">
  92. SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
  93. IF(pq.parse IS NULL, q.parse, pq.parse) parse,
  94. IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
  95. IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
  96. q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
  97. <if test="userId != null">
  98. , if(qc.user_id is null, 0, 1) collect
  99. </if>
  100. FROM mxjb_paper p
  101. JOIN mxjb_paper_question pq ON pq.paper_id = p.paper_id
  102. JOIN questions q ON q.id = pq.question_id
  103. <if test="userId != null">
  104. LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
  105. </if>
  106. <where>
  107. <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
  108. <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
  109. </where>
  110. ORDER BY pq.seq
  111. </select>
  112. <select id="selectQuestionsByAiPaperId" parameterType="map" resultMap="QuestionsResult">
  113. SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
  114. IF(pq.parse IS NULL, q.parse, pq.parse) parse,
  115. IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
  116. IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
  117. q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
  118. <if test="userId != null">
  119. , if(qc.user_id is null, 0, 1) collect
  120. </if>
  121. FROM mxjb_ai_paper p
  122. JOIN mxjb_ai_paper_question pq ON pq.paper_id = p.paper_id
  123. JOIN questions q ON q.id = pq.question_id
  124. <if test="userId != null">
  125. LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
  126. </if>
  127. <where>
  128. <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
  129. <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
  130. </where>
  131. ORDER BY pq.seq
  132. </select>
  133. <select id="selectQuestionsByHomeworkPaperId" parameterType="map" resultMap="QuestionsResult">
  134. SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
  135. IF(pq.parse IS NULL, q.parse, pq.parse) parse,
  136. IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
  137. IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
  138. q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
  139. <if test="userId != null">
  140. , if(qc.user_id is null, 0, 1) collect
  141. </if>
  142. FROM mxjb_customer_paper p
  143. JOIN mxjb_customer_paper_question pq ON pq.paper_id = p.paper_id
  144. JOIN questions q ON q.id = pq.question_id
  145. <if test="userId != null">
  146. LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
  147. </if>
  148. <where>
  149. <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
  150. <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
  151. </where>
  152. ORDER BY pq.seq
  153. </select>
  154. <select id="selectQuestionsByZtPaperId" parameterType="map" resultMap="QuestionsResult">
  155. SELECT q.* FROM `paperques` pq
  156. LEFT JOIN questions q ON q.id = pq.`question_id`
  157. <where>
  158. <if test="type != null"> AND pq.type = #{type}</if>
  159. <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
  160. <if test="paperIds != null"> AND pq.paperId in <foreach item="paperId" collection="paperIds" open="(" separator="," close=")">#{paperId}</foreach></if>
  161. </where>
  162. ORDER BY pq.`id`
  163. </select>
  164. <select id="selectQuestionsByPaperId" parameterType="map" resultMap="QuestionsResult">
  165. SELECT q.knowledges, 0 seq, q.id, q.qtpye, q.title, q.title1, q.source, NULL, q.`subjectId`, q.isSub, q.parse, q.answer1, q.answer2, q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, if(pq.sorces is null, q.score, pq.sorces) score, q.knowledgeId, qc.question_id > 0 collect, q.isSubType
  166. FROM papers p
  167. JOIN paperques pq ON pq.paperId = p.id
  168. JOIN questions q ON q.id = pq.question_id
  169. LEFT JOIN mxjb_question_collection qc on qc.question_id = q.id and qc.user_id = #{userId}
  170. WHERE p.id = #{paperId} AND (q.isSub is null or q.isSub = 0 or q.id = q.isSubType)
  171. ORDER BY pq.seq, IF(pq.`type` = 'paper', q.id, pq.id)
  172. </select>
  173. <select id="listQuestionsByPaperId" resultMap="QuestionsResult">
  174. SELECT q.*
  175. FROM papers p
  176. left JOIN paperques pq ON pq.paperId = p.id
  177. left JOIN questions q ON q.id = pq.question_id
  178. WHERE p.id = ${paperId}
  179. and q.id is not null
  180. ORDER BY q.id
  181. </select>
  182. <select id="selectSimilarQuestions" parameterType="map" resultMap="QuestionsResult">
  183. SELECT n.id
  184. FROM questions n
  185. LEFT JOIN mxjb_wrong_book w ON w.question_id = n.id AND w.customer_code = #{customerCode}
  186. <where> n.id != #{questionId} AND w.question_id IS NULL AND n.qtpye = #{qtpye} AND n.gradeId = #{gradeId} and n.subjectId = #{subjectId}
  187. <if test="isSub != null"> AND n.isSub = #{isSub}</if>
  188. <if test="known != null"> AND n.knowledges = #{known}</if>
  189. </where>
  190. LIMIT 500
  191. </select>
  192. <select id="selectTestQuestionsByMapCount" parameterType="map" resultType="int">
  193. SELECT COUNT(*)
  194. FROM `paperques` pq
  195. JOIN questions q ON q.id = pq.`question_id`
  196. LEFT JOIN `mxjb_paper_answers` a ON a.`question_id` = q.`id`
  197. LEFT JOIN `mxjb_paper_examinee` e ON e.`customer_code` = #{userId} AND a.`examinee_id` = e.`examinee_id`
  198. <where> a.`answer_id` IS NULL AND (q.isSub is null or q.id = q.isSubType)
  199. <if test="type != null"> AND pq.type = #{type}</if>
  200. <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
  201. <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
  202. <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
  203. <if test="diff != null "> and diff = #{diff}</if>
  204. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  205. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  206. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  207. <if test="area != null and area != ''"> and area = #{area}</if>
  208. <if test="year != null "> and year = #{year}</if>
  209. <if test="similarity != null "> and Similarity = #{similarity}</if>
  210. </where>
  211. </select>
  212. <select id="selectTestQuestionsByMap" parameterType="map" resultMap="QuestionsResult">
  213. select distinct q.id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
  214. parse, qtpye, diff, md5, subjectId,
  215. gradeId, knowledges, area, year, paperTpye, source,
  216. fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType
  217. FROM `paperques` pq JOIN questions q ON q.id = pq.`question_id`
  218. LEFT JOIN (SELECT question_id FROM `mxjb_paper_examinee` e JOIN `mxjb_paper_answers` a ON a.`examinee_id` = e.`examinee_id` WHERE e.`customer_code` = #{userId}) T ON T.question_id = q.id
  219. <where>T.`question_id` IS NULL AND (q.isSub is null or q.id = q.isSubType)
  220. <if test="type != null"> AND pq.type = #{type}</if>
  221. <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
  222. <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
  223. <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
  224. <if test="diff != null "> and diff = #{diff}</if>
  225. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  226. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  227. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  228. <if test="area != null and area != ''"> and area = #{area}</if>
  229. <if test="year != null "> and year = #{year}</if>
  230. <if test="similarity != null "> and Similarity = #{similarity}</if>
  231. </where>
  232. limit #{startPos}, 100
  233. </select>
  234. <select id="selectQuestionsByMapCount" parameterType="map" resultType="int">
  235. select count(*)
  236. from questions q
  237. <where>
  238. <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
  239. <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
  240. <if test="diff != null "> and diff = #{diff}</if>
  241. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  242. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  243. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  244. <if test="area != null and area != ''"> and area = #{area}</if>
  245. <if test="year != null "> and year = #{year}</if>
  246. <if test="similarity != null "> and Similarity = #{similarity}</if>
  247. </where>
  248. </select>
  249. <select id="selectQuestionsByMap" parameterType="map" resultMap="QuestionsResult">
  250. select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
  251. parse, qtpye, diff, md5, subjectId,
  252. gradeId, knowledges, area, year, paperTpye, source,
  253. fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, q.isSubType
  254. from questions q
  255. <where>
  256. <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
  257. <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
  258. <if test="diff != null "> and diff = #{diff}</if>
  259. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  260. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  261. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  262. <if test="area != null and area != ''"> and area = #{area}</if>
  263. <if test="year != null "> and year = #{year}</if>
  264. <if test="similarity != null "> and Similarity = #{similarity}</if>
  265. limit #{startPos}, 100
  266. </where>
  267. </select>
  268. <select id="selectQuestionsForAiSubject" parameterType="map" resultMap="QuestionsResult">
  269. SELECT pq.`create_time`, p.paper_id, q.knowledges, pq.knowledge_id, e.`examinee_id` seq, q.id, q.qtpye, q.title, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
  270. IF(pq.parse IS NULL, q.parse, pq.parse) parse,
  271. IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
  272. IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
  273. q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, pq.score, q.isSubType
  274. FROM mxjb_ai_paper p
  275. JOIN `mxjb_ai_examinee` e ON e.`paper_id` = p.`paper_id`
  276. JOIN `mxjb_ai_paper_question` pq ON pq.`paper_id` = p.`paper_id`
  277. JOIN questions q ON q.id = pq.`question_id`
  278. WHERE p.`creator_id` = #{creatorId} and p.subjectId = #{subjectId}
  279. ORDER BY pq.`create_time` DESC
  280. </select>
  281. <select id="selectQuestionsList" parameterType="Questions" resultMap="QuestionsResult">
  282. select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
  283. parse, qtpye, diff, md5, subjectId, (select subjectName from subject s where s.subjectId=q.subjectId) subjectName,
  284. gradeId, knowledges, area, year, paperTpye, source,
  285. fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, q.isSubType
  286. from questions q
  287. where 1=1
  288. <if test="id != null "> and id = #{id}</if>
  289. <if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if>
  290. <if test="optionA != null and optionA != ''"> and option_a = #{optionA}</if>
  291. <if test="optionB != null and optionB != ''"> and option_b = #{optionB}</if>
  292. <if test="optionC != null and optionC != ''"> and option_c = #{optionC}</if>
  293. <if test="optionD != null and optionD != ''"> and option_d = #{optionD}</if>
  294. <if test="optionE != null and optionE != ''"> and option_e = #{optionE}</if>
  295. <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
  296. <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
  297. <if test="parse != null and parse != ''"> and parse = #{parse}</if>
  298. <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
  299. <if test="diff != null "> and diff = #{diff}</if>
  300. <if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
  301. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  302. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  303. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  304. <if test="area != null and area != ''"> and area = #{area}</if>
  305. <if test="year != null "> and year = #{year}</if>
  306. <if test="paperTpye != null and paperTpye != ''"> and paperTpye = #{paperTpye}</if>
  307. <if test="source != null and source != ''"> and source = #{source}</if>
  308. <if test="fromSite != null and fromSite != ''"> and fromSite = #{fromSite}</if>
  309. <if test="isSub != null "> and isSub = #{isSub}</if>
  310. <if test="isSubType != null "> and isSubType = #{isSubType}</if>
  311. <if test="isNormal != null "> and isNormal = #{isNormal}</if>
  312. <if test="isKonw != null "> and isKonw = #{isKonw}</if>
  313. <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
  314. <if test="similarity != null "> and Similarity = #{similarity}</if>
  315. <if test="isunique != null "> and isunique = #{isunique}</if>
  316. <if test="md52 != null and md52 != ''"> and md52 = #{md52}</if>
  317. <if test="subjectName != null and subjectName != ''">
  318. and subjectId = (select subjectId from subject where subjectName=#{subjectName})
  319. </if>
  320. order by id desc
  321. </select>
  322. <!--解决分页慢 https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Changelog.md 更新时间2017-08-01 -->
  323. <select id="selectQuestionsList_COUNT" resultType="Long">
  324. select count(*)
  325. from questions q
  326. where 1=1 and q.id &gt;=1 and q.id &lt;=999999999
  327. <if test="id != null "> and id = #{id}</if>
  328. <if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if>
  329. <if test="optionA != null and optionA != ''"> and option_a = #{optionA}</if>
  330. <if test="optionB != null and optionB != ''"> and option_b = #{optionB}</if>
  331. <if test="optionC != null and optionC != ''"> and option_c = #{optionC}</if>
  332. <if test="optionD != null and optionD != ''"> and option_d = #{optionD}</if>
  333. <if test="optionE != null and optionE != ''"> and option_e = #{optionE}</if>
  334. <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
  335. <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
  336. <if test="parse != null and parse != ''"> and parse = #{parse}</if>
  337. <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
  338. <if test="diff != null "> and diff = #{diff}</if>
  339. <if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
  340. <if test="subjectId != null "> and subjectId = #{subjectId}</if>
  341. <if test="gradeId != null "> and gradeId = #{gradeId}</if>
  342. <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
  343. <if test="area != null and area != ''"> and area = #{area}</if>
  344. <if test="year != null "> and year = #{year}</if>
  345. <if test="paperTpye != null and paperTpye != ''"> and paperTpye = #{paperTpye}</if>
  346. <if test="source != null and source != ''"> and source = #{source}</if>
  347. <if test="fromSite != null and fromSite != ''"> and fromSite = #{fromSite}</if>
  348. <if test="isSub != null "> and isSub = #{isSub}</if>
  349. <if test="isNormal != null "> and isNormal = #{isNormal}</if>
  350. <if test="isKonw != null "> and isKonw = #{isKonw}</if>
  351. <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
  352. <if test="similarity != null "> and Similarity = #{similarity}</if>
  353. <if test="isunique != null "> and isunique = #{isunique}</if>
  354. <if test="md52 != null and md52 != ''"> and md52 = #{md52}</if>
  355. <if test="subjectName != null and subjectName != ''">
  356. and subjectId = (select subjectId from subject where subjectName=#{subjectName})
  357. </if>
  358. </select>
  359. <select id="selectQuestionsFilter" parameterType="Questions" resultMap="QuestionsResult">
  360. select id, title, title1, title0, answer0, parse0, options0,options, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2, parse, qtpye, diff, md5, subjectId, gradeId, knowledges, area, year, paperTpye, source, fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType from questions
  361. where isUpdate=0
  362. <if test="id != null "> and id = #{id}</if>
  363. <if test="params.ids != null "> and id in
  364. <foreach item="id" collection="params.ids" open="(" separator="," close=")">
  365. #{id}
  366. </foreach></if>
  367. and
  368. ( title like concat('%', #{title} ,'%')
  369. or title1 like concat('%', #{title} ,'%')
  370. or parse like concat('%', #{title} ,'%')
  371. or options like concat('%', #{title} ,'%')
  372. or answer1 like concat('%', #{title} ,'%')
  373. )
  374. </select>
  375. <select id="selectQuestionsById" parameterType="Long" resultMap="QuestionsResult">
  376. <include refid="selectQuestionsVo"/>
  377. where id = #{id}
  378. </select>
  379. <select id="selectQuestionsByPids" parameterType="Integer" resultMap="QuestionsResult">
  380. select id, title, title0, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
  381. parse, qtpye, diff, md5,
  382. gradeId, knowledges, area, year, paperTpye, source,
  383. fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType, score
  384. from questions q
  385. where isSubType in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
  386. order by q.number * 1
  387. </select>
  388. <insert id="insertQuestions" parameterType="Questions" useGeneratedKeys="true" keyProperty="id">
  389. insert into questions
  390. <trim prefix="(" suffix=")" suffixOverrides=",">
  391. <if test="title != null">title,</if>
  392. <if test="title1 != null">title1,</if>
  393. <if test="optionA != null">option_a,</if>
  394. <if test="optionB != null">option_b,</if>
  395. <if test="optionC != null">option_c,</if>
  396. <if test="optionD != null">option_d,</if>
  397. <if test="optionE != null">option_e,</if>
  398. <if test="answer1 != null">answer1,</if>
  399. <if test="answer2 != null">answer2,</if>
  400. <if test="parse != null">parse,</if>
  401. <if test="qtpye != null">qtpye,</if>
  402. <if test="diff != null">diff,</if>
  403. <if test="md5 != null">md5,</if>
  404. <if test="subjectId != null">subjectId,</if>
  405. <if test="gradeId != null">gradeId,</if>
  406. <if test="knowledges != null">knowledges,</if>
  407. <if test="area != null">area,</if>
  408. <if test="year != null">year,</if>
  409. <if test="paperTpye != null">paperTpye,</if>
  410. <if test="source != null">source,</if>
  411. <if test="fromSite != null">fromSite,</if>
  412. <if test="isSub != null">isSub,</if>
  413. <if test="isNormal != null">isNormal,</if>
  414. <if test="isKonw != null">isKonw,</if>
  415. <if test="tiid != null">tiid,</if>
  416. <if test="similarity != null">Similarity,</if>
  417. <if test="isunique != null">isunique,</if>
  418. <if test="md52 != null">md52,</if>
  419. </trim>
  420. <trim prefix="values (" suffix=")" suffixOverrides=",">
  421. <if test="title != null">#{title},</if>
  422. <if test="title1 != null">#{title1},</if>
  423. <if test="optionA != null">#{optionA},</if>
  424. <if test="optionB != null">#{optionB},</if>
  425. <if test="optionC != null">#{optionC},</if>
  426. <if test="optionD != null">#{optionD},</if>
  427. <if test="optionE != null">#{optionE},</if>
  428. <if test="answer1 != null">#{answer1},</if>
  429. <if test="answer2 != null">#{answer2},</if>
  430. <if test="parse != null">#{parse},</if>
  431. <if test="qtpye != null">#{qtpye},</if>
  432. <if test="diff != null">#{diff},</if>
  433. <if test="md5 != null">#{md5},</if>
  434. <if test="subjectId != null">#{subjectId},</if>
  435. <if test="gradeId != null">#{gradeId},</if>
  436. <if test="knowledges != null">#{knowledges},</if>
  437. <if test="area != null">#{area},</if>
  438. <if test="year != null">#{year},</if>
  439. <if test="paperTpye != null">#{paperTpye},</if>
  440. <if test="source != null">#{source},</if>
  441. <if test="fromSite != null">#{fromSite},</if>
  442. <if test="isSub != null">#{isSub},</if>
  443. <if test="isNormal != null">#{isNormal},</if>
  444. <if test="isKonw != null">#{isKonw},</if>
  445. <if test="tiid != null">#{tiid},</if>
  446. <if test="similarity != null">#{similarity},</if>
  447. <if test="isunique != null">#{isunique},</if>
  448. <if test="md52 != null">#{md52},</if>
  449. </trim>
  450. </insert>
  451. <update id="updateQuestions" parameterType="Questions">
  452. update questions
  453. <trim prefix="SET" suffixOverrides=",">
  454. <if test="title != null">title = #{title},</if>
  455. <if test="title1 != null">title1 = #{title1},</if>
  456. <if test="options != null">options = #{options},</if>
  457. <if test="optionA != null">option_a = #{optionA},</if>
  458. <if test="optionB != null">option_b = #{optionB},</if>
  459. <if test="optionC != null">option_c = #{optionC},</if>
  460. <if test="optionD != null">option_d = #{optionD},</if>
  461. <if test="optionE != null">option_e = #{optionE},</if>
  462. <if test="optionF != null">option_f = #{optionF},</if>
  463. <if test="optionG != null">option_g = #{optionG},</if>
  464. <if test="answer1 != null">answer1 = #{answer1},</if>
  465. <if test="answer2 != null">answer2 = #{answer2},</if>
  466. <if test="parse != null">parse = #{parse},</if>
  467. <if test="qtpye != null">qtpye = #{qtpye},</if>
  468. <if test="diff != null">diff = #{diff},</if>
  469. <if test="md5 != null">md5 = #{md5},</if>
  470. <if test="subjectId != null">subjectId = #{subjectId},</if>
  471. <if test="gradeId != null">gradeId = #{gradeId},</if>
  472. <if test="knowledges != null">knowledges = #{knowledges},</if>
  473. <if test="area != null">area = #{area},</if>
  474. <if test="year != null">year = #{year},</if>
  475. <if test="paperTpye != null">paperTpye = #{paperTpye},</if>
  476. <if test="source != null">source = #{source},</if>
  477. <if test="fromSite != null">fromSite = #{fromSite},</if>
  478. <if test="isSub != null">isSub = #{isSub},</if>
  479. <if test="isNormal != null">isNormal = #{isNormal},</if>
  480. <if test="isKonw != null">isKonw = #{isKonw},</if>
  481. <if test="tiid != null">tiid = #{tiid},</if>
  482. <if test="similarity != null">Similarity = #{similarity},</if>
  483. <if test="isunique != null">isunique = #{isunique},</if>
  484. <if test="md52 != null">md52 = #{md52},</if>
  485. <if test="isUpdate != null">isUpdate = #{isUpdate},</if>
  486. </trim>
  487. where id = #{id}
  488. </update>
  489. <delete id="deleteQuestionsById" parameterType="Long">
  490. delete from questions where id = #{id}
  491. </delete>
  492. <delete id="deleteQuestionsByIds" parameterType="String">
  493. delete from questions where id in
  494. <foreach item="id" collection="array" open="(" separator="," close=")">
  495. #{id}
  496. </foreach>
  497. </delete>
  498. <select id="getPaperQuestionList" parameterType="Questions" resultMap="QuestionsResult">
  499. SELECT
  500. a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,a.option_e,a.option_f,
  501. a.option_g, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
  502. a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
  503. a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
  504. FROM
  505. questions a,
  506. question_knowledge_basic_id b,
  507. chapter c
  508. WHERE
  509. c.pharseId = 3 and
  510. a.id = b.question_id
  511. AND b.knowledge_basic_id=c.knowledgeId
  512. <if test="gradeId != null">
  513. AND c.gradeId = #{gradeId}
  514. </if>
  515. <if test="subjectId != null">
  516. AND c.subjectId = #{subjectId}
  517. </if>
  518. <if test="editionid != null">
  519. AND c.editionId = #{editionid}
  520. </if>
  521. <if test="chapterIds != null">
  522. AND c.id in
  523. <foreach collection="chapterIds" item="chapterId" open="(" separator="," close=")">
  524. #{chapterId}
  525. </foreach>
  526. </if>
  527. <if test="chapterOrder != null">
  528. AND c.chapterOrder = #{chapterOrder}
  529. </if>
  530. <if test="sectionOrder != null">
  531. AND c.sectionOrder = #{sectionOrder}
  532. </if>
  533. <if test="unitOrder != null">
  534. AND c.unitOrder = #{unitOrder}
  535. </if>
  536. <if test="qtpye != null and qtpye !=''">
  537. AND a.qtpye = #{qtpye}
  538. </if>
  539. <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
  540. <if test="diff != null and diff == 1">and a.diff = 3 </if>
  541. <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
  542. <if test="knowledgeBasicIds != null">
  543. and b.knowledge_basic_id in
  544. <foreach item="id" collection="knowledgeBasicIds" open="(" separator="," close=")">
  545. #{id}
  546. </foreach>
  547. </if>
  548. <if test="number != null ">
  549. limit ${number}
  550. </if>
  551. </select>
  552. <select id="getPaperQuestionListByPaperId" parameterType="Long" resultMap="QuestionsResult">
  553. SELECT
  554. a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
  555. a.option_e,a.option_f,a.option_g, pq.answer1,pq.answer2, pq.parse,a.qtpye,a.diff,
  556. a.md5,a.knowledges,a.area, a.year, a.paperTpye,a.source,
  557. a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52,pq.score,p.subjectId, p.grade_id gradeId,
  558. p.name paperTitle, a.isSubType
  559. FROM
  560. questions a
  561. left join mxjb_paper_question pq on pq.question_id=a.id
  562. left join mxjb_paper p on p.paper_id=pq.paper_id
  563. WHERE
  564. p.paper_id=#{paperId}
  565. </select>
  566. <select id="getPaperQuestionListByKnowledge" parameterType="Questions" resultMap="QuestionsResult">
  567. SELECT
  568. a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
  569. a.option_e,a.option_f,a.option_g, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
  570. a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
  571. a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
  572. FROM
  573. questions a
  574. left join question_knowledge_basic_id b on b.question_id=a.id
  575. left join knowledge_level c on c.knowledgeId=b.knowledge_basic_id
  576. WHERE
  577. a.gradeId = 500
  578. <if test="subjectId != null">
  579. AND c.subjectId = #{subjectId}
  580. </if>
  581. <if test="level != null and knowledgeId != null and level == 1">
  582. AND c.knowledge_level_1 = #{knowledgeId}
  583. </if>
  584. <if test="level != null and knowledgeId != null and level == 2">
  585. AND c.knowledge_level_2 = #{knowledgeId}
  586. </if>
  587. <if test="level != null and knowledgeId != null and level == 3">
  588. AND c.knowledge_level_3 = #{knowledgeId}
  589. </if>
  590. <if test="qtpye != null and qtpye !=''">
  591. AND a.qtpye = #{qtpye}
  592. </if>
  593. <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
  594. <if test="diff != null and diff == 1">and a.diff = 3 </if>
  595. <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
  596. <if test="number != null ">
  597. limit ${number}
  598. </if>
  599. </select>
  600. <select id="getQuestionListByIds" parameterType="String" resultMap="QuestionsResult">
  601. <include refid="selectQuestionsVo"/>
  602. where id in
  603. <foreach item="id" collection="array" open="(" separator="," close=")">
  604. #{id}
  605. </foreach>
  606. </select>
  607. <select id="selectIdsByIdGreaterThan2" parameterType="Long" resultMap="QuestionsResult">
  608. SELECT t1.id from questions t1 where 1=1
  609. and t1.id not in (SELECT question_id from test_question_pic)
  610. order by t1.id desc
  611. limit 200
  612. </select>
  613. <select id="selectIdsByIdGreaterThan" parameterType="Long" resultMap="QuestionsResult">
  614. select id from questions
  615. where id > #{id}
  616. order by id asc limit 1000
  617. </select>
  618. <select id="selectByChapterTreeOldids" parameterType="Questions" resultMap="QuestionsResult">
  619. SELECT q.* from questions q
  620. left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
  621. left join knowledge_basic kb on kb.id = qkbi.knowledge_basic_id
  622. left join chapter_tree ct on ct.oldid = kb.md5
  623. where 1=1
  624. <if test="parse != null">and q.parse IS NOT NULL</if>
  625. <if test="chapterIds != null">
  626. and ct.id in
  627. <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
  628. #{id}
  629. </foreach>
  630. </if>
  631. <if test="knowledgeBasicIds != null">
  632. and kb.id in
  633. <foreach item="id" collection="knowledgeBasicIds" open="(" separator="," close=")">
  634. #{id}
  635. </foreach>
  636. </if>
  637. <if test="subjectId != null">
  638. AND q.subjectId = #{subjectId}
  639. </if>
  640. <if test="qtpye != null and qtpye !=''">
  641. AND q.qtpye = #{qtpye}
  642. </if>
  643. <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
  644. </select>
  645. <select id="selectByChapterTreeChineseAndEnglish" parameterType="Questions" resultMap="QuestionsResult">
  646. SELECT q.* from questions q
  647. left join chapter_question_id cqi on cqi.question_id = q.id
  648. left join chapter_tree ct on ct.id = cqi.chapter_id
  649. where 1=1
  650. <if test="subjectId != null">and q.subjectId = #{subjectId}</if>
  651. <if test="parse != null">and q.parse IS NOT NULL</if>
  652. <if test="chapterIds != null">
  653. and ct.id in
  654. <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
  655. #{id}
  656. </foreach>
  657. </if>
  658. <if test="chapterid != null">
  659. and ct.id = #{chapterid}
  660. </if>
  661. <if test="qtpye != null and qtpye !=''">
  662. AND q.qtpye = #{qtpye}
  663. </if>
  664. <if test="diff != null and diff == 0">and q.diff in (1,2)</if>
  665. <if test="diff != null and diff == 1">and q.diff = 3 </if>
  666. <if test="diff != null and diff == 2">and q.diff in (4,5)</if>
  667. <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
  668. </select>
  669. <select id="selectByKnowledgeTreeOldids" parameterType="Questions" resultMap="QuestionsResult">
  670. SELECT q.* from questions q
  671. left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
  672. left join knowledge_basic kb on qkbi.knowledge_basic_id = kb.id
  673. left join knowledge_tree kt on kt.oldId = kb.md5
  674. where 1=1
  675. <if test="knowledgeIds != null">
  676. and kt.id in
  677. <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
  678. #{id}
  679. </foreach>
  680. </if>
  681. <if test="qtpye != null and qtpye !=''">
  682. AND q.qtpye = #{qtpye}
  683. </if>
  684. <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
  685. </select>
  686. <select id="getPaperQuestionListBySubject" parameterType="Questions" resultMap="QuestionsResult">
  687. SELECT
  688. a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
  689. a.option_e, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
  690. a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
  691. a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
  692. FROM
  693. questions a
  694. WHERE
  695. 1=1
  696. <if test="subjectId != null">
  697. AND a.subjectId = #{subjectId}
  698. </if>
  699. <if test="qtpye != null and qtpye !=''">
  700. AND a.qtpye = #{qtpye}
  701. </if>
  702. <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
  703. <if test="diff != null and diff == 1">and a.diff = 3 </if>
  704. <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
  705. <if test="number != null ">
  706. limit ${number}
  707. </if>
  708. </select>
  709. <select id="getQuestionsByChapterForParactice" parameterType="Questions" resultMap="QuestionsResult">
  710. SELECT q.* from questions q
  711. left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
  712. left join knowledge_basic kb on kb.id = qkbi.knowledge_basic_id
  713. left join chapter_tree ct on ct.oldid = kb.md5
  714. where 1=1
  715. <if test="chapterIds != null">
  716. and ct.id in
  717. <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
  718. #{id}
  719. </foreach>
  720. </if>
  721. and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
  722. and q.option_a !='' and length(q.answer1)=1
  723. order by (q.parse IS NULL OR q.parse = ''), rand()
  724. </select>
  725. <select id="getQuestionsByChapterForParacticeChineseAndEnglish" parameterType="Questions" resultMap="QuestionsResult">
  726. select q.*
  727. from chapter_question_id cqi
  728. left join chapter_tree ct on cqi.chapter_id = ct.id
  729. left join questions q on cqi.question_id = q.id
  730. where 1=1
  731. <if test="chapterIds != null">
  732. and ct.id in
  733. <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
  734. #{id}
  735. </foreach>
  736. </if>
  737. and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
  738. and q.option_a !='' and length(q.answer1)=1
  739. order by (q.parse IS NULL OR q.parse = ''), rand()
  740. </select>
  741. <select id="getQuestionsByKnowledgeForParactice" parameterType="Questions" resultMap="QuestionsResult">
  742. SELECT q.* from questions q
  743. left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
  744. left join knowledge_basic kb on qkbi.knowledge_basic_id = kb.id
  745. left join knowledge_tree kt on kt.oldId = kb.md5
  746. where 1=1
  747. <if test="knowledgeIds != null">
  748. and kt.id in
  749. <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
  750. #{id}
  751. </foreach>
  752. </if>
  753. <if test="knowledgeId != null">
  754. and kt.id = #{knowledgeId}
  755. </if>
  756. and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
  757. and q.option_a !='' and length(q.answer1)=1
  758. order by (q.parse IS NULL OR q.parse = ''), rand()
  759. </select>
  760. <select id="selectCollectedList" parameterType="Questions" resultMap="QuestionsResult">
  761. select q.* from mxjb_question_collection c
  762. left join questions q on c.question_id = q.id
  763. left join subject s on q.subjectId = s.subjectId
  764. where c.user_id = #{userId}
  765. and q.subjectId = #{subjectId}
  766. </select>
  767. <select id="selectWrongQuestions" parameterType="Questions" resultMap="QuestionsResult">
  768. select q.* from mxjb_wrong_book b
  769. left join questions q on q.id = b.question_id
  770. where b.customer_code = #{customerCode}
  771. and q.subjectId = #{subjectId}
  772. and q.qtpye = #{qtpye}
  773. </select>
  774. <select id="selectCollectInfo" parameterType="java.util.HashMap" resultMap="QuestionsResult">
  775. SELECT q.id from mxjb_question_collection c
  776. left join questions q on c.question_id = q.id
  777. where user_id = #{userId}
  778. and c.question_id in
  779. <foreach item="id" collection="ids" open="(" separator="," close=")">
  780. #{id}
  781. </foreach>
  782. </select>
  783. <select id="selectByIds" parameterType="java.util.HashMap" resultMap="QuestionsResult">
  784. SELECT * from questions
  785. where id in
  786. <foreach item="id" collection="ids" open="(" separator="," close=")">
  787. #{id}
  788. </foreach>
  789. </select>
  790. <select id="selectByKnowledgeIds" parameterType="Questions" resultMap="QuestionsResult">
  791. select * from questions
  792. where id in (
  793. select question_id
  794. from question_knowledge_basic_id
  795. where knowledge_basic_id in
  796. <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
  797. #{id}
  798. </foreach>
  799. )
  800. <if test="qtpye != null and qtpye !=''">
  801. AND qtpye = #{qtpye}
  802. </if>
  803. <if test="number != null ">
  804. limit ${number}
  805. </if>
  806. </select>
  807. <select id="selectTotalBySubjectId" parameterType="integer" resultType="long">
  808. SELECT COUNT(*)
  809. FROM `questions` q
  810. WHERE q.`subjectId` = #{subjectId} AND q.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
  811. </select>
  812. <select id="selectTotalOfCompleted" resultType="long">
  813. SELECT count(distinct q2.id)
  814. FROM `questions` q2
  815. JOIN `mxjb_paper_answers` a2 ON a2.`question_id` = q2.`id`
  816. JOIN `mxjb_paper_examinee` e2 ON e2.`customer_code` = #{userId} AND a2.`examinee_id` = e2.`examinee_id`
  817. JOIN `mxjb_paper_test` p2 ON e2.`paper_id` = p2.`paper_id` AND p2.`name` = '必刷题'
  818. WHERE q2.`subjectId` = #{subjectId} AND q2.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
  819. </select>
  820. <select id="selectTotalOfLatestRight" resultType="long">
  821. SELECT COUNT(*)
  822. FROM `questions` q2
  823. JOIN `mxjb_paper_answers` a2 ON a2.`question_id` = q2.`id` AND a2.`state` = 1
  824. JOIN `mxjb_paper_examinee` e2 ON e2.`customer_code` = #{userId} AND a2.`examinee_id` = e2.`examinee_id`
  825. JOIN `mxjb_paper_test` p2 ON e2.`paper_id` = p2.`paper_id` AND p2.`name` = '必刷题'
  826. JOIN (SELECT q.`id`, MAX(e.`begin_time`) begin_time
  827. FROM `questions` q
  828. JOIN `mxjb_paper_answers` a ON a.`question_id` = q.`id`
  829. JOIN `mxjb_paper_examinee` e ON e.`customer_code` = #{userId} AND a.`examinee_id` = e.`examinee_id`
  830. JOIN `mxjb_paper_test` p ON e.`paper_id` = p.`paper_id` AND p.`name` = '必刷题'
  831. WHERE q.`subjectId` = #{subjectId} AND q.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
  832. GROUP BY q.`id`
  833. ) T ON q2.id = T.id AND T.begin_time = e2.begin_time
  834. WHERE q2.`subjectId` = #{subjectId} AND q2.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
  835. </select>
  836. <select id="selectLatestRates" resultMap="QuestionsResult">
  837. SELECT e.`paper_id` id, e.`begin_time` create_time, round(e.`score_rate` * 100) score
  838. FROM `mxjb_paper_test` p
  839. JOIN `mxjb_paper_examinee` e ON e.`paper_id` = p.`paper_id` AND e.`customer_code` = #{userId} AND e.`state` = 6
  840. WHERE p.name = '必刷题' AND p.subjectId = #{subjectId}
  841. ORDER BY e.`begin_time` DESC LIMIT 10
  842. </select>
  843. </mapper>