questionBankExplain.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  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">0/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">0/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" v-if="isContinue">
  281. <view class="collect"></view>
  282. <view @click="openFooterTab">答题卡</view>
  283. <view @click="submit">交卷</view>
  284. </view>
  285. </view>
  286. </swiper-item>
  287. </swiper>
  288. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  289. <view class="popupView">
  290. <view class="popupTops">
  291. <view class="topIcon"></view>
  292. 点击编号即可跳转至对应题目
  293. </view>
  294. <view class="popupContent">
  295. <scroll-view scroll-y="true" style="height: 506rpx;">
  296. <view class="boxSty">
  297. <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>
  298. </view>
  299. </scroll-view>
  300. </view>
  301. </view>
  302. </u-popup>
  303. <view class="dialog" v-if="showDialog">
  304. <view class="text">左右滑动切换上下题</view>
  305. <view class="btn" @click="hideDialog">我知道了</view>
  306. </view>
  307. </view>
  308. </template>
  309. <script>
  310. export default {
  311. data() {
  312. return {
  313. id:'',
  314. current:0,
  315. questionList:[],
  316. ast: ['A', 'B', 'C', 'D','E','F','G'],
  317. judge:['错误','正确'],
  318. show: false,
  319. showDialog:true,
  320. bankList: [],
  321. collectList:[],
  322. goodsId:'',
  323. explain:'',
  324. isContinue:'',
  325. chapterId:'',
  326. moduleId:'',
  327. isSubmit:false,
  328. };
  329. },
  330. onLoad(option){
  331. this.id = option.id;
  332. this.explain = option.explain;
  333. this.isContinue = option.continue;
  334. this.goodsId = option.goodsid;
  335. this.chapterId = option.chapterId;
  336. this.moduleId = option.moduleId;
  337. this.recordId = option.recordId;
  338. this.goodsQuestionList();
  339. },
  340. onUnload() {
  341. if(this.isSubmit) {
  342. return
  343. }
  344. this.examRecordEdit();
  345. },
  346. methods: {
  347. goodsQuestionList() {
  348. //继续答题
  349. if(this.isContinue) {
  350. this.$api.examReport(this.recordId).then(res => {
  351. let json = JSON.parse(res.data.data.historyExamJson)
  352. this.questionList = json;
  353. })
  354. } else { //解析
  355. this.$api.goodsQuestionList({
  356. examId:this.id
  357. }).then(res => {
  358. res.data.data.forEach((item,index) => {
  359. if(typeof item.jsonStr == 'string') {
  360. item.jsonStr = JSON.parse(item.jsonStr)
  361. if(item.type == 2) { //多选
  362. item.jsonStr.forEach(str => {
  363. str.optionsId = ''+str.optionsId;
  364. })
  365. let arr = item.answerQuestion.split(',');
  366. arr.forEach((a,i) => {
  367. arr[i] = ''+a;
  368. })
  369. item.ans = arr;
  370. if(this.explain) {
  371. item.ques = item.ans;
  372. }
  373. return;
  374. } else if(item.type == 5) {
  375. item.ansText = {
  376. text: '',
  377. imageList: []
  378. }
  379. if(this.explain) {
  380. item.ques = {
  381. text:item.analysisContent
  382. }
  383. return;
  384. }
  385. } else if(item.type == 4) {
  386. console.log(item.jsonStr)
  387. item.ques = []
  388. item.current = 0;
  389. let ansArr = [];
  390. item.jsonStr.forEach((json,index) => {
  391. if(json.type == 1) {
  392. ansArr[index] = json.answerQuestion;
  393. } else if(json.type == 2) {
  394. json.optionsList.forEach(str => {
  395. str.optionsId = ''+str.optionsId;
  396. })
  397. let arr = json.answerQuestion.split(',');
  398. arr.forEach((a,i) => {
  399. arr[i] = ''+a;
  400. })
  401. ansArr[index] = arr
  402. } else if(json.type == 3) {
  403. ansArr[index] = json.answerQuestion;
  404. } else if(json.type == 5) {
  405. ansArr[index] = {
  406. text: '',
  407. imageList: []
  408. }
  409. json.ansText = {
  410. text: '',
  411. imageList: []
  412. }
  413. }
  414. })
  415. item.ans = ansArr
  416. if(this.explain) {
  417. item.ques = item.ans;
  418. }
  419. return;
  420. }
  421. item.ans = item.answerQuestion
  422. if(this.explain) {
  423. item.ques = item.ans;
  424. }
  425. } else {
  426. if(this.explain) {
  427. item.ques = item.ans;
  428. }
  429. }
  430. })
  431. this.questionList = res.data.data;
  432. })
  433. }
  434. },
  435. /**
  436. * @param {Object} e单选点击
  437. */
  438. radioSelect(optionsId,bindex) {
  439. if(this.questionList[bindex].ques) return;
  440. this.$set(this.questionList[bindex],'ques',optionsId)
  441. },
  442. examRecordEdit() {
  443. if(!this.isSubmit) {
  444. let number = 0;
  445. let score = 0;
  446. this.questionList.forEach((item,index) => {
  447. if(item.type == 1) {
  448. if(item.ques == item.ans) {
  449. score += item.score;
  450. number++
  451. }
  452. } else if(item.type == 2) {
  453. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  454. return item.ques[quesIndex] == item.ans[quesIndex]
  455. })
  456. if(isRight) {
  457. score += item.score;
  458. number++
  459. }
  460. } else if(item.type == 3) {
  461. if(item.ques == item.ans) {
  462. score += item.score;
  463. number++
  464. }
  465. }
  466. })
  467. this.$api.examRecordEdit({
  468. examId:this.id,
  469. goodsId:this.goodsId,
  470. recordId: this.recordId,
  471. rightQuestionNum:number,
  472. status:0,
  473. historyExamJson:JSON.stringify(this.questionList)
  474. }).then(res => {
  475. })
  476. }
  477. },
  478. /**
  479. * @param {Object} e单选点击
  480. */
  481. radioSelectChild(optionsId,ansIndex,bindex) {
  482. if(this.questionList[bindex].ques[ansIndex]) return;
  483. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  484. },
  485. /**
  486. * @param {Object} 多选点击
  487. */
  488. checkboxSelect(optionsId,bindex,index) {
  489. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  490. },
  491. /**
  492. * @param {Object} 多选点击
  493. */
  494. checkboxSelectChild(bindex,ansIndex,childIndex) {
  495. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  496. },
  497. /**
  498. * 提交数据
  499. */
  500. submit() {
  501. let score = 0; //计算总分
  502. let reportStatus = 0;
  503. let number = 0;
  504. this.questionList.forEach((item,index) => {
  505. if(item.type == 1) {
  506. if(item.ques == item.ans) {
  507. score += item.score;
  508. number++
  509. }
  510. } else if(item.type == 2) {
  511. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  512. return item.ques[quesIndex] == item.ans[quesIndex]
  513. })
  514. if(isRight) {
  515. score += item.score;
  516. number++
  517. }
  518. } else if(item.type == 3) {
  519. if(item.ques == item.ans) {
  520. score += item.score;
  521. number++
  522. }
  523. }
  524. })
  525. // if(score >= 60) {
  526. // reportStatus = 1
  527. // } else {
  528. // reportStatus = 0
  529. // }
  530. this.$api.examRecordEdit({
  531. examId:this.id,
  532. goodsId:this.goodsId,
  533. // reportStatus:reportStatus,
  534. recordId: this.recordId,
  535. rightQuestionNum:number,
  536. status:1,
  537. score:score,
  538. historyExamJson:JSON.stringify(this.questionList)
  539. }).then(res => {
  540. this.isSubmit = true;
  541. if(res.data.code == 200) {
  542. uni.showToast({
  543. title: '交卷成功',
  544. duration: 2000,
  545. icon:'none'
  546. });
  547. setTimeout(() => {
  548. uni.redirectTo({
  549. url:'/pages2/bank/question_report?id='+this.recordId
  550. })
  551. },2000)
  552. }
  553. })
  554. },
  555. /**
  556. * @param {Object} 多选确认
  557. */
  558. checkboxSubmit(bindex) {
  559. if(this.questionList[bindex].ques) return;
  560. let arr = [];
  561. this.questionList[bindex].jsonStr.forEach(item => {
  562. if(item.checked) {
  563. arr.push(item.optionsId)
  564. }
  565. })
  566. this.$set(this.questionList[bindex],'ques',arr)
  567. },
  568. /**
  569. * @param {Object} 多选确认
  570. */
  571. checkboxSubmitChild(bindex,ansIndex) {
  572. if(this.questionList[bindex].ques[ansIndex]) return;
  573. let arr = [];
  574. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  575. if(item.checked) {
  576. arr.push(item.optionsId)
  577. }
  578. })
  579. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  580. },
  581. judgeSelect(index,bindex) {
  582. if(this.questionList[bindex].ques) return;
  583. this.$set(this.questionList[bindex],'ques',index+'')
  584. },
  585. judgeSelectChild(ansindex,childindex,bindex) {
  586. if(this.questionList[bindex].ques[ansindex]) return;
  587. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  588. },
  589. openFooterTab() {
  590. this.show = true;
  591. },
  592. hideDialog() {
  593. this.showDialog = false
  594. },
  595. changeIndex(index) {
  596. this.current = index
  597. },
  598. swiperChange(e) {
  599. this.current = e.detail.current;
  600. },
  601. deleteImg(imgIndex,bankIndex) {
  602. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  603. },
  604. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  605. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  606. },
  607. chooseImg(bankindex) {
  608. uni.chooseImage({
  609. count: 1, //默认9
  610. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  611. sourceType: ['album','camera'], //从相册选择
  612. success: (res) => {
  613. let self = this;
  614. // console.log(JSON.stringify(res.tempFilePaths));
  615. let img = res.tempFilePaths[0];
  616. uni.getImageInfo({
  617. src: img,
  618. success: async res => {
  619. let canvasWidth = res.width; //图片原始长宽
  620. let canvasHeight = res.height;
  621. if (canvasWidth > 1000 || canvasHeight > 1000) {
  622. uni.compressImage({
  623. src: img,
  624. quality: 75,
  625. width: '50%',
  626. height: '50%',
  627. success: async rest => {
  628. const dir = await self.uploadFile(rest.tempFilePath, 0);
  629. this.questionList[bankindex].ansText.imageList.push(dir)
  630. }
  631. });
  632. } else {
  633. const dir = await self.uploadFile(img, 0);
  634. this.questionList[bankindex].ansText.imageList.push(dir)
  635. }
  636. }
  637. });
  638. }
  639. })
  640. },
  641. chooseImgChild(bankindex,ansindex) {
  642. uni.chooseImage({
  643. count: 1, //默认9
  644. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  645. sourceType: ['album','camera'], //从相册选择
  646. success: (res) => {
  647. let self = this;
  648. // console.log(JSON.stringify(res.tempFilePaths));
  649. let img = res.tempFilePaths[0];
  650. uni.getImageInfo({
  651. src: img,
  652. success: async res => {
  653. let canvasWidth = res.width; //图片原始长宽
  654. let canvasHeight = res.height;
  655. if (canvasWidth > 1000 || canvasHeight > 1000) {
  656. uni.compressImage({
  657. src: img,
  658. quality: 75,
  659. width: '50%',
  660. height: '50%',
  661. success: async rest => {
  662. const dir = await self.uploadFile(rest.tempFilePath, 0);
  663. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  664. }
  665. });
  666. } else {
  667. const dir = await self.uploadFile(img, 0);
  668. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  669. }
  670. }
  671. });
  672. }
  673. })
  674. },
  675. uploadFile(options, int) {
  676. var self = this;
  677. return new Promise((resolve, reject) => {
  678. var data = {
  679. imageStatus: int
  680. };
  681. self.$api.aliyunpolicy(data).then(res => {
  682. console.log(res.data,6)
  683. if(res.data.code!=200){
  684. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  685. return
  686. }
  687. var ossToken = res.data.data.resultContent;
  688. if(ossToken.host==null||ossToken.host==undefined){
  689. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  690. return
  691. }
  692. uni.uploadFile({
  693. url: ossToken.host,
  694. name: 'file',
  695. filePath: options,
  696. fileType: 'image',
  697. header: {
  698. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  699. },
  700. formData: {
  701. key: ossToken.dir,
  702. OSSAccessKeyId: ossToken.accessid,
  703. policy: ossToken.policy,
  704. Signature: ossToken.signature,
  705. callback: ossToken.callback,
  706. success_action_status: 200
  707. },
  708. success: result => {
  709. if (result.statusCode === 200) {
  710. resolve(ossToken.dir);
  711. } else {
  712. uni.showToast({
  713. title: '上传失败',
  714. icon: 'none'
  715. });
  716. return;
  717. }
  718. },
  719. fail: error => {
  720. uni.showToast({
  721. title: '上传接口报错'+error,
  722. icon: 'none'
  723. });
  724. return;
  725. }
  726. });
  727. });
  728. });
  729. },
  730. submitAns(bankindex) {
  731. console.log(this.questionList[bankindex])
  732. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  733. uni.showToast({
  734. title: '请输入内容或上传图片',
  735. duration: 2000,
  736. icon:'none'
  737. });
  738. return
  739. }
  740. this.$set(this.questionList[bankindex],'ques',{
  741. imageList:this.questionList[bankindex].ansText.imageList,
  742. text:this.questionList[bankindex].ansText.text,
  743. })
  744. },
  745. submitAnsChild(bankindex,ansindex) {
  746. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  747. uni.showToast({
  748. title: '请输入内容或上传图片',
  749. duration: 2000,
  750. icon:'none'
  751. });
  752. return
  753. }
  754. this.$set(this.questionList[bankindex].ques,ansindex,{
  755. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  756. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  757. })
  758. },
  759. isRight(item,index) {
  760. //单选
  761. if(this.questionList[index].ques) {
  762. if(item.type == 1) {
  763. return this.questionList[index].ques == this.questionList[index].ans;
  764. //多选
  765. } else if(item.type == 2) {
  766. //每一项都相等
  767. return this.questionList[index].ques.every((item,i) => {
  768. console.log(item == this.questionList[index].ans[i])
  769. return item == this.questionList[index].ans[i];
  770. })
  771. //判断
  772. } else if(item.type == 3) {
  773. return this.questionList[index].ques == this.questionList[index].ans;
  774. } else {
  775. return false;
  776. }
  777. } else {
  778. return false;
  779. }
  780. },
  781. right(bankIndex,ansIndex,option) {
  782. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  783. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  784. return true
  785. } else {
  786. return false;
  787. }
  788. } else {
  789. return false;
  790. }
  791. },
  792. wrong(bankIndex,ansIndex,option) {
  793. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  794. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  795. return true;
  796. } else {
  797. return false;
  798. }
  799. } else {
  800. return false;
  801. }
  802. },
  803. isWrong(item,index) {
  804. if(this.questionList[index].ques) {
  805. //单选
  806. if(item.type == 1) {
  807. return this.questionList[index].ques != this.questionList[index].ans;
  808. //多选
  809. } else if(item.type == 2) {
  810. //每一项都相等
  811. return this.questionList[index].ques.some((item,i) => {
  812. return item != this.questionList[index].ans[i];
  813. })
  814. //判断
  815. } else if(item.type == 3) {
  816. return this.questionList[index].ques != this.questionList[index].ans;
  817. } else {
  818. return false;
  819. }
  820. } else {
  821. return false;
  822. }
  823. },
  824. tabSelect(index,bankindex) {
  825. this.$set(this.questionList[bankindex],'current',index)
  826. },
  827. }
  828. };
  829. </script>
  830. <style lang="scss" scoped>
  831. .swiper {
  832. width:100%;
  833. height:100vh;
  834. }
  835. .lisSty {
  836. margin-bottom: 16rpx;
  837. display: flex;
  838. .flex_auto {
  839. flex:1;
  840. }
  841. }
  842. .activeTI {
  843. vertical-align: middle;
  844. display: inline-block;
  845. border: 1rpx solid #eee;
  846. border-radius: 50rpx;
  847. height: 48rpx;
  848. line-height: 46rpx;
  849. text-align: center;
  850. width: 48rpx;
  851. margin-right: 15rpx;
  852. color: #666;
  853. font-size: 30rpx;
  854. &.right {
  855. color:#fff;
  856. background:green;
  857. }
  858. &.wrong {
  859. color:#fff;
  860. background:red;
  861. }
  862. &.checked {
  863. color:#fff;
  864. background:blue;
  865. }
  866. }
  867. .submit_checkbox {
  868. margin:20rpx auto;
  869. width: 526rpx;
  870. height: 80rpx;
  871. background: rgba(0, 122, 255, 1);
  872. color:#fff;
  873. text-align: center;
  874. line-height: 80rpx;
  875. font-size: 30rpx;
  876. border-radius: 40rpx;
  877. }
  878. .titles {
  879. overflow: hidden;
  880. margin-bottom: 24rpx;
  881. }
  882. .titBox {
  883. padding: 41rpx 25rpx 24rpx 25rpx;
  884. }
  885. .tabs {
  886. margin:10rpx;
  887. display: flex;
  888. .tab {
  889. margin:0 10rpx;
  890. width: 96rpx;
  891. height: 48rpx;
  892. line-height: 48rpx;
  893. text-align: center;
  894. color:#007AFF;
  895. font-size: 28rpx;
  896. border-radius: 16rpx;
  897. &.current {
  898. color:#fff;
  899. background: #007AFF;
  900. }
  901. }
  902. }
  903. .ans {
  904. margin:8rpx 8rpx 8rpx;
  905. .ans_input {
  906. border-radius: 16rpx;
  907. background:#fff;
  908. .top {
  909. border-bottom:1rpx solid #EEEEEE;
  910. padding: 16rpx;
  911. display: flex;
  912. align-items: center;
  913. .icon {
  914. margin-right:20rpx;
  915. width: 40rpx;
  916. height: 38rpx;
  917. }
  918. .progress {
  919. flex:1;
  920. }
  921. .submit {
  922. width: 168rpx;
  923. height: 48rpx;
  924. line-height: 48rpx;
  925. text-align: center;
  926. color:#fff;
  927. font-size: 30rpx;
  928. background: #007AFF;
  929. border-radius: 24rpx;
  930. }
  931. }
  932. .textarea {
  933. textarea {
  934. width:100%;
  935. height:287rpx;
  936. padding:10rpx;
  937. }
  938. }
  939. .imgs {
  940. overflow: hidden;
  941. display: flex;
  942. width:100%;
  943. .img {
  944. width: 104rpx;
  945. height: 104rpx;
  946. border-radius: 8rpx;
  947. position:relative;
  948. margin:20rpx;
  949. text {
  950. position:absolute;
  951. right:-15rpx;
  952. top:-15rpx;
  953. width:30rpx;
  954. height:30rpx;
  955. text-align: center;
  956. line-height: 30rpx;
  957. color:#fff;
  958. background:red;
  959. border-radius:50%;
  960. }
  961. image {
  962. width:100%;
  963. height:100%;
  964. }
  965. }
  966. }
  967. }
  968. .ans_submit {
  969. padding:16rpx;
  970. border-radius: 16rpx;
  971. background:#fff;
  972. .imgs {
  973. overflow: hidden;
  974. display: flex;
  975. width:100%;
  976. .img {
  977. width: 104rpx;
  978. height: 104rpx;
  979. border-radius: 8rpx;
  980. position:relative;
  981. margin:20rpx;
  982. image {
  983. width:100%;
  984. height:100%;
  985. }
  986. }
  987. }
  988. }
  989. }
  990. .firstLetter {
  991. display: flex;
  992. justify-content: space-between;
  993. align-items: center;
  994. margin-bottom: 30rpx;
  995. .leftLetters {
  996. display: flex;
  997. align-items: center;
  998. width: 220rpx;
  999. .btnType {
  1000. padding: 5rpx 10rpx;
  1001. border: 1rpx solid #007aff;
  1002. border-radius: 10rpx;
  1003. background-color: rgba(0, 122, 255, 0.1);
  1004. font-size: 28rpx;
  1005. color: #007aff;
  1006. margin-right: 15rpx;
  1007. }
  1008. }
  1009. }
  1010. .popupView {
  1011. height: 100%;
  1012. padding-bottom: 100rpx;
  1013. .popupTops {
  1014. height: 77rpx;
  1015. border-bottom: 1rpx solid #eee;
  1016. text-align: center;
  1017. line-height: 77rpx;
  1018. font-size: 24rpx;
  1019. color: #999;
  1020. position: relative;
  1021. .topIcon {
  1022. position: absolute;
  1023. top: 10rpx;
  1024. left: 50%;
  1025. transform: translateX(-50%);
  1026. width: 80rpx;
  1027. height: 8rpx;
  1028. background-color: #999;
  1029. border-radius: 4rpx;
  1030. }
  1031. }
  1032. .popupContent {
  1033. }
  1034. }
  1035. .pageContent {
  1036. position:relative;
  1037. background-color: #eaeef1;
  1038. min-height: 100vh;
  1039. padding-top: 8rpx;
  1040. padding-bottom: 100rpx;
  1041. }
  1042. .pad_8 {
  1043. background-color: #fff;
  1044. margin: 0rpx 8rpx 8rpx;
  1045. border-radius: 16rpx;
  1046. }
  1047. .answer {
  1048. height: 80rpx;
  1049. line-height: 80rpx;
  1050. padding: 0rpx 24rpx;
  1051. display: flex;
  1052. align-items: center;
  1053. justify-content: space-between;
  1054. color: #666;
  1055. font-size: 30rpx;
  1056. }
  1057. .footer_btn {
  1058. background-color: #fff;
  1059. z-index: 10078;
  1060. position: fixed;
  1061. bottom: 0rpx;
  1062. display: flex;
  1063. align-items: center;
  1064. justify-content: space-between;
  1065. width: 100%;
  1066. height: 98rpx;
  1067. padding: 0rpx 38rpx;
  1068. border-top: 1rpx solid #eee;
  1069. .collect {
  1070. visibility: hidden;
  1071. &.show {
  1072. visibility: visible;
  1073. }
  1074. }
  1075. }
  1076. .boxSty {
  1077. padding: 44rpx 41rpx 0rpx;
  1078. }
  1079. .liListSty {
  1080. border:1rpx solid #EEEEEE;
  1081. width: 88rpx;
  1082. height: 88rpx;
  1083. border-radius: 32rpx;
  1084. text-align: center;
  1085. line-height: 88rpx;
  1086. color: #333;
  1087. font-size: 32rpx;
  1088. float: left;
  1089. margin: 20rpx 23rpx;
  1090. &.isRight {
  1091. border:1rpx solid #EEEEEE;
  1092. color:#fff;
  1093. background: green;
  1094. }
  1095. &.isWrong {
  1096. border:1rpx solid #EEEEEE;
  1097. color:#fff;
  1098. background: red;
  1099. }
  1100. }
  1101. .answerInfos {
  1102. padding: 25rpx 25rpx 25rpx 23rpx;
  1103. }
  1104. .answerTitle {
  1105. margin-bottom: 28rpx;
  1106. color: #666;
  1107. font-size: 30rpx;
  1108. }
  1109. .answerContent {
  1110. font-size: 30rpx;
  1111. color: #666;
  1112. }
  1113. .textChild {
  1114. display: inline-block;
  1115. vertical-align: middle;
  1116. }
  1117. .dialog {
  1118. position: fixed;
  1119. left:0;
  1120. top:0;
  1121. width:100%;
  1122. height:100%;
  1123. background-color: rgba(0,0,0,0.8);
  1124. display: flex;
  1125. flex-direction: column;
  1126. align-items: center;
  1127. justify-content: center;
  1128. z-index: 20000;
  1129. .text {
  1130. font-size: 32rpx;
  1131. color: #FFFFFF;
  1132. text-align: center;
  1133. }
  1134. .btn {
  1135. width: 242rpx;
  1136. height: 82rpx;
  1137. border: 2rpx solid #FFFFFF;
  1138. border-radius: 16rpx;
  1139. text-align: center;
  1140. line-height: 82rpx;
  1141. margin:41rpx auto;
  1142. color:#fff;
  1143. font-size: 32rpx;
  1144. }
  1145. }
  1146. </style>