questionBankExplain.vue 34 KB

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