questionBankExplain.vue 34 KB

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