questionBank.vue 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" ref="navbar" :statusBar="true" title="试卷"></uni-nav-bar>
  4. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  5. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  6. <view class="pageContent">
  7. <view class="pad_8 titBox">
  8. <view class="firstLetter">
  9. <view class="leftLetters">
  10. <view class="btnType">
  11. <text v-if="bank.type == 1">单选</text>
  12. <text v-if="bank.type == 2">多选</text>
  13. <text v-if="bank.type == 3">判断</text>
  14. <text v-if="bank.type == 4">案例</text>
  15. <text v-if="bank.type == 5">简答</text>
  16. </view>
  17. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  18. </view>
  19. <view style="color: #666;font-size: 28rpx;">{{ countdown(lastTime) }}</view>
  20. </view>
  21. <view class="titles"><rich-text :nodes="bank.content"></rich-text></view>
  22. </view>
  23. <template v-if="bank.type == 1">
  24. <view class="pad_8 titBox no-margin">
  25. <view v-if="!bank.ques">
  26. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId, bankIndex)">
  27. <view class="activeTI">{{ ast[index] }}</view>
  28. <view class="flex_auto">{{ item.content }}</view>
  29. </view>
  30. </view>
  31. <view v-if="bank.ques">
  32. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  33. <text
  34. :class="{ right: item.optionsId == bank.ques || item.optionsId == bank.ans, wrong: item.optionsId == bank.ques && bank.ques != bank.ans }"
  35. class="activeTI"
  36. >
  37. {{ ast[index] }}
  38. </text>
  39. <view class="flex_auto">{{ item.content }}</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="bank.ques">
  44. <view class="pad_8 answer">
  45. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  46. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  47. </view>
  48. <view class="pad_8 answerInfos">
  49. <view class="answerTitle">答案解析</view>
  50. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  51. </view>
  52. </view>
  53. </template>
  54. <template v-if="bank.type == 2">
  55. <view class="pad_8 titBox no-margin">
  56. <view v-if="!bank.ques">
  57. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId, bankIndex, index)">
  58. <view :class="{ checked: item.checked }" class="activeTI">{{ ast[index] }}</view>
  59. <view class="flex_auto">{{ item.content }}</view>
  60. </view>
  61. </view>
  62. <view v-if="bank.ques">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text
  65. :class="{
  66. right: bank.ques.indexOf(item.optionsId) != -1 || bank.ans.indexOf(item.optionsId) != -1,
  67. wrong: bank.ques.indexOf(item.optionsId) != -1 && bank.ans.indexOf(item.optionsId) == -1
  68. }"
  69. class="activeTI"
  70. >
  71. {{ ast[index] }}
  72. </text>
  73. <view class="flex_auto">{{ item.content }}</view>
  74. </view>
  75. </view>
  76. <view v-if="!bank.ques" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(bank.jsonStr)}" @click="checkboxSubmit(bankIndex)">确认答案</view>
  77. </view>
  78. <view v-if="bank.ques">
  79. <view class="pad_8 answer">
  80. <view>
  81. 正确答案:
  82. <text v-for="(ansItem,ansIndex) in bank.ans" :key="ansIndex">{{ ast[ansItem - 1] }}</text>
  83. </view>
  84. <view>
  85. 我的答案:
  86. <text v-for="(quesItem,quesIndex) in bank.ques" :key="quesIndex">{{ ast[quesItem - 1] }}</text>
  87. </view>
  88. </view>
  89. <view class="pad_8 answerInfos">
  90. <view class="answerTitle">答案解析</view>
  91. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  92. </view>
  93. </view>
  94. </template>
  95. <template v-if="bank.type == 3">
  96. <view class="pad_8 titBox no-margin">
  97. <view v-if="!bank.ques">
  98. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index, bankIndex)">
  99. <view class="activeTI">{{ ast[index] }}</view>
  100. <view class="flex_auto">
  101. {{ item }}
  102. </view>
  103. </view>
  104. </view>
  105. <view v-if="bank.ques">
  106. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  107. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  108. {{ ast[index] }}
  109. </text>
  110. <view class="flex_auto">
  111. {{ item }}
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <view v-if="bank.ques">
  117. <view class="pad_8 answer">
  118. <view>正确答案:{{ ast[bank.ans] }}</view>
  119. <view>我的答案:{{ ast[bank.ques] }}</view>
  120. </view>
  121. <view class="pad_8 answerInfos">
  122. <view class="answerTitle">答案解析</view>
  123. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  124. </view>
  125. </view>
  126. </template>
  127. <!-- 简答题 -->
  128. <template v-if="bank.type == 5">
  129. <view class="pad_8 titBox">
  130. <view class="ans">
  131. <view class="ans_input" v-if="!bank.ques || (!bank.ques.imageList.length && !bank.ques.text)">
  132. <view class="top flex">
  133. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/camera.png" mode=""></image>
  134. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  135. <view class="submit" :class="{disabled:!bank.ansText.text && hasImgs(bank)}" @click="submitAns(bankIndex)">确认答案</view>
  136. </view>
  137. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  138. <view class="imgs">
  139. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList" :key="imgIndex">
  140. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  141. <image :src="$method.splitImgHost(img, true)"></image>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="ans_submit answerInfos" v-if="bank.ques.imageList.length || bank.ques.text">
  146. <view class="answerTitle">我的答案:</view>
  147. {{ bank.ques.text }}
  148. <view class="imgs"><image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques.imageList" :src="$method.splitImgHost(ques, true)"></image></view>
  149. </view>
  150. </view>
  151. </view>
  152. <view v-if="bank.ques.imageList.length || bank.ques.text">
  153. <view class="pad_8 answerInfos">
  154. <view class="answerTitle">答案解析:</view>
  155. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  156. </view>
  157. </view>
  158. </template>
  159. <!-- 案例题 -->
  160. <template v-if="bank.type == 4">
  161. <view class="tabs">
  162. <view
  163. class="tab"
  164. :class="{ current: tabIndex == bank.current }"
  165. :key="tabIndex"
  166. v-for="(tab, tabIndex) in bank.jsonStr"
  167. @click="tabSelect(tabIndex, bankIndex)"
  168. >
  169. 问题{{ tabIndex+1 }}
  170. </view>
  171. </view>
  172. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  173. <template v-if="ansItem.type == 1">
  174. <view class="pad_8 titBox">
  175. <view class="leftLetters">
  176. <view class="btnType">
  177. <text>单选</text>
  178. </view>
  179. </view>
  180. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  181. <view v-if="!bank.ques[ansIndex]">
  182. <view
  183. v-for="(option, childIndex) in ansItem.optionsList"
  184. :key="childIndex"
  185. class="lisSty"
  186. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  187. >
  188. <view class="activeTI">{{ ast[childIndex] }}</view>
  189. <view class="flex_auto">
  190. <rich-text class="textChild" :nodes="option.content"></rich-text>
  191. </view>
  192. </view>
  193. </view>
  194. <view v-if="bank.ques[ansIndex]">
  195. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty">
  196. <text
  197. :class="{
  198. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  199. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  200. }"
  201. class="activeTI"
  202. >
  203. {{ ast[childIndex] }}
  204. </text>
  205. <view class="flex_auto">
  206. <rich-text :nodes="option.content"></rich-text>
  207. </view>
  208. </view>
  209. </view>
  210. </view>
  211. <view v-if="bank.ques[ansIndex]">
  212. <view class="pad_8 answer">
  213. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  214. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  215. </view>
  216. <view class="pad_8 answerInfos">
  217. <view class="answerTitle">答案解析</view>
  218. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  219. </view>
  220. </view>
  221. </template>
  222. <template v-if="ansItem.type == 2">
  223. <view class="pad_8 titBox">
  224. <view class="leftLetters">
  225. <view class="btnType">
  226. <text>多选</text>
  227. </view>
  228. </view>
  229. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  230. <view v-if="!bank.ques[ansIndex]">
  231. <view
  232. v-for="(option, childindex) in ansItem.optionsList"
  233. :key="childindex"
  234. class="lisSty"
  235. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  236. >
  237. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  238. <view class="flex_auto">
  239. <rich-text :nodes="option.content"></rich-text>
  240. </view>
  241. </view>
  242. </view>
  243. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(ansItem.optionsList)}" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  244. <view v-if="bank.ques && bank.ques[ansIndex]">
  245. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  246. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  247. {{ ast[childindex] }}
  248. </text>
  249. <view class="flex_auto">
  250. <rich-text :nodes="option.content"></rich-text>
  251. </view>
  252. </view>
  253. </view>
  254. </view>
  255. <view v-if="bank.ques[ansIndex]">
  256. <view class="pad_8 answer">
  257. <view>
  258. 正确答案:
  259. <text :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  260. </view>
  261. <view>
  262. 我的答案:
  263. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  264. </view>
  265. </view>
  266. <view class="pad_8 answerInfos">
  267. <view class="answerTitle">答案解析</view>
  268. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  269. </view>
  270. </view>
  271. </template>
  272. <template v-if="ansItem.type == 3">
  273. <view class="pad_8 titBox">
  274. <view class="leftLetters">
  275. <view class="btnType">
  276. <text>判断</text>
  277. </view>
  278. </view>
  279. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  280. <view v-if="!bank.ques[ansIndex]">
  281. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  282. <view class="activeTI">{{ ast[childindex] }}</view>
  283. <view class="flex_auto">
  284. {{ option }}
  285. </view>
  286. </view>
  287. </view>
  288. <view v-if="bank.ques[ansIndex]">
  289. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  290. <text
  291. :class="{
  292. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  293. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  294. }"
  295. class="activeTI"
  296. >
  297. {{ ast[childindex] }}
  298. </text>
  299. <view class="flex_auto">
  300. {{ option }}
  301. </view>
  302. </view>
  303. </view>
  304. </view>
  305. <view v-if="bank.ques[ansIndex]">
  306. <view class="pad_8 answer">
  307. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  308. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  309. </view>
  310. <view class="pad_8 answerInfos">
  311. <view class="answerTitle">答案解析</view>
  312. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  313. </view>
  314. </view>
  315. </template>
  316. <!-- 简答题 -->
  317. <template v-if="ansItem.type == 5">
  318. <view class="pad_8 titBox_title">
  319. <view class="leftLetters">
  320. <view class="btnType">
  321. <text>简答</text>
  322. </view>
  323. </view>
  324. <view><rich-text :nodes="ansItem.content"></rich-text></view>
  325. </view>
  326. <view class="pad_8 titBox_title">
  327. <view class="ans">
  328. <view class="ans_input" v-if="!bank.ques[ansIndex] || (!bank.ques[ansIndex].text && !bank.ques[ansIndex].imageList.length)">
  329. <view class="top flex">
  330. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/camera.png" mode=""></image>
  331. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  332. <view class="submit" :class="{disabled:!ansItem.ansText.text && hasImgs(ansItem)}" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  333. </view>
  334. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  335. <view class="imgs">
  336. <view class="img" v-for="(img, imgIndex) in ansItem.ansText.imageList" :key="imgIndex">
  337. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  338. <image :src="$method.splitImgHost(img, true)"></image>
  339. </view>
  340. </view>
  341. </view>
  342. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex] && (bank.ques[ansIndex].imageList.length || bank.ques[ansIndex].text)">
  343. <view class="answerTitle">我的答案</view>
  344. {{ bank.ques[ansIndex].text || ''}}
  345. <view class="imgs">
  346. <image class="img" v-for="(ques,quesIndex) in bank.ques[ansIndex].imageList" :key="quesIndex" :src="$method.splitImgHost(ques, true)"></image>
  347. </view>
  348. </view>
  349. </view>
  350. </view>
  351. <view v-if="bank.ques[ansIndex].imageList.length || bank.ques[ansIndex].text">
  352. <view class="pad_8 answerInfos">
  353. <view class="answerTitle">答案解析</view>
  354. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  355. </view>
  356. </view>
  357. </template>
  358. </view>
  359. </template>
  360. <view class="footer_btn">
  361. <view class="collect" :class="{ show: goodsId && !isFromVideo ? true : false }" @click="collect(collectList[bankIndex], bankIndex)">
  362. <view v-if="collectList[bankIndex]">
  363. <image src="/static/icon/collected.png" mode=""></image>
  364. <view>取消收藏</view>
  365. </view>
  366. <view v-if="!collectList[bankIndex]">
  367. <image src="/static/icon/collect.png" mode=""></image>
  368. <view>收藏</view>
  369. </view>
  370. </view>
  371. <view class="flex_center" @click="openFooterTab">
  372. <view class="up-icon">
  373. <image src="/static/up.png"></image>
  374. </view>
  375. 答题卡
  376. </view>
  377. <view class="collect show" @click="pdsubmit">
  378. <view>
  379. <image src="/static/jj.png" mode=""></image>
  380. <view>交卷</view>
  381. </view>
  382. </view>
  383. </view>
  384. </view>
  385. </swiper-item>
  386. </swiper>
  387. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  388. <view class="popupView">
  389. <view class="popupTops">
  390. <view class="topIcon"></view>
  391. 点击编号即可跳转至对应题目
  392. </view>
  393. <view class="popupContent">
  394. <scroll-view scroll-y="true" style="height: 506rpx;">
  395. <view class="boxSty">
  396. <view
  397. v-for="(item, index) in questionList"
  398. :key="index"
  399. @click="changeIndex(index)"
  400. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  401. class="liListSty"
  402. >
  403. {{ index + 1 }}
  404. </view>
  405. </view>
  406. </scroll-view>
  407. </view>
  408. </view>
  409. </u-popup>
  410. <view class="dialog" v-if="showDialog">
  411. <image class="pointer" src="/static/pointer.png" mode=""></image>
  412. <view class="text">左右滑动切换上下题</view>
  413. <view class="btn" @click="showDialog = false">我知道了</view>
  414. </view>
  415. <view class="dialog-arrow" v-if="showArrow">
  416. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  417. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  418. <view class="btn" @click="showArrow = false">我知道了</view>
  419. </view>
  420. <view class="dialog_wrap" v-if="testOver">
  421. <view class="bg"></view>
  422. <view class="dialog">
  423. <view class="title">温馨提示</view>
  424. <view class="content">
  425. <view>您已完成所有题目,</view>
  426. <view>快去交卷吧!</view>
  427. </view>
  428. <view class="btns">
  429. <view class="btn" @click="noSubmit()">暂不交卷</view>
  430. <view class="btn active" @click="submitNow()">立即交卷</view>
  431. </view>
  432. </view>
  433. </view>
  434. <view class="dialog_wrap" v-if="isLastCount">
  435. <view class="bg"></view>
  436. <view class="dialog">
  437. <view class="title">温馨提示</view>
  438. <view class="content">
  439. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  440. </view>
  441. <view class="btns">
  442. <view class="btn" @click="noLeave()">暂不离开</view>
  443. <view class="btn active" @click="leaveNow()">继续离开</view>
  444. </view>
  445. </view>
  446. </view>
  447. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  448. <view class="popboxs">
  449. <view class="classTops">温馨提示</view>
  450. <view class="textStys">
  451. {{
  452. cgType === 7
  453. ? '您还未交卷,确定结束做题吗?'
  454. : cgType === 8
  455. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  456. : cgType === 6
  457. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  458. : cgType == 9
  459. ? `您已完成所有题目,快去交卷吧!`
  460. : ''
  461. }}
  462. </view>
  463. <view class="classFootsty" v-if="cgType === 6">
  464. <view class="btnsty btns1" @click="submit">立即交卷</view>
  465. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  466. </view>
  467. <view class="classFootsty" v-if="cgType === 7">
  468. <view class="btnsty btns1" @click="backPages">下次继续</view>
  469. <view class="btnsty btns2" @click="submit">结束做题</view>
  470. </view>
  471. <view class="classFootsty" v-if="cgType === 8">
  472. <view class="btnsty btns1" @click="backPages()">下次继续</view>
  473. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  474. </view>
  475. <view class="classFootsty" v-if="cgType === 9">
  476. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  477. <view class="btnsty btns2" @click="submit">立即交卷</view>
  478. </view>
  479. </view>
  480. </u-popup>
  481. </view>
  482. </template>
  483. <script>
  484. export default {
  485. data() {
  486. return {
  487. showpopups: false,
  488. id: '',
  489. current: 0,
  490. questionList: [],
  491. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  492. judge: ['错误', '正确'],
  493. ans: [],
  494. ques: [],
  495. show: false,
  496. showDialog: false,
  497. bankList: [],
  498. collectList: [],
  499. goodsId: '',
  500. recordId: '',
  501. isSubmit: false,
  502. lastTime: 0, //剩余考试时长
  503. allTimes: 0, //总考试时长
  504. timer: null,
  505. wrongList: [],
  506. bankType: 0, //试卷类型
  507. needBack: false, //是否是考试
  508. testOver: false,
  509. isLastCount: false, //是否有未答题目
  510. lastCount: 0, //剩余没有回答的题目数
  511. chapterId: 0,
  512. moduleId: 0,
  513. showArrow:false, //退出提示
  514. isFromVideo:'',
  515. gradeId:'',
  516. cgType: 0 //对应设计稿弹窗编码
  517. };
  518. },
  519. async onLoad(option) {
  520. this.current = +option.current || 0
  521. this.id = option.id;
  522. this.goodsId = option.goodsid;
  523. this.chapterId = option.chapterId || 0;
  524. this.moduleId = option.moduleId || 0;
  525. this.isFromVideo = option.isFromVideo||'';
  526. this.gradeId = option.gradeId || '';
  527. let isBack = option.isback;
  528. let showDialog = uni.getStorageSync('showDialog');
  529. if(showDialog) {
  530. this.showDialog = false;
  531. } else {
  532. this.showDialog = true;
  533. uni.setStorageSync('showDialog','1');
  534. }
  535. //考试被迫返回
  536. if (isBack) {
  537. let app = getApp();
  538. let globalData = app.globalData;
  539. for (var k in globalData.bankData) {
  540. this[k] = globalData.bankData[k];
  541. }
  542. this.showArrow = true;
  543. this.timer = setInterval(() => {
  544. if (this.lastTime <= 0) {
  545. clearInterval(this.timer);
  546. uni.showToast({
  547. icon:'none',
  548. mask:true,
  549. title:'考试时间已到,系统将自动交卷',
  550. duration:10000
  551. })
  552. this.submit();
  553. return;
  554. }
  555. this.lastTime--;
  556. }, 1000);
  557. } else {
  558. //进入页面
  559. await this.bankExam();
  560. this.goodsQuestionList();
  561. }
  562. },
  563. onUnload() {
  564. if (this.isSubmit) {
  565. clearInterval(this.timer)
  566. return;
  567. }
  568. //考试试卷 阻止ios手势返回,自动跳回答题页
  569. if (this.needBack) {
  570. let app = getApp();
  571. app.globalData.bankData = this.$data;
  572. clearInterval(this.timer);
  573. uni.navigateTo({
  574. url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  575. });
  576. } else {
  577. //点击返回按钮确认允许退出,记录答题记录
  578. clearInterval(this.timer)
  579. this.examRecordEdit();
  580. }
  581. },
  582. methods: {
  583. /**
  584. * 是否有上传图片
  585. */
  586. hasImgs(bank) {
  587. return bank.ansText.imageList.length == 0;
  588. },
  589. /**
  590. * 获取试卷类型2考试,1练习
  591. */
  592. bankExam() {
  593. return new Promise(resolve => {
  594. this.$api.bankExam(this.id).then(res => {
  595. this.bankType = res.data.data.doType;
  596. if (this.bankType == 2) {
  597. this.needBack = true;
  598. }
  599. resolve()
  600. });
  601. })
  602. },
  603. /**
  604. * 点击后退按钮
  605. */
  606. clickLeft() {
  607. if (this.bankType == 1) {
  608. let ansCount = this.questionOverNum(true); //已答题数
  609. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  610. //所有题目答完
  611. if (this.lastCount == 0) {
  612. // this.testOver = true;
  613. this.cgType = 7;
  614. //未答完
  615. } else {
  616. this.cgType = 8;
  617. // this.isLastCount = true;
  618. }
  619. this.showpopups = true;
  620. } else if (this.bankType == 2) {
  621. let ansCount = this.questionOverNum(true); //已答题数
  622. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  623. //所有题目答完
  624. if (this.lastCount == 0) {
  625. this.testOver = true;
  626. //未答完
  627. } else {
  628. this.isLastCount = true;
  629. }
  630. }
  631. },
  632. /**
  633. * 返回上一页
  634. */
  635. backPages() {
  636. this.needBack = false;
  637. uni.navigateBack({
  638. delta: 1
  639. });
  640. },
  641. /**
  642. * 获取已经回答的题目数
  643. * hasSpecail (是否包含简答和案例)
  644. */
  645. questionOverNum(hasSpecail) {
  646. let count = 0;
  647. this.questionList.forEach(item => {
  648. if (item.type == 1 || item.type == 2 || item.type == 3) {
  649. if (item.ques) {
  650. count++;
  651. }
  652. } else if (item.type == 4) {
  653. //案例题
  654. if(hasSpecail) {
  655. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  656. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  657. if (item.ques[indexs]) {
  658. return true;
  659. } else {
  660. return false;
  661. }
  662. } else if (jsonItem.type == 5) {
  663. if (item.ques[indexs] && (item.ques[indexs].text || item.ques[indexs].imageList.length)) {
  664. console.log('chil')
  665. return true;
  666. } else {
  667. return false;
  668. }
  669. }
  670. });
  671. if (isOver) {
  672. count++;
  673. console.log(item, 444);
  674. }
  675. }
  676. } else if (item.type == 5) {
  677. //简答题
  678. if(hasSpecail) {
  679. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  680. console.log(5,item)
  681. count++;
  682. }
  683. }
  684. }
  685. });
  686. return count;
  687. },
  688. /**
  689. * 是否做完所有题目
  690. */
  691. isDoOver() {
  692. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  693. if(this.questionList.length == questionOverNum) { //全部做完弹窗
  694. this.cgType = 9;
  695. this.showpopups = true;
  696. }
  697. },
  698. /**
  699. * 暂不交卷
  700. */
  701. noSubmit() {
  702. //设为允许退出页面
  703. this.needBack = false;
  704. uni.navigateBack({
  705. delta: 1
  706. });
  707. },
  708. /**
  709. * 不离开
  710. */
  711. noLeave() {
  712. this.isLastCount = false;
  713. },
  714. /**
  715. * 立即离开并交卷
  716. */
  717. leaveNow() {
  718. this.needBack = false;
  719. this.isSubmit = true;
  720. uni.navigateBack({
  721. delta: 1
  722. });
  723. let score = 0; //计算总分
  724. let reportStatus = 0;
  725. let number = 0; //做对的题目数量
  726. let doQuestionNum = 0; //做过的题目数量
  727. let allScore = 0; //总分
  728. let passScore = 0;
  729. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  730. let doQuestionIds = []; //做过的题目id
  731. let rightQuestionIds = []; //做对的题目id
  732. this.questionList.forEach((item, index) => {
  733. // passScore = item.passScore
  734. if (item.type == 1) {
  735. //正确
  736. if (item.ques == item.ans) {
  737. item.scoreResult = item.score;
  738. score += item.score;
  739. number++;
  740. rightQuestionIds.push(item.questionId)
  741. } else { //错误
  742. item.scoreResult = 0;
  743. doWrongQuestionIds.push(item.questionId)
  744. }
  745. allScore += item.score;
  746. if (item.ques) {
  747. doQuestionNum++;
  748. doQuestionIds.push(item.questionId)
  749. }
  750. } else if (item.type == 2) {
  751. let isRight =
  752. item.ans &&
  753. item.ans.every((quesItem, quesIndex) => {
  754. if(item.ques) {
  755. return item.ques[quesIndex] == item.ans[quesIndex];
  756. } else {
  757. return false;
  758. }
  759. });
  760. if (isRight) {
  761. score += item.score;
  762. number++;
  763. item.scoreResult = item.score;
  764. rightQuestionIds.push(item.questionId)
  765. } else {
  766. let checkboxScore = item.score; //获取单题总分数
  767. item.ques && item.ques.forEach((ques,quesIndex) => {
  768. //选错一个全扣
  769. if(item.ques) {
  770. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  771. checkboxScore = 0;
  772. }
  773. } else {
  774. checkboxScore = 0;
  775. }
  776. })
  777. console.log(checkboxScore)
  778. //没选错
  779. if(checkboxScore) {
  780. item.ans.forEach((ans,quesIndex) => {
  781. //漏选只能得部分分数
  782. if(item.ques) {
  783. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  784. checkboxScore = item.partScore;
  785. }
  786. } else {
  787. checkboxScore = 0;
  788. }
  789. })
  790. }
  791. if(checkboxScore <= 0) { //0分
  792. item.scoreResult = 0;
  793. doWrongQuestionIds.push(item.questionId)
  794. } else { //部分分
  795. number++;
  796. item.scoreResult = checkboxScore;
  797. score += checkboxScore;
  798. rightQuestionIds.push(item.questionId)
  799. }
  800. }
  801. allScore += item.score;
  802. if (item.ques && item.ques.length) {
  803. doQuestionNum++;
  804. doQuestionIds.push(item.questionId)
  805. }
  806. } else if (item.type == 3) {
  807. if (item.ques == item.ans) {
  808. item.scoreResult = item.score;
  809. score += item.score;
  810. number++;
  811. rightQuestionIds.push(item.questionId)
  812. } else {
  813. item.scoreResult = 0;
  814. doWrongQuestionIds.push(item.questionId)
  815. }
  816. allScore += item.score;
  817. if (item.ques) {
  818. doQuestionNum++;
  819. doQuestionIds.push(item.questionId)
  820. }
  821. } else if (item.type == 4) {
  822. allScore += item.score;
  823. if (item.ques && item.ques.length) {
  824. doQuestionNum++;
  825. doQuestionIds.push(item.questionId)
  826. }
  827. } else if (item.type == 5) {
  828. allScore += item.score;
  829. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  830. doQuestionNum++;
  831. doQuestionIds.push(item.questionId)
  832. }
  833. }
  834. });
  835. //大于60分及格
  836. if(score >= 60) {
  837. reportStatus = 1
  838. } else {
  839. reportStatus = 0
  840. }
  841. //交卷
  842. this.$api
  843. .examRecordEdit({
  844. examId: this.id,
  845. goodsId: this.goodsId,
  846. reportStatus:reportStatus,
  847. recordId: this.recordId,
  848. rightQuestionNum: number,
  849. status: 1,
  850. moduleExamId:this.moduleId || 0,
  851. chapterExamId:this.chapterId || 0,
  852. doQuestionIds:doQuestionIds.join(','),
  853. rightQuestionIds:rightQuestionIds.join(','),
  854. doQuestionNum: doQuestionNum,
  855. performance: score,
  856. totalScore: allScore,
  857. examTime: parseInt(this.allTimes),
  858. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  859. historyExamJson: JSON.stringify(this.questionList)
  860. })
  861. .then(res => {
  862. this.isSubmit = true;
  863. if (res.data.code == 200) {
  864. }
  865. });
  866. //错题集id提交(客观题)
  867. this.$api.examWrongRecord({
  868. moduleExamId:this.moduleId || 0,
  869. chapterExamId:this.chapterId || 0,
  870. examId: this.id,
  871. goodsId: this.goodsId,
  872. questionIds: doWrongQuestionIds,
  873. recordId: this.recordId
  874. }).then(res => {
  875. });
  876. },
  877. /**
  878. * 立即交卷
  879. */
  880. submitNow() {
  881. this.showpopups = false;
  882. this.needBack = false;
  883. this.submit();
  884. },
  885. /**
  886. * 离开页面统计回答正确题数
  887. */
  888. examRecordEdit() {
  889. if (!this.isSubmit) {
  890. let number = 0;
  891. let score = 0;
  892. let doQuestionNum = 0;
  893. let doQuestionIds = []; //做过的题目id
  894. this.questionList.forEach((item, index) => {
  895. if (item.type == 1) {
  896. if (item.ques == item.ans) {
  897. score += item.score;
  898. number++;
  899. }
  900. if (item.ques) {
  901. doQuestionNum++;
  902. doQuestionIds.push(item.questionId)
  903. }
  904. } else if (item.type == 2) {
  905. let isRight =
  906. item.ans &&
  907. item.ans.every((quesItem, quesIndex) => {
  908. if(item.ques) {
  909. return item.ques[quesIndex] == item.ans[quesIndex];
  910. } else {
  911. return false;
  912. }
  913. });
  914. if (isRight) {
  915. score += item.score;
  916. number++;
  917. } else {
  918. let checkboxScore = item.score; //获取单题总分数
  919. item.ques && item.ques.forEach((ques,quesIndex) => {
  920. //选错一个全扣
  921. if(item.ques) {
  922. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  923. checkboxScore = 0;
  924. }
  925. } else {
  926. checkboxScore = 0;
  927. }
  928. })
  929. console.log(checkboxScore)
  930. //没选错
  931. if(checkboxScore) {
  932. item.ans.forEach((ans,quesIndex) => {
  933. //漏选扣一部分
  934. if(item.ques) {
  935. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  936. checkboxScore = item.partScore;
  937. }
  938. } else {
  939. checkboxScore = 0;
  940. }
  941. })
  942. }
  943. if(checkboxScore <= 0) { //0分
  944. } else { //部分分
  945. number++;
  946. score += checkboxScore;
  947. }
  948. }
  949. if (item.ques && item.ques.length) {
  950. doQuestionNum++;
  951. doQuestionIds.push(item.questionId)
  952. }
  953. } else if (item.type == 3) {
  954. if (item.ques == item.ans) {
  955. score += item.score;
  956. number++;
  957. }
  958. if (item.ques) {
  959. doQuestionNum++;
  960. doQuestionIds.push(item.questionId)
  961. }
  962. } else if (item == 4) {
  963. if (item.ques.length) {
  964. doQuestionNum++;
  965. doQuestionIds.push(item.questionId)
  966. }
  967. } else if (item.type == 5) {
  968. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  969. doQuestionNum++;
  970. doQuestionIds.push(item.questionId)
  971. }
  972. }
  973. });
  974. this.$api
  975. .examRecordEdit({
  976. examId: this.id,
  977. goodsId: this.goodsId,
  978. recordId: this.recordId,
  979. doQuestionIds:doQuestionIds.join(','),
  980. rightQuestionNum: number,
  981. moduleExamId:this.moduleId || 0,
  982. chapterExamId:this.chapterId || 0,
  983. status: 0,
  984. doQuestionNum: doQuestionNum,
  985. historyExamJson: JSON.stringify(this.questionList)
  986. })
  987. .then(res => {});
  988. }
  989. },
  990. /**
  991. * 记录总题数
  992. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  993. */
  994. examRecord(hasSpecial) {
  995. let questionList = 0;
  996. if(!hasSpecial) {
  997. this.questionList.forEach((item, index) => {
  998. if(item.type == 1 || item.type == 2 || item.type == 3) {
  999. questionList++;
  1000. }
  1001. })
  1002. } else {
  1003. questionList = this.questionList.length;
  1004. }
  1005. this.$api
  1006. .examRecord({
  1007. chapterExamId: this.chapterId || 0,
  1008. moduleExamId: this.moduleId || 0,
  1009. examId: this.id,
  1010. goodsId: this.goodsId,
  1011. totalQuestionNum: questionList
  1012. })
  1013. .then(res => {
  1014. this.recordId = res.data.data;
  1015. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1016. if(this.bankType == 1) {
  1017. this.examRecordEdit();
  1018. }
  1019. });
  1020. },
  1021. /**
  1022. * @param {Object} second倒计时过滤器
  1023. */
  1024. countdown(second) {
  1025. if (second) {
  1026. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1027. let m = parseInt((second / 60) % 60); // 计算分数
  1028. let s = parseInt(second % 60); // 计算当前秒数
  1029. if (h < 10) h = '0' + h;
  1030. if (m < 10) m = '0' + m;
  1031. if (s < 10) s = '0' + s;
  1032. return h + ':' + m + ':' + s;
  1033. } else {
  1034. return '';
  1035. }
  1036. },
  1037. /**
  1038. * 请求题目列表
  1039. */
  1040. goodsQuestionList() {
  1041. this.$api
  1042. .goodsQuestionList({
  1043. examId: this.id
  1044. })
  1045. .then(res => {
  1046. if (!res.data.data.length) {
  1047. this.hideDialog();
  1048. uni.showModal({
  1049. showCancel: false,
  1050. content: '该试卷暂无题目',
  1051. success: function(k) {
  1052. if (k.confirm) {
  1053. uni.navigateBack();
  1054. }
  1055. }
  1056. });
  1057. return;
  1058. }
  1059. this.allTimes = res.data.data[0].answerTime * 60;
  1060. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1061. //考试时间到了自动交卷
  1062. if (this.lastTime) {
  1063. this.timer = setInterval(() => {
  1064. if (this.lastTime <= 0) {
  1065. clearInterval(this.timer);
  1066. uni.showToast({
  1067. icon:'none',
  1068. mask:true,
  1069. title:'考试时间已到,系统将自动交卷',
  1070. duration:10000
  1071. })
  1072. this.submit();
  1073. return;
  1074. }
  1075. this.lastTime--;
  1076. }, 1000);
  1077. } else {
  1078. }
  1079. res.data.data.forEach((item, index) => {
  1080. if (typeof item.jsonStr == 'string') {
  1081. item.jsonStr = JSON.parse(item.jsonStr);
  1082. if (item.type == 2) {
  1083. //多选
  1084. item.jsonStr.forEach(str => {
  1085. str.optionsId = '' + str.optionsId;
  1086. });
  1087. let arr = item.answerQuestion.split(',');
  1088. arr.forEach((a, i) => {
  1089. arr[i] = '' + a;
  1090. });
  1091. item.ans = arr;
  1092. return;
  1093. } else if (item.type == 5) {
  1094. //简答题
  1095. item.ansText = {
  1096. text: '',
  1097. imageList: []
  1098. };
  1099. item.ques = {
  1100. text: '',
  1101. imageList: []
  1102. }
  1103. } else if (item.type == 4) {
  1104. //案例题
  1105. console.log(item.jsonStr);
  1106. item.ques = [];
  1107. item.current = 0;
  1108. let ansArr = [];
  1109. item.jsonStr.forEach((json, index) => {
  1110. if (json.type == 1) {
  1111. ansArr[index] = json.answerQuestion;
  1112. } else if (json.type == 2) {
  1113. json.optionsList.forEach(str => {
  1114. str.optionsId = '' + str.optionsId;
  1115. });
  1116. let arr = json.answerQuestion.split(',');
  1117. arr.forEach((a, i) => {
  1118. arr[i] = '' + a;
  1119. });
  1120. ansArr[index] = arr;
  1121. } else if (json.type == 3) {
  1122. ansArr[index] = json.answerQuestion;
  1123. } else if (json.type == 5) {
  1124. ansArr[index] = {
  1125. text: json.answerQuestion,
  1126. imageList: []
  1127. };
  1128. json.ansText = {
  1129. text: '',
  1130. imageList: []
  1131. };
  1132. }
  1133. });
  1134. item.ans = ansArr;
  1135. return;
  1136. }
  1137. item.ans = item.answerQuestion;
  1138. }
  1139. });
  1140. this.questionList = res.data.data;
  1141. console.log(this.questionList)
  1142. this.lastCount = this.questionList.length;
  1143. this.examRecord();
  1144. this.getCollectInfo(this.current);
  1145. });
  1146. },
  1147. /**
  1148. * @param {Object} e单选点击
  1149. */
  1150. radioSelect(optionsId, bindex) {
  1151. if (this.questionList[bindex].ques) return;
  1152. this.$set(this.questionList[bindex], 'ques', optionsId);
  1153. this.isDoOver();
  1154. // 回答错误
  1155. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1156. this.$api
  1157. .examWrongRecord({
  1158. examId: this.id,
  1159. goodsId: this.goodsId,
  1160. moduleExamId:this.moduleId || 0,
  1161. chapterExamId:this.chapterId || 0,
  1162. questionIds: [this.questionList[bindex].questionId],
  1163. recordId: this.recordId
  1164. })
  1165. .then(res => {});
  1166. } else {
  1167. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1168. // if(question) {
  1169. // this.$api.wrongRecordDelete({
  1170. // "examId": +this.id,
  1171. // "goodsId": +this.goodsId,
  1172. // "questionId": this.questionList[bindex].questionId,
  1173. // }).then(res => {
  1174. // })
  1175. // }
  1176. }
  1177. },
  1178. /**
  1179. * @param {Object} e案例单选点击
  1180. */
  1181. radioSelectChild(optionsId, ansIndex, bindex) {
  1182. if (this.questionList[bindex].ques[ansIndex]) return;
  1183. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1184. this.isDoOver();
  1185. },
  1186. /**
  1187. * @param {Object} 多选点击
  1188. */
  1189. checkboxSelect(optionsId, bindex, index) {
  1190. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  1191. },
  1192. /**
  1193. * @param {Object} 案例多选点击
  1194. */
  1195. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1196. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  1197. },
  1198. isCheckboxChecked(arr) {
  1199. return arr.some(item => {
  1200. if (item.checked) {
  1201. return true;
  1202. }
  1203. });
  1204. },
  1205. /**
  1206. * @param {Object} 多选确认
  1207. */
  1208. checkboxSubmit(bindex) {
  1209. if (this.questionList[bindex].ques) return;
  1210. let arr = [];
  1211. this.questionList[bindex].jsonStr.forEach(item => {
  1212. if (item.checked) {
  1213. arr.push(item.optionsId);
  1214. }
  1215. });
  1216. if(!arr.length) {
  1217. uni.showToast({
  1218. title:'请选择答案',
  1219. icon:'none'
  1220. })
  1221. return;
  1222. }
  1223. this.$set(this.questionList[bindex], 'ques', arr);
  1224. this.isDoOver();
  1225. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  1226. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1227. });
  1228. // 回答错误
  1229. if (isWrong) {
  1230. this.$api
  1231. .examWrongRecord({
  1232. examId: this.id,
  1233. goodsId: this.goodsId,
  1234. moduleExamId:this.moduleId || 0,
  1235. chapterExamId:this.chapterId || 0,
  1236. questionIds: [this.questionList[bindex].questionId],
  1237. recordId: this.recordId
  1238. })
  1239. .then(res => {});
  1240. } else {
  1241. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1242. // if(question) {
  1243. // this.$api.wrongRecordDelete({
  1244. // "examId": +this.id,
  1245. // "goodsId": +this.goodsId,
  1246. // "questionId": this.questionList[bindex].questionId,
  1247. // }).then(res => {
  1248. // })
  1249. // }
  1250. }
  1251. },
  1252. /**
  1253. * @param {Object} 案例多选确认
  1254. */
  1255. checkboxSubmitChild(bindex, ansIndex) {
  1256. if (this.questionList[bindex].ques[ansIndex]) return;
  1257. let arr = [];
  1258. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1259. if (item.checked) {
  1260. arr.push(item.optionsId);
  1261. }
  1262. });
  1263. if(!arr.length) {
  1264. uni.showToast({
  1265. title:'请选择答案',
  1266. icon:'none'
  1267. })
  1268. return;
  1269. }
  1270. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1271. this.isDoOver();
  1272. },
  1273. /**
  1274. * @param {Object} index
  1275. * @param {Object} bindex
  1276. * 判断题
  1277. */
  1278. judgeSelect(index, bindex) {
  1279. if (this.questionList[bindex].ques) return;
  1280. this.$set(this.questionList[bindex], 'ques', index + '');
  1281. this.isDoOver();
  1282. // 回答错误
  1283. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1284. this.$api
  1285. .examWrongRecord({
  1286. examId: this.id,
  1287. goodsId: this.goodsId,
  1288. moduleExamId:this.moduleId || 0,
  1289. chapterExamId:this.chapterId || 0,
  1290. questionIds:[this.questionList[bindex].questionId],
  1291. recordId: this.recordId
  1292. })
  1293. .then(res => {});
  1294. } else {
  1295. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1296. // if(question) {
  1297. // this.$api.wrongRecordDelete({
  1298. // "examId": +this.id,
  1299. // "goodsId": +this.goodsId,
  1300. // "questionId": this.questionList[bindex].questionId,
  1301. // }).then(res => {
  1302. // })
  1303. // }
  1304. }
  1305. },
  1306. /**
  1307. * @param {Object} ansindex
  1308. * @param {Object} childindex
  1309. * @param {Object} bindex
  1310. * 案例判断题
  1311. */
  1312. judgeSelectChild(ansindex, childindex, bindex) {
  1313. if (this.questionList[bindex].ques[ansindex]) return;
  1314. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1315. this.isDoOver();
  1316. },
  1317. openFooterTab() {
  1318. this.show = true;
  1319. },
  1320. changeIndex(index) {
  1321. this.current = index;
  1322. },
  1323. swiperChange(e) {
  1324. this.current = e.detail.current;
  1325. this.getCollectInfo(this.current);
  1326. },
  1327. /**
  1328. * @param {Object} current
  1329. * 获取收藏信息
  1330. */
  1331. getCollectInfo(current) {
  1332. this.$api
  1333. .getCollectInfo({
  1334. examId: this.id,
  1335. questionId: this.questionList[current].questionId,
  1336. goodsId: this.goodsId
  1337. })
  1338. .then(res => {
  1339. if (res.data.code == 500) {
  1340. this.$set(this.collectList, current, false);
  1341. } else if (res.data.code == 200) {
  1342. this.$set(this.collectList, current, res.data.data);
  1343. }
  1344. });
  1345. },
  1346. pdsubmit() {
  1347. // if (this.bankType == 1) {
  1348. let ansCount = this.questionOverNum(true); //已答题数
  1349. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1350. //没有答完
  1351. if (this.lastCount !== 0) {
  1352. this.cgType = 6;
  1353. this.showpopups = true;
  1354. return;
  1355. }
  1356. // }
  1357. if(this.bankType == 2) {
  1358. if(this.lastTime > 0) {
  1359. let lastTime = this.countdown(this.lastTime)
  1360. uni.showModal({
  1361. title:'提示',
  1362. content:`时间还剩余${lastTime},确定交卷吗?`,
  1363. confirmText:'交卷',
  1364. cancelText:'继续答题',
  1365. success:(res) => {
  1366. if(res.confirm) { //确定
  1367. this.submit();
  1368. } else { //取消
  1369. }
  1370. }
  1371. })
  1372. return;
  1373. }
  1374. }
  1375. this.submit();
  1376. },
  1377. /**
  1378. * 交卷
  1379. */
  1380. submit() {
  1381. let score = 0; //计算总分
  1382. let reportStatus = 0;
  1383. let number = 0; //做对的题目数量
  1384. let doQuestionNum = 0; //做过的题目数量
  1385. let allScore = 0; //总分
  1386. let passScore = 0;
  1387. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1388. let doQuestionIds = []; //做过的题目id
  1389. let rightQuestionIds = []; //做对的题目id
  1390. this.questionList.forEach((item, index) => {
  1391. passScore = item.passScore
  1392. if (item.type == 1) {
  1393. //正确
  1394. if (item.ques == item.ans) {
  1395. item.scoreResult = item.score;
  1396. score += item.score;
  1397. number++;
  1398. rightQuestionIds.push(item.questionId)
  1399. } else { //错误
  1400. item.scoreResult = 0;
  1401. doWrongQuestionIds.push(item.questionId)
  1402. }
  1403. allScore += item.score;
  1404. if (item.ques) {
  1405. doQuestionNum++;
  1406. doQuestionIds.push(item.questionId)
  1407. }
  1408. } else if (item.type == 2) {
  1409. let isRight =
  1410. item.ans &&
  1411. item.ans.every((quesItem, quesIndex) => {
  1412. if(item.ques) {
  1413. return item.ques[quesIndex] == item.ans[quesIndex];
  1414. } else {
  1415. return false;
  1416. }
  1417. });
  1418. if (isRight) {
  1419. score += item.score;
  1420. number++;
  1421. item.scoreResult = item.score;
  1422. rightQuestionIds.push(item.questionId)
  1423. } else {
  1424. let checkboxScore = item.score; //获取单题总分数
  1425. item.ques && item.ques.forEach((ques,quesIndex) => {
  1426. //选错一个全扣
  1427. if(item.ques) {
  1428. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1429. checkboxScore = 0;
  1430. }
  1431. } else {
  1432. checkboxScore = 0;
  1433. }
  1434. })
  1435. console.log(checkboxScore)
  1436. //没选错
  1437. if(checkboxScore) {
  1438. item.ans.forEach((ans,quesIndex) => {
  1439. //漏选扣一部分
  1440. if(item.ques) {
  1441. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1442. checkboxScore = item.partScore;
  1443. }
  1444. } else {
  1445. checkboxScore = 0;
  1446. }
  1447. })
  1448. }
  1449. if(checkboxScore <= 0) { //0分
  1450. item.scoreResult = 0;
  1451. doWrongQuestionIds.push(item.questionId)
  1452. } else { //部分分
  1453. number++;
  1454. item.scoreResult = checkboxScore;
  1455. score += checkboxScore;
  1456. rightQuestionIds.push(item.questionId)
  1457. }
  1458. }
  1459. allScore += item.score;
  1460. if (item.ques && item.ques.length) {
  1461. doQuestionNum++;
  1462. doQuestionIds.push(item.questionId)
  1463. }
  1464. } else if (item.type == 3) {
  1465. if (item.ques == item.ans) {
  1466. item.scoreResult = item.score;
  1467. score += item.score;
  1468. number++;
  1469. rightQuestionIds.push(item.questionId)
  1470. } else {
  1471. item.scoreResult = 0;
  1472. doWrongQuestionIds.push(item.questionId)
  1473. }
  1474. allScore += item.score;
  1475. if (item.ques) {
  1476. doQuestionNum++;
  1477. doQuestionIds.push(item.questionId)
  1478. }
  1479. } else if (item.type == 4) {
  1480. allScore += item.score;
  1481. if (item.ques && item.ques.length) {
  1482. doQuestionNum++;
  1483. doQuestionIds.push(item.questionId)
  1484. }
  1485. } else if (item.type == 5) {
  1486. allScore += item.score;
  1487. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1488. doQuestionNum++;
  1489. doQuestionIds.push(item.questionId)
  1490. }
  1491. }
  1492. });
  1493. //大于及格
  1494. if(score >= passScore) {
  1495. reportStatus = 1
  1496. } else {
  1497. reportStatus = 0
  1498. }
  1499. //交卷
  1500. this.$api
  1501. .examRecordEdit({
  1502. examId: this.id,
  1503. goodsId: this.goodsId,
  1504. reportStatus:reportStatus,
  1505. recordId: this.recordId,
  1506. rightQuestionNum: number,
  1507. status: 1,
  1508. moduleExamId:this.moduleId || 0,
  1509. chapterExamId:this.chapterId || 0,
  1510. doQuestionIds:doQuestionIds.join(','),
  1511. rightQuestionIds:rightQuestionIds.join(','),
  1512. doQuestionNum: doQuestionNum,
  1513. performance: score,
  1514. totalScore: allScore,
  1515. examTime: parseInt(this.allTimes),
  1516. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1517. historyExamJson: JSON.stringify(this.questionList)
  1518. })
  1519. .then(res => {
  1520. this.isSubmit = true;
  1521. if (res.data.code == 200) {
  1522. uni.showToast({
  1523. title: '交卷成功',
  1524. duration: 1000,
  1525. icon: 'none'
  1526. });
  1527. setTimeout(() => {
  1528. uni.redirectTo({
  1529. url: '/pages2/bank/question_report?goodsId='+this.goodsId+'&chapterId='+this.chapterId+'&moduleId='+this.moduleId+'&examId='+this.id+'&id=' + this.recordId
  1530. });
  1531. }, 1000);
  1532. }
  1533. });
  1534. //错题集id提交(客观题)
  1535. this.$api.examWrongRecord({
  1536. examId: this.id,
  1537. goodsId: this.goodsId,
  1538. questionIds: doWrongQuestionIds,
  1539. recordId: this.recordId
  1540. }).then(res => {
  1541. });
  1542. },
  1543. /**
  1544. * @param {Object} state
  1545. * @param {Object} index
  1546. * 收藏
  1547. */
  1548. collect(state, index) {
  1549. if (!state) {
  1550. this.$api
  1551. .collectQuestion({
  1552. examId: this.id,
  1553. questionId: this.questionList[index].questionId,
  1554. goodsId: this.goodsId || ''
  1555. })
  1556. .then(res => {
  1557. if (res.data.code == 200) {
  1558. this.$set(this.collectList, index, true);
  1559. uni.showToast({
  1560. title: '收藏成功',
  1561. duration: 2000,
  1562. icon: 'none'
  1563. });
  1564. this.getCollectInfo(index)
  1565. }
  1566. });
  1567. } else {
  1568. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  1569. if (res.data.code == 200) {
  1570. this.$set(this.collectList, index, false);
  1571. uni.showToast({
  1572. title: '取消收藏成功',
  1573. duration: 2000,
  1574. icon: 'none'
  1575. });
  1576. }
  1577. });
  1578. }
  1579. return;
  1580. },
  1581. /**
  1582. * @param {Object} imgIndex
  1583. * @param {Object} bankIndex
  1584. * 删除简答图片
  1585. */
  1586. deleteImg(imgIndex, bankIndex) {
  1587. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1588. },
  1589. /**
  1590. * @param {Object} imgIndex
  1591. * @param {Object} bankIndex
  1592. * @param {Object} ansIndex
  1593. * 删除案例题简答图片
  1594. */
  1595. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1596. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1597. },
  1598. /**
  1599. * @param {Object} bankindex
  1600. * 选择上传图片
  1601. */
  1602. chooseImg(bankindex) {
  1603. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1604. uni.showToast({
  1605. icon:'none',
  1606. title:'最多选择4张'
  1607. })
  1608. return;
  1609. }
  1610. uni.chooseImage({
  1611. count: 1, //默认9
  1612. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1613. sourceType: ['album', 'camera'], //从相册选择
  1614. success: res => {
  1615. let self = this;
  1616. // console.log(JSON.stringify(res.tempFilePaths));
  1617. let img = res.tempFilePaths[0];
  1618. uni.getImageInfo({
  1619. src: img,
  1620. success: async res => {
  1621. let canvasWidth = res.width; //图片原始长宽
  1622. let canvasHeight = res.height;
  1623. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1624. uni.compressImage({
  1625. src: img,
  1626. quality: 75,
  1627. width: '50%',
  1628. height: '50%',
  1629. success: async rest => {
  1630. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1631. this.questionList[bankindex].ansText.imageList.push(dir);
  1632. }
  1633. });
  1634. } else {
  1635. const dir = await self.uploadFile(img, 0);
  1636. this.questionList[bankindex].ansText.imageList.push(dir);
  1637. }
  1638. }
  1639. });
  1640. }
  1641. });
  1642. },
  1643. /**
  1644. * @param {Object} bankindex
  1645. * @param {Object} ansindex
  1646. * 案例题选择上传图片
  1647. */
  1648. chooseImgChild(bankindex, ansindex) {
  1649. if(this.questionList[bankindex].jsonStr[ansindex] && this.questionList[bankindex].jsonStr[ansindex].ansText && this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length >= 4) {
  1650. uni.showToast({
  1651. icon:'none',
  1652. title:'最多选择4张'
  1653. })
  1654. return;
  1655. }
  1656. uni.chooseImage({
  1657. count: 1, //默认9
  1658. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1659. sourceType: ['album', 'camera'], //从相册选择
  1660. success: res => {
  1661. let self = this;
  1662. // console.log(JSON.stringify(res.tempFilePaths));
  1663. let img = res.tempFilePaths[0];
  1664. uni.getImageInfo({
  1665. src: img,
  1666. success: async res => {
  1667. let canvasWidth = res.width; //图片原始长宽
  1668. let canvasHeight = res.height;
  1669. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1670. uni.compressImage({
  1671. src: img,
  1672. quality: 75,
  1673. width: '50%',
  1674. height: '50%',
  1675. success: async rest => {
  1676. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1677. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1678. }
  1679. });
  1680. } else {
  1681. const dir = await self.uploadFile(img, 0);
  1682. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1683. }
  1684. }
  1685. });
  1686. }
  1687. });
  1688. },
  1689. uploadFile(options, int) {
  1690. var self = this;
  1691. return new Promise((resolve, reject) => {
  1692. var data = {
  1693. imageStatus: int
  1694. };
  1695. self.$api.aliyunpolicy(data).then(res => {
  1696. console.log(res.data, 6);
  1697. if (res.data.code != 200) {
  1698. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1699. return;
  1700. }
  1701. var ossToken = res.data.data.resultContent;
  1702. if (ossToken.host == null || ossToken.host == undefined) {
  1703. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1704. return;
  1705. }
  1706. uni.uploadFile({
  1707. url: ossToken.host,
  1708. name: 'file',
  1709. filePath: options,
  1710. fileType: 'image',
  1711. header: {
  1712. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1713. },
  1714. formData: {
  1715. key: ossToken.dir,
  1716. OSSAccessKeyId: ossToken.accessid,
  1717. policy: ossToken.policy,
  1718. Signature: ossToken.signature,
  1719. callback: ossToken.callback,
  1720. success_action_status: 200
  1721. },
  1722. success: result => {
  1723. if (result.statusCode === 200) {
  1724. resolve(ossToken.dir);
  1725. } else {
  1726. uni.showToast({
  1727. title: '上传失败',
  1728. icon: 'none'
  1729. });
  1730. return;
  1731. }
  1732. },
  1733. fail: error => {
  1734. uni.showToast({
  1735. title: '上传接口报错' + error,
  1736. icon: 'none'
  1737. });
  1738. return;
  1739. }
  1740. });
  1741. });
  1742. });
  1743. },
  1744. /**
  1745. * @param {Object} type
  1746. * @param {Object} bankindex
  1747. * 简答题答案确认
  1748. */
  1749. submitAns(bankindex) {
  1750. console.log(this.questionList[bankindex]);
  1751. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1752. uni.showToast({
  1753. title: '请输入内容或上传图片',
  1754. duration: 2000,
  1755. icon: 'none'
  1756. });
  1757. return;
  1758. }
  1759. this.$set(this.questionList[bankindex], 'ques', {
  1760. imageList: this.questionList[bankindex].ansText.imageList || [],
  1761. text: this.questionList[bankindex].ansText.text || ''
  1762. });
  1763. this.isDoOver()
  1764. },
  1765. /**
  1766. * @param {Object} bankindex
  1767. * @param {Object} ansindex
  1768. * 案例题简答答案确认
  1769. */
  1770. submitAnsChild(bankindex, ansindex) {
  1771. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1772. uni.showToast({
  1773. title: '请输入内容或上传图片',
  1774. duration: 2000,
  1775. icon: 'none'
  1776. });
  1777. return;
  1778. }
  1779. this.$set(this.questionList[bankindex].ques, ansindex, {
  1780. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList || [],
  1781. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || ''
  1782. });
  1783. this.isDoOver()
  1784. },
  1785. isRight(item, index) {
  1786. //单选
  1787. if (this.questionList[index].ques) {
  1788. if (item.type == 1) {
  1789. return this.questionList[index].ques == this.questionList[index].ans;
  1790. //多选
  1791. } else if (item.type == 2) {
  1792. //每一项都相等
  1793. return this.questionList[index].ques.every((item, i) => {
  1794. return item == this.questionList[index].ans[i];
  1795. });
  1796. //判断
  1797. } else if (item.type == 3) {
  1798. return this.questionList[index].ques == this.questionList[index].ans;
  1799. // } else if (item.type == 5) {
  1800. // if(this.questionList[index].ques.text){
  1801. // return true
  1802. // }else{
  1803. // return false
  1804. // }
  1805. } else {
  1806. return false;
  1807. }
  1808. } else {
  1809. return false;
  1810. }
  1811. },
  1812. right(bankIndex, ansIndex, option) {
  1813. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1814. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1815. return true;
  1816. } else {
  1817. return false;
  1818. }
  1819. } else {
  1820. return false;
  1821. }
  1822. },
  1823. wrong(bankIndex, ansIndex, option) {
  1824. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1825. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1826. return true;
  1827. } else {
  1828. return false;
  1829. }
  1830. } else {
  1831. return false;
  1832. }
  1833. },
  1834. isWrong(item, index) {
  1835. if (this.questionList[index].ques) {
  1836. //单选
  1837. if (item.type == 1) {
  1838. return this.questionList[index].ques != this.questionList[index].ans;
  1839. //多选
  1840. } else if (item.type == 2) {
  1841. //每一项都相等
  1842. return this.questionList[index].ques.some((item, index) => {
  1843. return item != this.questionList[index].ans;
  1844. });
  1845. //判断
  1846. } else if (item.type == 3) {
  1847. return this.questionList[index].ques != this.questionList[index].ans;
  1848. } else {
  1849. return false;
  1850. }
  1851. } else {
  1852. return false;
  1853. }
  1854. },
  1855. tabSelect(index, bankindex) {
  1856. this.$set(this.questionList[bankindex], 'current', index);
  1857. }
  1858. }
  1859. };
  1860. </script>
  1861. <style lang="scss" scoped>
  1862. .questionBank {
  1863. width:100%;
  1864. height:100vh;
  1865. display: flex;
  1866. flex-direction: column;
  1867. }
  1868. .swiper {
  1869. width: 100%;
  1870. flex:1;
  1871. }
  1872. .lisSty {
  1873. margin-bottom: 16rpx;
  1874. display: flex;
  1875. align-items: center;
  1876. .flex_auto {
  1877. flex: 1;
  1878. }
  1879. }
  1880. .activeTI {
  1881. vertical-align: middle;
  1882. display: inline-block;
  1883. border: 1rpx solid #eee;
  1884. border-radius: 50rpx;
  1885. height: 48rpx;
  1886. line-height: 46rpx;
  1887. text-align: center;
  1888. width: 48rpx;
  1889. margin-right: 15rpx;
  1890. color: #666;
  1891. font-size: 30rpx;
  1892. &.right {
  1893. color: #fff;
  1894. background: #36C75A;
  1895. }
  1896. &.wrong {
  1897. color: #fff;
  1898. background: #FF3B30;
  1899. }
  1900. &.checked {
  1901. color: #fff;
  1902. background: #007AFF;
  1903. }
  1904. }
  1905. .submit_checkbox {
  1906. position:fixed;
  1907. left:0;
  1908. right:0;
  1909. bottom:120rpx;
  1910. margin: 20rpx auto;
  1911. width: 526rpx;
  1912. height: 80rpx;
  1913. background: rgba(0, 122, 255, 1);
  1914. color: #fff;
  1915. text-align: center;
  1916. line-height: 80rpx;
  1917. font-size: 30rpx;
  1918. border-radius: 40rpx;
  1919. &.disabled {
  1920. opacity: 0.6;
  1921. }
  1922. }
  1923. .titles {
  1924. overflow: hidden;
  1925. margin-bottom: 24rpx;
  1926. }
  1927. .titBox {
  1928. padding: 41rpx 25rpx 24rpx 25rpx;
  1929. }
  1930. .titBox_title {
  1931. padding: 21rpx;
  1932. }
  1933. .tabs {
  1934. margin: 10rpx;
  1935. display: flex;
  1936. .tab {
  1937. margin: 0 4rpx;
  1938. padding:10rpx 13rpx;
  1939. text-align: center;
  1940. color: #007aff;
  1941. font-size: 28rpx;
  1942. border-radius: 16rpx;
  1943. background:#fff;
  1944. &.current {
  1945. color: #fff;
  1946. background: #007aff;
  1947. }
  1948. }
  1949. }
  1950. .ans {
  1951. margin: 8rpx 8rpx 8rpx;
  1952. .ans_input {
  1953. border-radius: 16rpx;
  1954. background: #fff;
  1955. .top {
  1956. border-bottom: 1rpx solid #eeeeee;
  1957. padding: 16rpx;
  1958. display: flex;
  1959. align-items: center;
  1960. .icon {
  1961. margin-right: 20rpx;
  1962. width: 40rpx;
  1963. height: 38rpx;
  1964. }
  1965. .progress {
  1966. flex: 1;
  1967. }
  1968. .submit {
  1969. width: 168rpx;
  1970. height: 48rpx;
  1971. line-height: 48rpx;
  1972. text-align: center;
  1973. color: #fff;
  1974. font-size: 30rpx;
  1975. background: #007aff;
  1976. border-radius: 24rpx;
  1977. &.disabled {
  1978. opacity: 0.6;
  1979. }
  1980. }
  1981. }
  1982. .textarea {
  1983. textarea {
  1984. width: 100%;
  1985. height: 287rpx;
  1986. padding: 10rpx;
  1987. }
  1988. }
  1989. .imgs {
  1990. overflow: hidden;
  1991. display: flex;
  1992. width: 100%;
  1993. .img {
  1994. width: 104rpx;
  1995. height: 104rpx;
  1996. border-radius: 8rpx;
  1997. position: relative;
  1998. margin: 20rpx;
  1999. text {
  2000. position: absolute;
  2001. right: -15rpx;
  2002. top: -15rpx;
  2003. width: 30rpx;
  2004. height: 30rpx;
  2005. text-align: center;
  2006. line-height: 30rpx;
  2007. color: #fff;
  2008. background: #FF3B30;
  2009. border-radius: 50%;
  2010. }
  2011. image {
  2012. width: 100%;
  2013. height: 100%;
  2014. }
  2015. }
  2016. }
  2017. }
  2018. .ans_submit {
  2019. padding: 16rpx;
  2020. border-radius: 16rpx;
  2021. background: #fff;
  2022. .imgs {
  2023. overflow: hidden;
  2024. display: flex;
  2025. width: 100%;
  2026. .img {
  2027. width: 104rpx;
  2028. height: 104rpx;
  2029. border-radius: 8rpx;
  2030. position: relative;
  2031. margin: 20rpx;
  2032. image {
  2033. width: 100%;
  2034. height: 100%;
  2035. }
  2036. }
  2037. }
  2038. }
  2039. }
  2040. .leftLetters {
  2041. display: flex;
  2042. align-items: center;
  2043. width: 220rpx;
  2044. .btnType {
  2045. padding: 5rpx 10rpx;
  2046. border: 1rpx solid #007aff;
  2047. border-radius: 10rpx;
  2048. background-color: rgba(0, 122, 255, 0.1);
  2049. font-size: 28rpx;
  2050. color: #007aff;
  2051. margin-right: 15rpx;
  2052. }
  2053. }
  2054. .firstLetter {
  2055. display: flex;
  2056. justify-content: space-between;
  2057. align-items: center;
  2058. margin-bottom: 30rpx;
  2059. }
  2060. .popupView {
  2061. height: 100%;
  2062. padding-bottom: 100rpx;
  2063. .popupTops {
  2064. height: 77rpx;
  2065. border-bottom: 1rpx solid #eee;
  2066. text-align: center;
  2067. line-height: 77rpx;
  2068. font-size: 24rpx;
  2069. color: #999;
  2070. position: relative;
  2071. .topIcon {
  2072. position: absolute;
  2073. top: 10rpx;
  2074. left: 50%;
  2075. transform: translateX(-50%);
  2076. width: 80rpx;
  2077. height: 8rpx;
  2078. background-color: #999;
  2079. border-radius: 4rpx;
  2080. }
  2081. }
  2082. .popupContent {
  2083. }
  2084. }
  2085. .pageContent {
  2086. position: relative;
  2087. background-color: #eaeef1;
  2088. height: 100%;
  2089. padding-top: 8rpx;
  2090. padding-bottom: 100rpx;
  2091. overflow-y: scroll;
  2092. }
  2093. .pad_8 {
  2094. background-color: #fff;
  2095. margin: 0rpx 8rpx 8rpx;
  2096. border-radius: 16rpx;
  2097. &.no-margin {
  2098. margin-top:-16rpx;
  2099. border-radius: 0 0 16rpx 16rpx;
  2100. }
  2101. }
  2102. .answer {
  2103. height: 80rpx;
  2104. line-height: 80rpx;
  2105. padding: 0rpx 24rpx;
  2106. display: flex;
  2107. align-items: center;
  2108. justify-content: space-between;
  2109. color: #666;
  2110. font-size: 30rpx;
  2111. }
  2112. .footer_btn {
  2113. background-color: #fff;
  2114. z-index: 10078;
  2115. position: fixed;
  2116. bottom: 0rpx;
  2117. display: flex;
  2118. align-items: center;
  2119. justify-content: space-between;
  2120. width: 100%;
  2121. height: 98rpx;
  2122. padding: 0rpx 38rpx;
  2123. border-top: 1rpx solid #eee;
  2124. .flex_center {
  2125. flex:1;
  2126. display: flex;
  2127. justify-content: center;
  2128. align-items: center;
  2129. flex-direction: column;
  2130. margin:0 200rpx;
  2131. font-size: 24rpx;
  2132. color: #999999;
  2133. .up-icon {
  2134. margin-bottom:18rpx;
  2135. width:100%;
  2136. display: flex;
  2137. justify-content: center;
  2138. image {
  2139. width:58rpx;
  2140. height:21rpx;
  2141. }
  2142. }
  2143. }
  2144. .collect {
  2145. visibility: hidden;
  2146. width:100rpx;
  2147. &.show {
  2148. visibility: visible;
  2149. }
  2150. >view {
  2151. display: flex;
  2152. flex-direction: column;
  2153. align-items: center;
  2154. justify-content: center;
  2155. image {
  2156. width:32rpx;
  2157. height:32rpx;
  2158. margin-bottom:6rpx;
  2159. }
  2160. view {
  2161. font-size: 24rpx;
  2162. color: #999999;
  2163. }
  2164. }
  2165. }
  2166. }
  2167. .boxSty {
  2168. padding: 44rpx 41rpx 0rpx;
  2169. }
  2170. .liListSty {
  2171. border: 1rpx solid #eeeeee;
  2172. width: 88rpx;
  2173. height: 88rpx;
  2174. border-radius: 32rpx;
  2175. text-align: center;
  2176. line-height: 88rpx;
  2177. color: #333;
  2178. font-size: 32rpx;
  2179. float: left;
  2180. margin: 20rpx 23rpx;
  2181. &.isRight {
  2182. border: 1rpx solid #eeeeee;
  2183. color: #fff;
  2184. background: #36C75A;
  2185. }
  2186. &.isWrong {
  2187. border: 1rpx solid #eeeeee;
  2188. color: #fff;
  2189. background: #FF3B30;
  2190. }
  2191. }
  2192. .answerInfos {
  2193. padding: 25rpx 25rpx 25rpx 23rpx;
  2194. }
  2195. .answerTitle {
  2196. margin-bottom: 28rpx;
  2197. color: #666;
  2198. font-size: 30rpx;
  2199. }
  2200. .answerContent {
  2201. font-size: 30rpx;
  2202. color: #666;
  2203. }
  2204. .textChild {
  2205. display: inline-block;
  2206. vertical-align: middle;
  2207. }
  2208. .dialog {
  2209. position: fixed;
  2210. left: 0;
  2211. top: 0;
  2212. width: 100%;
  2213. height: 100%;
  2214. background-color: rgba(0, 0, 0, 0.8);
  2215. display: flex;
  2216. flex-direction: column;
  2217. align-items: center;
  2218. justify-content: center;
  2219. z-index: 20000;
  2220. .pointer {
  2221. width:338rpx;
  2222. height:240rpx;
  2223. }
  2224. .text {
  2225. font-size: 32rpx;
  2226. color: #ffffff;
  2227. text-align: center;
  2228. }
  2229. .btn {
  2230. width: 242rpx;
  2231. height: 82rpx;
  2232. border: 2rpx solid #ffffff;
  2233. border-radius: 16rpx;
  2234. text-align: center;
  2235. line-height: 82rpx;
  2236. margin: 41rpx auto;
  2237. color: #fff;
  2238. font-size: 32rpx;
  2239. }
  2240. }
  2241. .dialog-arrow {
  2242. padding-top:124rpx;
  2243. position: fixed;
  2244. left: 0;
  2245. top: 0;
  2246. width: 100%;
  2247. height: 100%;
  2248. background-color: rgba(0, 0, 0, 0.8);
  2249. z-index: 20000;
  2250. .pointer {
  2251. margin-left:87rpx;
  2252. display: block;
  2253. width:95rpx;
  2254. height:98rpx;
  2255. }
  2256. .text {
  2257. padding-left:177rpx;
  2258. font-size: 32rpx;
  2259. color: #ffffff;
  2260. }
  2261. .btn {
  2262. width: 242rpx;
  2263. height: 82rpx;
  2264. border: 2rpx solid #ffffff;
  2265. border-radius: 16rpx;
  2266. text-align: center;
  2267. line-height: 82rpx;
  2268. margin: 500rpx auto 0;
  2269. color: #fff;
  2270. font-size: 32rpx;
  2271. }
  2272. }
  2273. .dialog_wrap {
  2274. position: fixed;
  2275. left: 0;
  2276. top: 0;
  2277. width: 100%;
  2278. height: 100%;
  2279. z-index: 9999999999;
  2280. .bg {
  2281. background: rgba(0, 0, 0, 0.3);
  2282. position: absolute;
  2283. left: 0;
  2284. top: 0;
  2285. width: 100%;
  2286. height: 100%;
  2287. }
  2288. .dialog {
  2289. position: absolute;
  2290. left: 50%;
  2291. top: 50%;
  2292. transform: translate3D(-50%, -50%, 0);
  2293. width: 640rpx;
  2294. height: 439rpx;
  2295. background: #ffffff;
  2296. border-radius: 24rpx;
  2297. .title {
  2298. font-size: 30rpx;
  2299. font-weight: bold;
  2300. color: #333333;
  2301. line-height: 48rpx;
  2302. text-align: center;
  2303. margin-top: 40rpx;
  2304. }
  2305. .content {
  2306. margin: 35rpx 35rpx 0;
  2307. font-size: 30rpx;
  2308. color: #666666;
  2309. line-height: 48rpx;
  2310. }
  2311. .btns {
  2312. margin-top: 35rpx;
  2313. display: flex;
  2314. align-items: center;
  2315. justify-content: center;
  2316. .btn {
  2317. width: 200rpx;
  2318. height: 80rpx;
  2319. line-height: 80rpx;
  2320. text-align: center;
  2321. background: #f5f5f5;
  2322. border-radius: 40rpx;
  2323. font-size: 30rpx;
  2324. color: rgba(0, 122, 255, 1);
  2325. background: #f5f5f5;
  2326. margin: 0 20rpx;
  2327. &.active {
  2328. color: #f5f5f5;
  2329. background: rgba(0, 122, 255, 1);
  2330. }
  2331. }
  2332. }
  2333. }
  2334. }
  2335. .popboxs {
  2336. width: 100%;
  2337. height: 100%;
  2338. display: flex;
  2339. flex-direction: column;
  2340. align-items: center;
  2341. }
  2342. .classTops {
  2343. flex-shrink: 0;
  2344. padding: 39rpx 0rpx 4rpx;
  2345. font-weight: bold;
  2346. color: #333;
  2347. font-size: 30rpx;
  2348. }
  2349. .textStys {
  2350. width: 100%;
  2351. flex: 1;
  2352. padding: 36rpx;
  2353. }
  2354. .classFootsty {
  2355. flex-shrink: 0;
  2356. display: flex;
  2357. align-items: center;
  2358. justify-content: center;
  2359. padding: 10rpx 0rpx 40rpx;
  2360. .btnsty {
  2361. width: 200rpx;
  2362. height: 80rpx;
  2363. border-radius: 40rpx;
  2364. font-weight: bold;
  2365. font-size: 30rpx;
  2366. text-align: center;
  2367. line-height: 80rpx;
  2368. }
  2369. .btns1 {
  2370. background-color: #f5f5f5;
  2371. color: #007aff;
  2372. }
  2373. .btns2 {
  2374. margin-left: 40rpx;
  2375. background-color: #007aff;
  2376. color: #ffffff;
  2377. }
  2378. }
  2379. </style>