wrongBank.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
  5. <view class="pageContent">
  6. <view class="pad_8 titBox" >
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">
  10. <text v-if="bank.type==1">单选</text>
  11. <text v-if="bank.type==2">多选</text>
  12. <text v-if="bank.type==3">判断</text>
  13. <text v-if="bank.type==4">案例题</text>
  14. <text v-if="bank.type==5">简答题</text>
  15. </view>
  16. <text>{{bankIndex+1}}/{{questionList.length}}</text>
  17. </view>
  18. <view style="color: #666;font-size: 28rpx;"></view>
  19. <view class="leftLetters"></view>
  20. </view>
  21. <view class="titles">
  22. <rich-text :nodes="bank.content"></rich-text>
  23. </view>
  24. </view>
  25. <view class="pad_8 titBox">
  26. <template v-if="bank.type == 1">
  27. <view v-if="!bank.ques">
  28. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId,bankIndex)">
  29. <view class="activeTI">{{ ast[index] }}</view>
  30. <view class="flex_auto">{{ item.content }}</view>
  31. </view>
  32. </view>
  33. <view v-if="bank.ques">
  34. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  35. <text :class="{right:(item.optionsId == bank.ques) || (item.optionsId == bank.ans),wrong:(item.optionsId == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  36. <view class="flex_auto">{{ item.content }}</view>
  37. </view>
  38. </view>
  39. <view v-if="bank.ques">
  40. <view class="pad_8 answer">
  41. <view>正确答案:{{ast[bank.ans-1]}}</view>
  42. <view v-if="!explain">我的答案:{{ast[bank.ques-1]}}</view>
  43. </view>
  44. <view class="pad_8 answerInfos">
  45. <view class="answerTitle">答案解析</view>
  46. <view class="answerContent">
  47. <rich-text :nodes="bank.analysisContent"></rich-text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <template v-if="bank.type == 2">
  53. <view v-if="!bank.ques">
  54. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId,bankIndex,index)">
  55. <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
  56. <view class="flex_auto">{{ item.content }}</view>
  57. </view>
  58. </view>
  59. <view v-if="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">
  60. 确认答案
  61. </view>
  62. <view v-if="bank.ques">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text :class="{right:(bank.ques.indexOf(item.optionsId) != -1 ) || (bank.ans.indexOf(item.optionsId) != -1),wrong:(bank.ques.indexOf(item.optionsId) != -1 ) && (bank.ans.indexOf(item.optionsId) == -1)}" class="activeTI">{{ ast[index] }}</text>
  65. <view class="flex_auto">{{ item.content }}</view>
  66. </view>
  67. </view>
  68. <view v-if="bank.ques">
  69. <view class="pad_8 answer">
  70. <view>正确答案:
  71. <text v-for="ansItem in bank.ans">{{ast[ansItem-1]}}</text>
  72. </view>
  73. <view v-if="!explain">我的答案:
  74. <text v-for="quesItem in bank.ques">{{ast[quesItem-1]}}</text>
  75. </view>
  76. </view>
  77. <view class="pad_8 answerInfos">
  78. <view class="answerTitle">答案解析</view>
  79. <view class="answerContent">
  80. <rich-text :nodes="bank.analysisContent"></rich-text>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <template v-if="bank.type == 3">
  86. <view v-if="!bank.ques">
  87. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index,bankIndex)">
  88. <view class="activeTI">{{ ast[index] }}</view>
  89. {{ item }}
  90. </view>
  91. </view>
  92. <view v-if="bank.ques">
  93. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  94. <text :class="{right:(index == bank.ques) || (index == bank.ans),wrong:(index == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  95. {{ item }}
  96. </view>
  97. </view>
  98. <view v-if="bank.ques">
  99. <view class="pad_8 answer">
  100. <view>正确答案:{{ast[bank.ans]}}</view>
  101. <view v-if="!explain">我的答案:{{ast[bank.ques]}}</view>
  102. </view>
  103. <view class="pad_8 answerInfos">
  104. <view class="answerTitle">答案解析</view>
  105. <view class="answerContent">
  106. <rich-text :nodes="bank.analysisContent"></rich-text>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <!-- 简答题 -->
  112. <template v-if="bank.type == 5">
  113. <view class="ans">
  114. <view class="ans_input" v-if="!bank.ques">
  115. <view class="top flex">
  116. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  117. <view class="progress">{{bank.ansText.imageList.length}}/4</view>
  118. <view class="submit" @click="submitAns(bankIndex)" >确认答案</view>
  119. </view>
  120. <view class="textarea">
  121. <textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea>
  122. </view>
  123. <view class="imgs">
  124. <view class="img" v-for="(img,imgIndex) in bank.ansText.imageList" >
  125. <text @click="deleteImg(imgIndex,bankIndex)">x</text>
  126. <image :src="$method.splitImgHost(img, true)"></image>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="ans_submit answerInfos" v-if="bank.ques && !explain">
  131. <view class="answerTitle">我的答案:</view>
  132. {{bank.ques.text}}
  133. <view class="imgs">
  134. <image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques,true)"></image>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="bank.ques">
  139. <view class="pad_8 answerInfos">
  140. <view class="answerTitle">答案解析:</view>
  141. <view class="answerContent">
  142. <rich-text :nodes="bank.analysisContent"></rich-text>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <!-- 案例题 -->
  148. <template v-if="bank.type == 4">
  149. <view class="tabs">
  150. <view class="tab" :class="{current:tabIndex == bank.current}" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect(tabIndex,bankIndex)">问题{{tabIndex}}</view>
  151. </view>
  152. <view v-for="(ansItem,ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  153. <view class="titles">
  154. <rich-text :nodes="ansItem.content"></rich-text>
  155. </view>
  156. <template v-if="ansItem.type == 1">
  157. <view v-if="!bank.ques[ansIndex]">
  158. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild(option.optionsId,ansIndex,bankIndex)">
  159. <view class="activeTI">{{ ast[childIndex] }}</view>
  160. <rich-text class="textChild" :nodes="option.content"></rich-text>
  161. </view>
  162. </view>
  163. <view v-if="bank.ques[ansIndex]">
  164. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  165. <text :class="{right:(option.optionsId == bank.ques[ansIndex]) || (option.optionsId == bank.ans[ansIndex]),wrong:(option.optionsId == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childIndex] }}</text>
  166. <rich-text :nodes="option.content"></rich-text>
  167. </view>
  168. </view>
  169. <view v-if="bank.ques[ansIndex]">
  170. <view class="pad_8 answer">
  171. <view>正确答案:{{ast[bank.ans[ansIndex]-1]}}</view>
  172. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]-1]}}</view>
  173. </view>
  174. <view class="pad_8 answerInfos">
  175. <view class="answerTitle">答案解析</view>
  176. <view class="answerContent">
  177. <rich-text :nodes="option.analysisContent"></rich-text>
  178. </view>
  179. </view>
  180. </view>
  181. </template>
  182. <template v-if="ansItem.type == 2">
  183. <view v-if="!bank.ques[ansIndex]">
  184. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty" @click="checkboxSelectChild(bankIndex,ansIndex,childindex)">
  185. <view :class="{checked:option.checked}" class="activeTI">{{ ast[childindex] }}</view>
  186. <rich-text :nodes="option.content"></rich-text>
  187. </view>
  188. </view>
  189. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex,ansIndex)">
  190. 确认答案
  191. </view>
  192. <view v-if="bank.ques && bank.ques[ansIndex]">
  193. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  194. <text :class="{right:right(bankIndex,ansIndex,option),wrong:wrong(bankIndex,ansIndex,option)}" class="activeTI">{{ ast[childindex] }}</text>
  195. <rich-text :nodes="option.content"></rich-text>
  196. </view>
  197. </view>
  198. <view v-if="bank.ques[ansIndex]">
  199. <view class="pad_8 answer">
  200. <view>正确答案:
  201. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  202. </view>
  203. <view v-if="!explain">我的答案:
  204. <text v-for="quesItem in bank.ques[ansIndex]">{{ast[quesItem-1]}}</text>
  205. </view>
  206. </view>
  207. <view class="pad_8 answerInfos">
  208. <view class="answerTitle">答案解析</view>
  209. <view class="answerContent">
  210. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  211. </view>
  212. </view>
  213. </view>
  214. </template>
  215. <template v-if="ansItem.type == 3">
  216. <view v-if="!bank.ques[ansIndex]">
  217. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex,childindex,bankIndex)">
  218. <view class="activeTI">{{ ast[childindex] }}</view>
  219. {{ option }}
  220. </view>
  221. </view>
  222. <view v-if="bank.ques[ansIndex]">
  223. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  224. <text :class="{right:(childindex == bank.ques[ansIndex]) || (childindex == bank.ans[ansIndex]),wrong:(childindex == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childindex] }}</text>
  225. {{ option }}
  226. </view>
  227. </view>
  228. <view v-if="bank.ques[ansIndex]">
  229. <view class="pad_8 answer">
  230. <view>正确答案:{{ast[bank.ans[ansIndex]]}}</view>
  231. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]]}}</view>
  232. </view>
  233. <view class="pad_8 answerInfos">
  234. <view class="answerTitle">答案解析</view>
  235. <view class="answerContent">
  236. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  237. </view>
  238. </view>
  239. </view>
  240. </template>
  241. <!-- 简答题 -->
  242. <template v-if="ansItem.type == 5">
  243. <view class="ans">
  244. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  245. <view class="top flex">
  246. <image class="icon" @click="chooseImgChild(bankIndex,ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  247. <view class="progress">{{ansItem.ansText.imageList.length}}/4</view>
  248. <view class="submit" @click="submitAnsChild(bankIndex,ansIndex)">确认答案</view>
  249. </view>
  250. <view class="textarea">
  251. <textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea>
  252. </view>
  253. <view class="imgs">
  254. <view class="img" v-for="(img,imgIndex) in ansItem.ansText.imageList" >
  255. <text @click="deleteImgChild(imgIndex,bankIndex,ansIndex)">x</text>
  256. <image :src="$method.splitImgHost(img, true)"></image>
  257. </view>
  258. </view>
  259. </view>
  260. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex] && !explain">
  261. <view class="answerTitle">答案我的</view>
  262. {{bank.ques[ansIndex].text}}
  263. <view class="imgs">
  264. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques,true)"></image>
  265. </view>
  266. </view>
  267. </view>
  268. <view v-if="bank.ques[ansIndex]">
  269. <view class="pad_8 answerInfos">
  270. <view class="answerTitle">答案解析</view>
  271. <view class="answerContent">
  272. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  273. </view>
  274. </view>
  275. </view>
  276. </template>
  277. </view>
  278. </template>
  279. </view>
  280. <view class="footer_btn">
  281. <view class="flex_center" @click="openFooterTab">
  282. <view class="up-icon">
  283. <image src="/static/up.png"></image>
  284. </view>
  285. 答题卡
  286. </view>
  287. <view class="collect" :class="{show:!explain}" @click="pdsubmit">
  288. <view>
  289. <image src="/static/jj.png" mode=""></image>
  290. <view>交卷</view>
  291. </view>
  292. </view>
  293. </view>
  294. </view>
  295. </swiper-item>
  296. </swiper>
  297. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  298. <view class="popupView">
  299. <view class="popupTops">
  300. <view class="topIcon"></view>
  301. 点击编号即可跳转至对应题目
  302. </view>
  303. <view class="popupContent">
  304. <scroll-view scroll-y="true" style="height: 506rpx;">
  305. <view class="boxSty">
  306. <view v-for="(item, index) in questionList" :key="index" @click="changeIndex(index)" :class="{isRight:isRight(item,index),isWrong:isWrong(item,index)}" class="liListSty">{{ index + 1 }}</view>
  307. </view>
  308. </scroll-view>
  309. </view>
  310. </view>
  311. </u-popup>
  312. <view class="dialog" v-if="showDialog">
  313. <view class="text">左右滑动切换上下题</view>
  314. <view class="btn" @click="hideDialog">我知道了</view>
  315. </view>
  316. </view>
  317. </template>
  318. <script>
  319. export default {
  320. data() {
  321. return {
  322. id:'',
  323. current:0,
  324. questionList:[],
  325. ast: ['A', 'B', 'C', 'D','E','F','G'],
  326. judge:['错误','正确'],
  327. show: false,
  328. showDialog:true,
  329. isFromReport:'', //来自答题报告
  330. bankList: [],
  331. collectList:[],
  332. goodsId:'',
  333. examId:'',
  334. explain:'',
  335. };
  336. },
  337. onLoad(option){
  338. this.id = option.id || '';
  339. this.examId = option.examId || '';
  340. this.isFromReport = option.isFromReport;
  341. this.explain = option.explain || '';
  342. // if(this.isFromReport) { //通过答题报告查询错题列表
  343. // console.log(2)
  344. // this.wrongRecordList();
  345. // } else { //通过错题集查询错题列表
  346. // console.log(1)
  347. this.wrongRecordExamQuestionList();
  348. // }
  349. },
  350. onUnload() {
  351. },
  352. methods: {
  353. /**
  354. * 通过答题报告查询错题列表
  355. */
  356. wrongRecordList() {
  357. this.$api.wrongRecordList({
  358. recordId:this.id,
  359. }).then(res => {
  360. res.data.rows.forEach((item,index) => {
  361. if(typeof item.jsonStr == 'string') {
  362. item.jsonStr = JSON.parse(item.jsonStr)
  363. if(item.type == 2) { //多选
  364. item.jsonStr.forEach(str => {
  365. str.optionsId = ''+str.optionsId;
  366. })
  367. let arr = item.answerQuestion.split(',');
  368. arr.forEach((a,i) => {
  369. arr[i] = ''+a;
  370. })
  371. item.ans = arr;
  372. if(this.explain) {
  373. item.ques = item.ans;
  374. }
  375. return;
  376. } else if(item.type == 5) {
  377. item.ansText = {
  378. text: '',
  379. imageList: []
  380. }
  381. if(this.explain) {
  382. item.ques = {
  383. text:item.analysisContent
  384. }
  385. return;
  386. }
  387. } else if(item.type == 4) {
  388. console.log(item.jsonStr)
  389. item.ques = []
  390. item.current = 0;
  391. let ansArr = [];
  392. item.jsonStr.forEach((json,index) => {
  393. if(json.type == 1) {
  394. ansArr[index] = json.answerQuestion;
  395. } else if(json.type == 2) {
  396. json.optionsList.forEach(str => {
  397. str.optionsId = ''+str.optionsId;
  398. })
  399. let arr = json.answerQuestion.split(',');
  400. arr.forEach((a,i) => {
  401. arr[i] = ''+a;
  402. })
  403. ansArr[index] = arr
  404. } else if(json.type == 3) {
  405. ansArr[index] = json.answerQuestion;
  406. } else if(json.type == 5) {
  407. ansArr[index] = {
  408. text: '',
  409. imageList: []
  410. }
  411. json.ansText = {
  412. text: '',
  413. imageList: []
  414. }
  415. }
  416. })
  417. item.ans = ansArr
  418. if(this.explain) {
  419. item.ques = item.ans;
  420. }
  421. return;
  422. }
  423. item.ans = item.answerQuestion
  424. if(this.explain) {
  425. item.ques = item.ans;
  426. }
  427. } else {
  428. if(this.explain) {
  429. item.ques = item.ans;
  430. }
  431. }
  432. })
  433. this.questionList = res.data.rows;
  434. })
  435. },
  436. /**
  437. * 通过错题集查询错题列表
  438. */
  439. wrongRecordExamQuestionList() {
  440. this.$api.wrongRecordExamQuestionList({
  441. examId:this.examId,
  442. recordId:this.id,
  443. }).then(res => {
  444. res.data.rows.forEach((item,index) => {
  445. if(typeof item.jsonStr == 'string') {
  446. item.jsonStr = JSON.parse(item.jsonStr)
  447. if(item.type == 2) { //多选
  448. item.jsonStr.forEach(str => {
  449. str.optionsId = ''+str.optionsId;
  450. })
  451. let arr = item.answerQuestion.split(',');
  452. arr.forEach((a,i) => {
  453. arr[i] = ''+a;
  454. })
  455. item.ans = arr;
  456. if(this.explain) {
  457. item.ques = item.ans;
  458. }
  459. return;
  460. } else if(item.type == 5) {
  461. item.ansText = {
  462. text: '',
  463. imageList: []
  464. }
  465. if(this.explain) {
  466. item.ques = {
  467. text:item.analysisContent
  468. }
  469. return;
  470. }
  471. } else if(item.type == 4) {
  472. console.log(item.jsonStr)
  473. item.ques = []
  474. item.current = 0;
  475. let ansArr = [];
  476. item.jsonStr.forEach((json,index) => {
  477. if(json.type == 1) {
  478. ansArr[index] = json.answerQuestion;
  479. } else if(json.type == 2) {
  480. json.optionsList.forEach(str => {
  481. str.optionsId = ''+str.optionsId;
  482. })
  483. let arr = json.answerQuestion.split(',');
  484. arr.forEach((a,i) => {
  485. arr[i] = ''+a;
  486. })
  487. ansArr[index] = arr
  488. } else if(json.type == 3) {
  489. ansArr[index] = json.answerQuestion;
  490. } else if(json.type == 5) {
  491. ansArr[index] = {
  492. text: '',
  493. imageList: []
  494. }
  495. json.ansText = {
  496. text: '',
  497. imageList: []
  498. }
  499. }
  500. })
  501. item.ans = ansArr
  502. if(this.explain) {
  503. item.ques = item.ans;
  504. }
  505. return;
  506. }
  507. item.ans = item.answerQuestion
  508. if(this.explain) {
  509. item.ques = item.ans;
  510. }
  511. } else {
  512. if(this.explain) {
  513. item.ques = item.ans;
  514. }
  515. }
  516. })
  517. this.questionList = res.data.rows;
  518. })
  519. },
  520. /**
  521. * @param {Object} e单选点击
  522. */
  523. radioSelect(optionsId,bindex) {
  524. if(this.questionList[bindex].ques) return;
  525. this.$set(this.questionList[bindex],'ques',optionsId)
  526. // 回答错误
  527. if(this.questionList[bindex].ques != this.questionList[bindex].ans) {
  528. } else {
  529. this.$api.wrongRecordDelete({
  530. "examId": this.questionList[bindex].examId,
  531. "goodsId": this.questionList[bindex].goodsId,
  532. "questionId": this.questionList[bindex].questionId,
  533. }).then(res => {
  534. })
  535. }
  536. },
  537. /**
  538. * @param {Object} e单选点击
  539. */
  540. radioSelectChild(optionsId,ansIndex,bindex) {
  541. if(this.questionList[bindex].ques[ansIndex]) return;
  542. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  543. },
  544. /**
  545. * @param {Object} 多选点击
  546. */
  547. checkboxSelect(optionsId,bindex,index) {
  548. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  549. },
  550. /**
  551. * @param {Object} 多选点击
  552. */
  553. checkboxSelectChild(bindex,ansIndex,childIndex) {
  554. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  555. },
  556. /**
  557. * @param {Object} 多选确认
  558. */
  559. checkboxSubmit(bindex) {
  560. if(this.questionList[bindex].ques) return;
  561. let arr = [];
  562. this.questionList[bindex].jsonStr.forEach(item => {
  563. if(item.checked) {
  564. arr.push(item.optionsId)
  565. }
  566. })
  567. this.$set(this.questionList[bindex],'ques',arr)
  568. let isWrong = this.questionList[bindex].ques.some((quesItem,quesIndex) => {
  569. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex]
  570. })
  571. // 回答错误
  572. if(isWrong) {
  573. } else {
  574. let question = this.questionList.find(item => item.questionId == this.questionList[bindex].questionId);
  575. if(question) {
  576. this.$api.wrongRecordDelete({
  577. "examId": question.examId,
  578. "goodsId": question.goodsId,
  579. "questionId": question.questionId,
  580. }).then(res => {
  581. })
  582. }
  583. }
  584. },
  585. /**
  586. * @param {Object} 多选确认
  587. */
  588. checkboxSubmitChild(bindex,ansIndex) {
  589. if(this.questionList[bindex].ques[ansIndex]) return;
  590. let arr = [];
  591. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  592. if(item.checked) {
  593. arr.push(item.optionsId)
  594. }
  595. })
  596. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  597. },
  598. judgeSelect(index,bindex) {
  599. if(this.questionList[bindex].ques) return;
  600. this.$set(this.questionList[bindex],'ques',index+'')
  601. // 回答错误
  602. if(this.questionList[bindex].ques != this.questionList[bindex].ans) {
  603. } else {
  604. this.$api.wrongRecordDelete({
  605. "examId": this.questionList[bindex].examId,
  606. "goodsId": this.questionList[bindex].goodsId,
  607. "questionId": this.questionList[bindex].questionId,
  608. }).then(res => {
  609. })
  610. }
  611. },
  612. judgeSelectChild(ansindex,childindex,bindex) {
  613. if(this.questionList[bindex].ques[ansindex]) return;
  614. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  615. },
  616. openFooterTab() {
  617. this.show = true;
  618. },
  619. hideDialog() {
  620. this.showDialog = false
  621. },
  622. changeIndex(index) {
  623. this.current = index
  624. },
  625. swiperChange(e) {
  626. this.current = e.detail.current;
  627. },
  628. deleteImg(imgIndex,bankIndex) {
  629. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  630. },
  631. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  632. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  633. },
  634. chooseImg(bankindex) {
  635. uni.chooseImage({
  636. count: 1, //默认9
  637. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  638. sourceType: ['album','camera'], //从相册选择
  639. success: (res) => {
  640. let self = this;
  641. // console.log(JSON.stringify(res.tempFilePaths));
  642. let img = res.tempFilePaths[0];
  643. uni.getImageInfo({
  644. src: img,
  645. success: async res => {
  646. let canvasWidth = res.width; //图片原始长宽
  647. let canvasHeight = res.height;
  648. if (canvasWidth > 1000 || canvasHeight > 1000) {
  649. uni.compressImage({
  650. src: img,
  651. quality: 75,
  652. width: '50%',
  653. height: '50%',
  654. success: async rest => {
  655. const dir = await self.uploadFile(rest.tempFilePath, 0);
  656. this.questionList[bankindex].ansText.imageList.push(dir)
  657. }
  658. });
  659. } else {
  660. const dir = await self.uploadFile(img, 0);
  661. this.questionList[bankindex].ansText.imageList.push(dir)
  662. }
  663. }
  664. });
  665. }
  666. })
  667. },
  668. chooseImgChild(bankindex,ansindex) {
  669. uni.chooseImage({
  670. count: 1, //默认9
  671. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  672. sourceType: ['album','camera'], //从相册选择
  673. success: (res) => {
  674. let self = this;
  675. // console.log(JSON.stringify(res.tempFilePaths));
  676. let img = res.tempFilePaths[0];
  677. uni.getImageInfo({
  678. src: img,
  679. success: async res => {
  680. let canvasWidth = res.width; //图片原始长宽
  681. let canvasHeight = res.height;
  682. if (canvasWidth > 1000 || canvasHeight > 1000) {
  683. uni.compressImage({
  684. src: img,
  685. quality: 75,
  686. width: '50%',
  687. height: '50%',
  688. success: async rest => {
  689. const dir = await self.uploadFile(rest.tempFilePath, 0);
  690. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  691. }
  692. });
  693. } else {
  694. const dir = await self.uploadFile(img, 0);
  695. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  696. }
  697. }
  698. });
  699. }
  700. })
  701. },
  702. uploadFile(options, int) {
  703. var self = this;
  704. return new Promise((resolve, reject) => {
  705. var data = {
  706. imageStatus: int
  707. };
  708. self.$api.aliyunpolicy(data).then(res => {
  709. console.log(res.data,6)
  710. if(res.data.code!=200){
  711. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  712. return
  713. }
  714. var ossToken = res.data.data.resultContent;
  715. if(ossToken.host==null||ossToken.host==undefined){
  716. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  717. return
  718. }
  719. uni.uploadFile({
  720. url: ossToken.host,
  721. name: 'file',
  722. filePath: options,
  723. fileType: 'image',
  724. header: {
  725. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  726. },
  727. formData: {
  728. key: ossToken.dir,
  729. OSSAccessKeyId: ossToken.accessid,
  730. policy: ossToken.policy,
  731. Signature: ossToken.signature,
  732. callback: ossToken.callback,
  733. success_action_status: 200
  734. },
  735. success: result => {
  736. if (result.statusCode === 200) {
  737. resolve(ossToken.dir);
  738. } else {
  739. uni.showToast({
  740. title: '上传失败',
  741. icon: 'none'
  742. });
  743. return;
  744. }
  745. },
  746. fail: error => {
  747. uni.showToast({
  748. title: '上传接口报错'+error,
  749. icon: 'none'
  750. });
  751. return;
  752. }
  753. });
  754. });
  755. });
  756. },
  757. submitAns(bankindex) {
  758. console.log(this.questionList[bankindex])
  759. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  760. uni.showToast({
  761. title: '请输入内容或上传图片',
  762. duration: 2000,
  763. icon:'none'
  764. });
  765. return
  766. }
  767. this.$set(this.questionList[bankindex],'ques',{
  768. imageList:this.questionList[bankindex].ansText.imageList,
  769. text:this.questionList[bankindex].ansText.text,
  770. })
  771. },
  772. submitAnsChild(bankindex,ansindex) {
  773. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  774. uni.showToast({
  775. title: '请输入内容或上传图片',
  776. duration: 2000,
  777. icon:'none'
  778. });
  779. return
  780. }
  781. this.$set(this.questionList[bankindex].ques,ansindex,{
  782. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  783. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  784. })
  785. },
  786. isRight(item,index) {
  787. //单选
  788. if(this.questionList[index].ques) {
  789. if(item.type == 1) {
  790. return this.questionList[index].ques == this.questionList[index].ans;
  791. //多选
  792. } else if(item.type == 2) {
  793. //每一项都相等
  794. return this.questionList[index].ques.every((item,i) => {
  795. return item == this.questionList[index].ans[i];
  796. })
  797. //判断
  798. } else if(item.type == 3) {
  799. return this.questionList[index].ques == this.questionList[index].ans;
  800. } else {
  801. return false;
  802. }
  803. } else {
  804. return false;
  805. }
  806. },
  807. right(bankIndex,ansIndex,option) {
  808. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  809. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  810. return true
  811. } else {
  812. return false;
  813. }
  814. } else {
  815. return false;
  816. }
  817. },
  818. wrong(bankIndex,ansIndex,option) {
  819. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  820. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  821. return true;
  822. } else {
  823. return false;
  824. }
  825. } else {
  826. return false;
  827. }
  828. },
  829. isWrong(item,index) {
  830. if(this.questionList[index].ques) {
  831. //单选
  832. if(item.type == 1) {
  833. return this.questionList[index].ques != this.questionList[index].ans;
  834. //多选
  835. } else if(item.type == 2) {
  836. //每一项都相等
  837. return this.questionList[index].ques.some((item,index) => {
  838. return item != this.questionList[index].ans;
  839. })
  840. //判断
  841. } else if(item.type == 3) {
  842. return this.questionList[index].ques != this.questionList[index].ans;
  843. } else {
  844. return false;
  845. }
  846. } else {
  847. return false;
  848. }
  849. },
  850. tabSelect(index,bankindex) {
  851. this.$set(this.questionList[bankindex],'current',index)
  852. },
  853. pdsubmit() {
  854. uni.showToast({
  855. icon:'none',
  856. title:'交卷成功',
  857. duration:1000,
  858. })
  859. setTimeout(() => {
  860. uni.navigateBack({
  861. delta:1
  862. })
  863. },1000)
  864. }
  865. }
  866. };
  867. </script>
  868. <style lang="scss" scoped>
  869. .swiper {
  870. width:100%;
  871. height:100vh;
  872. }
  873. .lisSty {
  874. margin-bottom: 16rpx;
  875. display: flex;
  876. .flex_auto {
  877. flex:1;
  878. }
  879. }
  880. .activeTI {
  881. vertical-align: middle;
  882. display: inline-block;
  883. border: 1rpx solid #eee;
  884. border-radius: 50rpx;
  885. height: 48rpx;
  886. line-height: 46rpx;
  887. text-align: center;
  888. width: 48rpx;
  889. margin-right: 15rpx;
  890. color: #666;
  891. font-size: 30rpx;
  892. &.right {
  893. color:#fff;
  894. background:green;
  895. }
  896. &.wrong {
  897. color:#fff;
  898. background:red;
  899. }
  900. &.checked {
  901. color:#fff;
  902. background:blue;
  903. }
  904. }
  905. .submit_checkbox {
  906. margin:20rpx auto;
  907. width: 526rpx;
  908. height: 80rpx;
  909. background: rgba(0, 122, 255, 1);
  910. color:#fff;
  911. text-align: center;
  912. line-height: 80rpx;
  913. font-size: 30rpx;
  914. border-radius: 40rpx;
  915. }
  916. .titles {
  917. overflow: hidden;
  918. margin-bottom: 24rpx;
  919. }
  920. .titBox {
  921. padding: 41rpx 25rpx 24rpx 25rpx;
  922. }
  923. .tabs {
  924. margin:10rpx;
  925. display: flex;
  926. .tab {
  927. margin:0 10rpx;
  928. width: 96rpx;
  929. height: 48rpx;
  930. line-height: 48rpx;
  931. text-align: center;
  932. color:#007AFF;
  933. font-size: 28rpx;
  934. border-radius: 16rpx;
  935. &.current {
  936. color:#fff;
  937. background: #007AFF;
  938. }
  939. }
  940. }
  941. .ans {
  942. margin:8rpx 8rpx 8rpx;
  943. .ans_input {
  944. border-radius: 16rpx;
  945. background:#fff;
  946. .top {
  947. border-bottom:1rpx solid #EEEEEE;
  948. padding: 16rpx;
  949. display: flex;
  950. align-items: center;
  951. .icon {
  952. margin-right:20rpx;
  953. width: 40rpx;
  954. height: 38rpx;
  955. }
  956. .progress {
  957. flex:1;
  958. }
  959. .submit {
  960. width: 168rpx;
  961. height: 48rpx;
  962. line-height: 48rpx;
  963. text-align: center;
  964. color:#fff;
  965. font-size: 30rpx;
  966. background: #007AFF;
  967. border-radius: 24rpx;
  968. }
  969. }
  970. .textarea {
  971. textarea {
  972. width:100%;
  973. height:287rpx;
  974. padding:10rpx;
  975. }
  976. }
  977. .imgs {
  978. overflow: hidden;
  979. display: flex;
  980. width:100%;
  981. .img {
  982. width: 104rpx;
  983. height: 104rpx;
  984. border-radius: 8rpx;
  985. position:relative;
  986. margin:20rpx;
  987. text {
  988. position:absolute;
  989. right:-15rpx;
  990. top:-15rpx;
  991. width:30rpx;
  992. height:30rpx;
  993. text-align: center;
  994. line-height: 30rpx;
  995. color:#fff;
  996. background:red;
  997. border-radius:50%;
  998. }
  999. image {
  1000. width:100%;
  1001. height:100%;
  1002. }
  1003. }
  1004. }
  1005. }
  1006. .ans_submit {
  1007. padding:16rpx;
  1008. border-radius: 16rpx;
  1009. background:#fff;
  1010. .imgs {
  1011. overflow: hidden;
  1012. display: flex;
  1013. width:100%;
  1014. .img {
  1015. width: 104rpx;
  1016. height: 104rpx;
  1017. border-radius: 8rpx;
  1018. position:relative;
  1019. margin:20rpx;
  1020. image {
  1021. width:100%;
  1022. height:100%;
  1023. }
  1024. }
  1025. }
  1026. }
  1027. }
  1028. .firstLetter {
  1029. display: flex;
  1030. justify-content: space-between;
  1031. align-items: center;
  1032. margin-bottom: 30rpx;
  1033. .leftLetters {
  1034. display: flex;
  1035. align-items: center;
  1036. width: 220rpx;
  1037. .btnType {
  1038. padding: 5rpx 10rpx;
  1039. border: 1rpx solid #007aff;
  1040. border-radius: 10rpx;
  1041. background-color: rgba(0, 122, 255, 0.1);
  1042. font-size: 28rpx;
  1043. color: #007aff;
  1044. margin-right: 15rpx;
  1045. }
  1046. }
  1047. }
  1048. .popupView {
  1049. height: 100%;
  1050. padding-bottom: 100rpx;
  1051. .popupTops {
  1052. height: 77rpx;
  1053. border-bottom: 1rpx solid #eee;
  1054. text-align: center;
  1055. line-height: 77rpx;
  1056. font-size: 24rpx;
  1057. color: #999;
  1058. position: relative;
  1059. .topIcon {
  1060. position: absolute;
  1061. top: 10rpx;
  1062. left: 50%;
  1063. transform: translateX(-50%);
  1064. width: 80rpx;
  1065. height: 8rpx;
  1066. background-color: #999;
  1067. border-radius: 4rpx;
  1068. }
  1069. }
  1070. .popupContent {
  1071. }
  1072. }
  1073. .pageContent {
  1074. position:relative;
  1075. background-color: #eaeef1;
  1076. height: 100%;
  1077. overflow-y: scroll;
  1078. padding-top: 8rpx;
  1079. padding-bottom: 100rpx;
  1080. }
  1081. .pad_8 {
  1082. background-color: #fff;
  1083. margin: 0rpx 8rpx 8rpx;
  1084. border-radius: 16rpx;
  1085. }
  1086. .answer {
  1087. height: 80rpx;
  1088. line-height: 80rpx;
  1089. padding: 0rpx 24rpx;
  1090. display: flex;
  1091. align-items: center;
  1092. justify-content: space-between;
  1093. color: #666;
  1094. font-size: 30rpx;
  1095. }
  1096. .footer_btn {
  1097. background-color: #fff;
  1098. z-index: 10078;
  1099. position: fixed;
  1100. bottom: 0rpx;
  1101. display: flex;
  1102. align-items: center;
  1103. justify-content: space-between;
  1104. width: 100%;
  1105. height: 98rpx;
  1106. padding: 0rpx 38rpx;
  1107. border-top: 1rpx solid #eee;
  1108. .flex_center {
  1109. flex:1;
  1110. display: flex;
  1111. justify-content: center;
  1112. align-items: center;
  1113. flex-direction: column;
  1114. margin:0 200rpx;
  1115. font-size: 24rpx;
  1116. color: #999999;
  1117. .up-icon {
  1118. margin-bottom:18rpx;
  1119. width:100%;
  1120. display: flex;
  1121. justify-content: center;
  1122. image {
  1123. width:58rpx;
  1124. height:21rpx;
  1125. }
  1126. }
  1127. }
  1128. .collect {
  1129. visibility: hidden;
  1130. &.show {
  1131. visibility: visible;
  1132. }
  1133. >view {
  1134. display: flex;
  1135. flex-direction: column;
  1136. align-items: center;
  1137. justify-content: center;
  1138. image {
  1139. width:32rpx;
  1140. height:32rpx;
  1141. margin-bottom:6rpx;
  1142. }
  1143. view {
  1144. font-size: 24rpx;
  1145. color: #999999;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. .boxSty {
  1151. padding: 44rpx 41rpx 0rpx;
  1152. }
  1153. .liListSty {
  1154. border:1rpx solid #EEEEEE;
  1155. width: 88rpx;
  1156. height: 88rpx;
  1157. border-radius: 32rpx;
  1158. text-align: center;
  1159. line-height: 88rpx;
  1160. color: #333;
  1161. font-size: 32rpx;
  1162. float: left;
  1163. margin: 20rpx 23rpx;
  1164. &.isRight {
  1165. border:1rpx solid #EEEEEE;
  1166. color:#fff;
  1167. background: green;
  1168. }
  1169. &.isWrong {
  1170. border:1rpx solid #EEEEEE;
  1171. color:#fff;
  1172. background: red;
  1173. }
  1174. }
  1175. .answerInfos {
  1176. padding: 25rpx 25rpx 25rpx 23rpx;
  1177. }
  1178. .answerTitle {
  1179. margin-bottom: 28rpx;
  1180. color: #666;
  1181. font-size: 30rpx;
  1182. }
  1183. .answerContent {
  1184. font-size: 30rpx;
  1185. color: #666;
  1186. }
  1187. .textChild {
  1188. display: inline-block;
  1189. vertical-align: middle;
  1190. }
  1191. .dialog {
  1192. position: fixed;
  1193. left:0;
  1194. top:0;
  1195. width:100%;
  1196. height:100%;
  1197. background-color: rgba(0,0,0,0.8);
  1198. display: flex;
  1199. flex-direction: column;
  1200. align-items: center;
  1201. justify-content: center;
  1202. z-index: 20000;
  1203. .text {
  1204. font-size: 32rpx;
  1205. color: #FFFFFF;
  1206. text-align: center;
  1207. }
  1208. .btn {
  1209. width: 242rpx;
  1210. height: 82rpx;
  1211. border: 2rpx solid #FFFFFF;
  1212. border-radius: 16rpx;
  1213. text-align: center;
  1214. line-height: 82rpx;
  1215. margin:41rpx auto;
  1216. color:#fff;
  1217. font-size: 32rpx;
  1218. }
  1219. }
  1220. </style>