questionBank.vue 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" ref="navbar" :statusBar="true" :title="examData.examName"></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" @click="showPhoto(bank.content)"><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),isOver:isOver(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. examData:{},
  517. cgType: 0 //对应设计稿弹窗编码
  518. };
  519. },
  520. async onLoad(option) {
  521. this.current = +option.current || 0
  522. this.id = option.id;
  523. this.goodsId = option.goodsid;
  524. this.chapterId = option.chapterId || 0;
  525. this.moduleId = option.moduleId || 0;
  526. this.isFromVideo = option.isFromVideo||'';
  527. this.gradeId = option.gradeId || '';
  528. let isBack = option.isback;
  529. let showDialog = uni.getStorageSync('showDialog');
  530. if(showDialog) {
  531. this.showDialog = false;
  532. } else {
  533. this.showDialog = true;
  534. uni.setStorageSync('showDialog','1');
  535. }
  536. //考试被迫返回
  537. if (isBack) {
  538. let app = getApp();
  539. let globalData = app.globalData;
  540. for (var k in globalData.bankData) {
  541. this[k] = globalData.bankData[k];
  542. }
  543. this.showArrow = true;
  544. this.timer = setInterval(() => {
  545. if (this.lastTime <= 0) {
  546. clearInterval(this.timer);
  547. uni.showToast({
  548. icon:'none',
  549. mask:true,
  550. title:'考试时间已到,系统将自动交卷',
  551. duration:10000
  552. })
  553. this.submit();
  554. return;
  555. }
  556. this.lastTime--;
  557. }, 1000);
  558. } else {
  559. //进入页面
  560. await this.bankExam();
  561. this.goodsQuestionList();
  562. }
  563. },
  564. onUnload() {
  565. if (this.isSubmit) {
  566. clearInterval(this.timer)
  567. return;
  568. }
  569. //考试试卷 阻止ios手势返回,自动跳回答题页
  570. if (this.needBack) {
  571. let app = getApp();
  572. app.globalData.bankData = this.$data;
  573. clearInterval(this.timer);
  574. uni.navigateTo({
  575. url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  576. });
  577. } else {
  578. //点击返回按钮确认允许退出,记录答题记录
  579. clearInterval(this.timer)
  580. this.examRecordEdit();
  581. }
  582. },
  583. methods: {
  584. /**
  585. * 是否有上传图片
  586. */
  587. hasImgs(bank) {
  588. return bank.ansText.imageList.length == 0;
  589. },
  590. /**
  591. * 获取试卷类型2考试,1练习
  592. */
  593. bankExam() {
  594. return new Promise(resolve => {
  595. this.$api.bankExam(this.id).then(res => {
  596. this.bankType = res.data.data.doType;
  597. this.examData = res.data.data;
  598. if (this.bankType == 2) {
  599. this.needBack = true;
  600. }
  601. resolve()
  602. });
  603. })
  604. },
  605. /**
  606. * 点击后退按钮
  607. */
  608. clickLeft() {
  609. if (this.bankType == 1) {
  610. let ansCount = this.questionOverNum(true); //已答题数
  611. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  612. //所有题目答完
  613. if (this.lastCount == 0) {
  614. // this.testOver = true;
  615. this.cgType = 7;
  616. //未答完
  617. } else {
  618. this.cgType = 8;
  619. // this.isLastCount = true;
  620. }
  621. this.showpopups = true;
  622. } else if (this.bankType == 2) {
  623. let ansCount = this.questionOverNum(true); //已答题数
  624. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  625. //所有题目答完
  626. if (this.lastCount == 0) {
  627. this.testOver = true;
  628. //未答完
  629. } else {
  630. this.isLastCount = true;
  631. }
  632. }
  633. },
  634. /**
  635. * 返回上一页
  636. */
  637. backPages() {
  638. this.needBack = false;
  639. uni.navigateBack({
  640. delta: 1
  641. });
  642. },
  643. /**
  644. * 获取已经回答的题目数
  645. * hasSpecail (是否包含简答和案例)
  646. */
  647. questionOverNum(hasSpecail) {
  648. let count = 0;
  649. this.questionList.forEach(item => {
  650. if (item.type == 1 || item.type == 2 || item.type == 3) {
  651. if (item.ques) {
  652. count++;
  653. }
  654. } else if (item.type == 4) {
  655. //案例题
  656. if(hasSpecail) {
  657. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  658. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  659. if (item.ques[indexs]) {
  660. return true;
  661. } else {
  662. return false;
  663. }
  664. } else if (jsonItem.type == 5) {
  665. if (item.ques[indexs] && (item.ques[indexs].text || item.ques[indexs].imageList.length)) {
  666. console.log('chil')
  667. return true;
  668. } else {
  669. return false;
  670. }
  671. }
  672. });
  673. if (isOver) {
  674. count++;
  675. console.log(item, 444);
  676. }
  677. }
  678. } else if (item.type == 5) {
  679. //简答题
  680. if(hasSpecail) {
  681. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  682. console.log(5,item)
  683. count++;
  684. }
  685. }
  686. }
  687. });
  688. return count;
  689. },
  690. /**
  691. * 是否做完所有题目
  692. */
  693. isDoOver() {
  694. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  695. if(this.questionList.length == questionOverNum) { //全部做完弹窗
  696. this.cgType = 9;
  697. this.showpopups = true;
  698. }
  699. },
  700. /**
  701. * 暂不交卷
  702. */
  703. noSubmit() {
  704. //设为允许退出页面
  705. this.needBack = false;
  706. uni.navigateBack({
  707. delta: 1
  708. });
  709. },
  710. /**
  711. * 不离开
  712. */
  713. noLeave() {
  714. this.isLastCount = false;
  715. },
  716. /**
  717. * 立即离开并交卷
  718. */
  719. leaveNow() {
  720. this.needBack = false;
  721. this.isSubmit = true;
  722. uni.navigateBack({
  723. delta: 1
  724. });
  725. let score = 0; //计算总分
  726. let reportStatus = 0;
  727. let number = 0; //做对的题目数量
  728. let doQuestionNum = 0; //做过的题目数量
  729. let allScore = 0; //总分
  730. let passScore = 0;
  731. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  732. let doQuestionIds = []; //做过的题目id
  733. let rightQuestionIds = []; //做对的题目id
  734. this.questionList.forEach((item, index) => {
  735. // passScore = item.passScore
  736. if (item.type == 1) {
  737. //正确
  738. if (item.ques == item.ans) {
  739. item.scoreResult = item.score;
  740. score += item.score;
  741. number++;
  742. rightQuestionIds.push(item.questionId)
  743. } else { //错误
  744. item.scoreResult = 0;
  745. doWrongQuestionIds.push(item.questionId)
  746. }
  747. allScore += item.score;
  748. if (item.ques) {
  749. doQuestionNum++;
  750. doQuestionIds.push(item.questionId)
  751. }
  752. } else if (item.type == 2) {
  753. let isRight =
  754. item.ans &&
  755. item.ans.every((quesItem, quesIndex) => {
  756. if(item.ques) {
  757. return item.ques[quesIndex] == item.ans[quesIndex];
  758. } else {
  759. return false;
  760. }
  761. });
  762. if (isRight) {
  763. score += item.score;
  764. number++;
  765. item.scoreResult = item.score;
  766. rightQuestionIds.push(item.questionId)
  767. } else {
  768. let checkboxScore = item.score; //获取单题总分数
  769. item.ques && item.ques.forEach((ques,quesIndex) => {
  770. //选错一个全扣
  771. if(item.ques) {
  772. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  773. checkboxScore = 0;
  774. }
  775. } else {
  776. checkboxScore = 0;
  777. }
  778. })
  779. console.log(checkboxScore)
  780. //没选错
  781. if(checkboxScore) {
  782. item.ans.forEach((ans,quesIndex) => {
  783. //漏选只能得部分分数
  784. if(item.ques) {
  785. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  786. checkboxScore = item.partScore;
  787. }
  788. } else {
  789. checkboxScore = 0;
  790. }
  791. })
  792. }
  793. if(checkboxScore <= 0) { //0分
  794. item.scoreResult = 0;
  795. doWrongQuestionIds.push(item.questionId)
  796. } else { //部分分
  797. // number++;
  798. doWrongQuestionIds.push(item.questionId)
  799. item.scoreResult = checkboxScore;
  800. score += checkboxScore;
  801. // rightQuestionIds.push(item.questionId)
  802. }
  803. }
  804. allScore += item.score;
  805. if (item.ques && item.ques.length) {
  806. doQuestionNum++;
  807. doQuestionIds.push(item.questionId)
  808. }
  809. } else if (item.type == 3) {
  810. if (item.ques == item.ans) {
  811. item.scoreResult = item.score;
  812. score += item.score;
  813. number++;
  814. rightQuestionIds.push(item.questionId)
  815. } else {
  816. item.scoreResult = 0;
  817. doWrongQuestionIds.push(item.questionId)
  818. }
  819. allScore += item.score;
  820. if (item.ques) {
  821. doQuestionNum++;
  822. doQuestionIds.push(item.questionId)
  823. }
  824. } else if (item.type == 4) {
  825. allScore += item.score;
  826. if (item.ques && item.ques.length) {
  827. doQuestionNum++;
  828. doQuestionIds.push(item.questionId)
  829. }
  830. } else if (item.type == 5) {
  831. allScore += item.score;
  832. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  833. doQuestionNum++;
  834. doQuestionIds.push(item.questionId)
  835. }
  836. }
  837. });
  838. //大于60分及格
  839. if(score >= 60) {
  840. reportStatus = 1
  841. } else {
  842. reportStatus = 0
  843. }
  844. //交卷
  845. this.$api
  846. .examRecordEdit({
  847. examId: this.id,
  848. goodsId: this.goodsId,
  849. reportStatus:reportStatus,
  850. recordId: this.recordId,
  851. rightQuestionNum: number,
  852. status: 1,
  853. moduleExamId:this.moduleId || 0,
  854. chapterExamId:this.chapterId || 0,
  855. doQuestionIds:doQuestionIds.join(','),
  856. rightQuestionIds:rightQuestionIds.join(','),
  857. doQuestionNum: doQuestionNum,
  858. performance: score,
  859. totalScore: allScore,
  860. examTime: parseInt(this.allTimes),
  861. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  862. historyExamJson: JSON.stringify(this.questionList)
  863. })
  864. .then(res => {
  865. this.isSubmit = true;
  866. if (res.data.code == 200) {
  867. }
  868. });
  869. //错题集id提交(客观题)
  870. this.$api.examWrongRecord({
  871. moduleExamId:this.moduleId || 0,
  872. chapterExamId:this.chapterId || 0,
  873. examId: this.id,
  874. goodsId: this.goodsId,
  875. questionIds: doWrongQuestionIds,
  876. recordId: this.recordId
  877. }).then(res => {
  878. });
  879. },
  880. /**
  881. * 立即交卷
  882. */
  883. submitNow() {
  884. this.showpopups = false;
  885. this.needBack = false;
  886. this.submit();
  887. },
  888. /**
  889. * 离开页面统计回答正确题数
  890. */
  891. examRecordEdit() {
  892. if (!this.isSubmit) {
  893. let number = 0;
  894. let score = 0;
  895. let doQuestionNum = 0;
  896. let doQuestionIds = []; //做过的题目id
  897. this.questionList.forEach((item, index) => {
  898. if (item.type == 1) {
  899. if (item.ques == item.ans) {
  900. score += item.score;
  901. number++;
  902. }
  903. if (item.ques) {
  904. doQuestionNum++;
  905. doQuestionIds.push(item.questionId)
  906. }
  907. } else if (item.type == 2) {
  908. let isRight =
  909. item.ans &&
  910. item.ans.every((quesItem, quesIndex) => {
  911. if(item.ques) {
  912. return item.ques[quesIndex] == item.ans[quesIndex];
  913. } else {
  914. return false;
  915. }
  916. });
  917. if (isRight) {
  918. score += item.score;
  919. number++;
  920. } else {
  921. let checkboxScore = item.score; //获取单题总分数
  922. item.ques && item.ques.forEach((ques,quesIndex) => {
  923. //选错一个全扣
  924. if(item.ques) {
  925. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  926. checkboxScore = 0;
  927. }
  928. } else {
  929. checkboxScore = 0;
  930. }
  931. })
  932. console.log(checkboxScore)
  933. //没选错
  934. if(checkboxScore) {
  935. item.ans.forEach((ans,quesIndex) => {
  936. //漏选扣一部分
  937. if(item.ques) {
  938. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  939. checkboxScore = item.partScore;
  940. }
  941. } else {
  942. checkboxScore = 0;
  943. }
  944. })
  945. }
  946. if(checkboxScore <= 0) { //0分
  947. } else { //部分分
  948. // number++;
  949. score += checkboxScore;
  950. }
  951. }
  952. if (item.ques && item.ques.length) {
  953. doQuestionNum++;
  954. doQuestionIds.push(item.questionId)
  955. }
  956. } else if (item.type == 3) {
  957. if (item.ques == item.ans) {
  958. score += item.score;
  959. number++;
  960. }
  961. if (item.ques) {
  962. doQuestionNum++;
  963. doQuestionIds.push(item.questionId)
  964. }
  965. } else if (item == 4) {
  966. if (item.ques.length) {
  967. doQuestionNum++;
  968. doQuestionIds.push(item.questionId)
  969. }
  970. } else if (item.type == 5) {
  971. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  972. doQuestionNum++;
  973. doQuestionIds.push(item.questionId)
  974. }
  975. }
  976. });
  977. this.$api
  978. .examRecordEdit({
  979. examId: this.id,
  980. goodsId: this.goodsId,
  981. recordId: this.recordId,
  982. doQuestionIds:doQuestionIds.join(','),
  983. rightQuestionNum: number,
  984. moduleExamId:this.moduleId || 0,
  985. chapterExamId:this.chapterId || 0,
  986. status: 0,
  987. doQuestionNum: doQuestionNum,
  988. historyExamJson: JSON.stringify(this.questionList)
  989. })
  990. .then(res => {});
  991. }
  992. },
  993. /**
  994. * 记录总题数
  995. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  996. */
  997. examRecord(hasSpecial) {
  998. let questionList = 0;
  999. // if(!hasSpecial) {
  1000. this.questionList.forEach((item, index) => {
  1001. if(item.type == 1 || item.type == 2 || item.type == 3) {
  1002. questionList++;
  1003. }
  1004. })
  1005. // } else {
  1006. // questionList = this.questionList.length;
  1007. // }
  1008. this.$api
  1009. .examRecord({
  1010. chapterExamId: this.chapterId || 0,
  1011. moduleExamId: this.moduleId || 0,
  1012. examId: this.id,
  1013. goodsId: this.goodsId,
  1014. totalQuestionNum: questionList,
  1015. allQuestionNum:this.questionList.length
  1016. })
  1017. .then(res => {
  1018. this.recordId = res.data.data;
  1019. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1020. if(this.bankType == 1) {
  1021. this.examRecordEdit();
  1022. }
  1023. });
  1024. },
  1025. /**
  1026. * @param {Object} second倒计时过滤器
  1027. */
  1028. countdown(second) {
  1029. if (second) {
  1030. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1031. let m = parseInt((second / 60) % 60); // 计算分数
  1032. let s = parseInt(second % 60); // 计算当前秒数
  1033. if (h < 10) h = '0' + h;
  1034. if (m < 10) m = '0' + m;
  1035. if (s < 10) s = '0' + s;
  1036. return h + ':' + m + ':' + s;
  1037. } else {
  1038. return '';
  1039. }
  1040. },
  1041. /**
  1042. * 请求题目列表
  1043. */
  1044. goodsQuestionList() {
  1045. this.$api
  1046. .goodsQuestionList({
  1047. examId: this.id
  1048. })
  1049. .then(res => {
  1050. if (!res.data.data.length) {
  1051. this.hideDialog();
  1052. uni.showModal({
  1053. showCancel: false,
  1054. content: '该试卷暂无题目',
  1055. success: function(k) {
  1056. if (k.confirm) {
  1057. uni.navigateBack();
  1058. }
  1059. }
  1060. });
  1061. return;
  1062. }
  1063. this.allTimes = res.data.data[0].answerTime * 60;
  1064. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1065. //考试时间到了自动交卷
  1066. if (this.lastTime) {
  1067. this.timer = setInterval(() => {
  1068. if (this.lastTime <= 0) {
  1069. clearInterval(this.timer);
  1070. uni.showToast({
  1071. icon:'none',
  1072. mask:true,
  1073. title:'考试时间已到,系统将自动交卷',
  1074. duration:10000
  1075. })
  1076. this.submit();
  1077. return;
  1078. }
  1079. this.lastTime--;
  1080. }, 1000);
  1081. } else {
  1082. }
  1083. res.data.data.forEach((item, index) => {
  1084. if (typeof item.jsonStr == 'string') {
  1085. item.jsonStr = JSON.parse(item.jsonStr);
  1086. console.log(index)
  1087. if (item.type == 2) {
  1088. //多选
  1089. item.jsonStr.forEach(str => {
  1090. str.optionsId = '' + str.optionsId;
  1091. });
  1092. let arr = item.answerQuestion.split(',');
  1093. arr.forEach((a, i) => {
  1094. arr[i] = '' + a;
  1095. });
  1096. item.ans = arr;
  1097. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1098. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1099. return;
  1100. } else if (item.type == 5) {
  1101. //简答题
  1102. item.ansText = {
  1103. text: '',
  1104. imageList: []
  1105. };
  1106. item.ques = {
  1107. text: '',
  1108. imageList: []
  1109. }
  1110. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1111. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1112. } else if (item.type == 4) {
  1113. //案例题
  1114. console.log(item.jsonStr);
  1115. item.ques = [];
  1116. item.current = 0;
  1117. let ansArr = [];
  1118. item.jsonStr.forEach((json, index) => {
  1119. if (json.type == 1) {
  1120. ansArr[index] = json.answerQuestion;
  1121. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1122. } else if (json.type == 2) {
  1123. json.optionsList.forEach(str => {
  1124. str.optionsId = '' + str.optionsId;
  1125. });
  1126. let arr = json.answerQuestion.split(',');
  1127. arr.forEach((a, i) => {
  1128. arr[i] = '' + a;
  1129. });
  1130. ansArr[index] = arr;
  1131. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1132. } else if (json.type == 3) {
  1133. ansArr[index] = json.answerQuestion;
  1134. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1135. } else if (json.type == 5) {
  1136. ansArr[index] = {
  1137. text: json.answerQuestion,
  1138. imageList: []
  1139. };
  1140. json.ansText = {
  1141. text: '',
  1142. imageList: []
  1143. };
  1144. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1145. }
  1146. });
  1147. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1148. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1149. item.ans = ansArr;
  1150. return;
  1151. }
  1152. console.log(item.analysisContent)
  1153. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1154. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1155. item.ans = item.answerQuestion;
  1156. }
  1157. });
  1158. this.questionList = res.data.data;
  1159. console.log(this.questionList)
  1160. this.lastCount = this.questionList.length;
  1161. this.examRecord();
  1162. this.getCollectInfo(this.current);
  1163. });
  1164. },
  1165. /**
  1166. * @param {Object} e单选点击
  1167. */
  1168. radioSelect(optionsId, bindex) {
  1169. if (this.questionList[bindex].ques) return;
  1170. this.$set(this.questionList[bindex], 'ques', optionsId);
  1171. this.isDoOver();
  1172. // 回答错误
  1173. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1174. this.$api
  1175. .examWrongRecord({
  1176. examId: this.id,
  1177. goodsId: this.goodsId,
  1178. moduleExamId:this.moduleId || 0,
  1179. chapterExamId:this.chapterId || 0,
  1180. questionIds: [this.questionList[bindex].questionId],
  1181. recordId: this.recordId
  1182. })
  1183. .then(res => {});
  1184. } else {
  1185. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1186. // if(question) {
  1187. // this.$api.wrongRecordDelete({
  1188. // "examId": +this.id,
  1189. // "goodsId": +this.goodsId,
  1190. // "questionId": this.questionList[bindex].questionId,
  1191. // }).then(res => {
  1192. // })
  1193. // }
  1194. }
  1195. },
  1196. /**
  1197. * @param {Object} e案例单选点击
  1198. */
  1199. radioSelectChild(optionsId, ansIndex, bindex) {
  1200. if (this.questionList[bindex].ques[ansIndex]) return;
  1201. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1202. this.isDoOver();
  1203. },
  1204. /**
  1205. * @param {Object} 多选点击
  1206. */
  1207. checkboxSelect(optionsId, bindex, index) {
  1208. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  1209. },
  1210. /**
  1211. * @param {Object} 案例多选点击
  1212. */
  1213. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1214. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  1215. },
  1216. isCheckboxChecked(arr) {
  1217. return arr.some(item => {
  1218. if (item.checked) {
  1219. return true;
  1220. }
  1221. });
  1222. },
  1223. /**
  1224. * @param {Object} 多选确认
  1225. */
  1226. checkboxSubmit(bindex) {
  1227. if (this.questionList[bindex].ques) return;
  1228. let arr = [];
  1229. this.questionList[bindex].jsonStr.forEach(item => {
  1230. if (item.checked) {
  1231. arr.push(item.optionsId);
  1232. }
  1233. });
  1234. if(!arr.length) {
  1235. uni.showToast({
  1236. title:'请选择答案',
  1237. icon:'none'
  1238. })
  1239. return;
  1240. }
  1241. this.$set(this.questionList[bindex], 'ques', arr);
  1242. this.isDoOver();
  1243. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  1244. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1245. });
  1246. // 回答错误
  1247. if (isWrong) {
  1248. this.$api
  1249. .examWrongRecord({
  1250. examId: this.id,
  1251. goodsId: this.goodsId,
  1252. moduleExamId:this.moduleId || 0,
  1253. chapterExamId:this.chapterId || 0,
  1254. questionIds: [this.questionList[bindex].questionId],
  1255. recordId: this.recordId
  1256. })
  1257. .then(res => {});
  1258. } else {
  1259. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1260. // if(question) {
  1261. // this.$api.wrongRecordDelete({
  1262. // "examId": +this.id,
  1263. // "goodsId": +this.goodsId,
  1264. // "questionId": this.questionList[bindex].questionId,
  1265. // }).then(res => {
  1266. // })
  1267. // }
  1268. }
  1269. },
  1270. /**
  1271. * @param {Object} 案例多选确认
  1272. */
  1273. checkboxSubmitChild(bindex, ansIndex) {
  1274. if (this.questionList[bindex].ques[ansIndex]) return;
  1275. let arr = [];
  1276. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1277. if (item.checked) {
  1278. arr.push(item.optionsId);
  1279. }
  1280. });
  1281. if(!arr.length) {
  1282. uni.showToast({
  1283. title:'请选择答案',
  1284. icon:'none'
  1285. })
  1286. return;
  1287. }
  1288. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1289. this.isDoOver();
  1290. },
  1291. /**
  1292. * @param {Object} index
  1293. * @param {Object} bindex
  1294. * 判断题
  1295. */
  1296. judgeSelect(index, bindex) {
  1297. if (this.questionList[bindex].ques) return;
  1298. this.$set(this.questionList[bindex], 'ques', index + '');
  1299. this.isDoOver();
  1300. // 回答错误
  1301. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1302. this.$api
  1303. .examWrongRecord({
  1304. examId: this.id,
  1305. goodsId: this.goodsId,
  1306. moduleExamId:this.moduleId || 0,
  1307. chapterExamId:this.chapterId || 0,
  1308. questionIds:[this.questionList[bindex].questionId],
  1309. recordId: this.recordId
  1310. })
  1311. .then(res => {});
  1312. } else {
  1313. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1314. // if(question) {
  1315. // this.$api.wrongRecordDelete({
  1316. // "examId": +this.id,
  1317. // "goodsId": +this.goodsId,
  1318. // "questionId": this.questionList[bindex].questionId,
  1319. // }).then(res => {
  1320. // })
  1321. // }
  1322. }
  1323. },
  1324. /**
  1325. * @param {Object} ansindex
  1326. * @param {Object} childindex
  1327. * @param {Object} bindex
  1328. * 案例判断题
  1329. */
  1330. judgeSelectChild(ansindex, childindex, bindex) {
  1331. if (this.questionList[bindex].ques[ansindex]) return;
  1332. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1333. this.isDoOver();
  1334. },
  1335. openFooterTab() {
  1336. this.show = true;
  1337. },
  1338. changeIndex(index) {
  1339. this.current = index;
  1340. },
  1341. swiperChange(e) {
  1342. this.current = e.detail.current;
  1343. this.getCollectInfo(this.current);
  1344. },
  1345. /**
  1346. * @param {Object} current
  1347. * 获取收藏信息
  1348. */
  1349. getCollectInfo(current) {
  1350. this.$api
  1351. .getCollectInfo({
  1352. examId: this.id,
  1353. questionId: this.questionList[current].questionId,
  1354. goodsId: this.goodsId
  1355. })
  1356. .then(res => {
  1357. if (res.data.code == 500) {
  1358. this.$set(this.collectList, current, false);
  1359. } else if (res.data.code == 200) {
  1360. this.$set(this.collectList, current, res.data.data);
  1361. }
  1362. });
  1363. },
  1364. pdsubmit() {
  1365. // if (this.bankType == 1) {
  1366. let ansCount = this.questionOverNum(true); //已答题数
  1367. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1368. //没有答完
  1369. if (this.lastCount !== 0) {
  1370. this.cgType = 6;
  1371. this.showpopups = true;
  1372. return;
  1373. }
  1374. // }
  1375. if(this.bankType == 2) {
  1376. if(this.lastTime > 0) {
  1377. let lastTime = this.countdown(this.lastTime)
  1378. uni.showModal({
  1379. title:'提示',
  1380. content:`时间还剩余${lastTime},确定交卷吗?`,
  1381. confirmText:'交卷',
  1382. cancelText:'继续答题',
  1383. success:(res) => {
  1384. if(res.confirm) { //确定
  1385. this.submit();
  1386. } else { //取消
  1387. }
  1388. }
  1389. })
  1390. return;
  1391. }
  1392. }
  1393. this.submit();
  1394. },
  1395. /**
  1396. * 交卷
  1397. */
  1398. submit() {
  1399. let score = 0; //计算总分
  1400. let reportStatus = 0;
  1401. let number = 0; //做对的题目数量
  1402. let doQuestionNum = 0; //做过的题目数量
  1403. let allScore = 0; //总分
  1404. let passScore = 0;
  1405. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1406. let doQuestionIds = []; //做过的题目id
  1407. let rightQuestionIds = []; //做对的题目id
  1408. this.questionList.forEach((item, index) => {
  1409. passScore = item.passScore
  1410. if (item.type == 1) {
  1411. //正确
  1412. if (item.ques == item.ans) {
  1413. item.scoreResult = item.score;
  1414. score += item.score;
  1415. number++;
  1416. rightQuestionIds.push(item.questionId)
  1417. } else { //错误
  1418. item.scoreResult = 0;
  1419. doWrongQuestionIds.push(item.questionId)
  1420. }
  1421. allScore += item.score;
  1422. if (item.ques) {
  1423. doQuestionNum++;
  1424. doQuestionIds.push(item.questionId)
  1425. }
  1426. } else if (item.type == 2) {
  1427. let isRight =
  1428. item.ans &&
  1429. item.ans.every((quesItem, quesIndex) => {
  1430. if(item.ques) {
  1431. return item.ques[quesIndex] == item.ans[quesIndex];
  1432. } else {
  1433. return false;
  1434. }
  1435. });
  1436. if (isRight) {
  1437. score += item.score;
  1438. number++;
  1439. item.scoreResult = item.score;
  1440. rightQuestionIds.push(item.questionId)
  1441. } else {
  1442. let checkboxScore = item.score; //获取单题总分数
  1443. item.ques && item.ques.forEach((ques,quesIndex) => {
  1444. //选错一个全扣
  1445. if(item.ques) {
  1446. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1447. checkboxScore = 0;
  1448. }
  1449. } else {
  1450. checkboxScore = 0;
  1451. }
  1452. })
  1453. console.log(checkboxScore)
  1454. //没选错
  1455. if(checkboxScore) {
  1456. item.ans.forEach((ans,quesIndex) => {
  1457. //漏选扣一部分
  1458. if(item.ques) {
  1459. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1460. checkboxScore = item.partScore;
  1461. }
  1462. } else {
  1463. checkboxScore = 0;
  1464. }
  1465. })
  1466. }
  1467. if(checkboxScore <= 0) { //0分
  1468. item.scoreResult = 0;
  1469. doWrongQuestionIds.push(item.questionId)
  1470. } else { //部分分
  1471. // number++;
  1472. doWrongQuestionIds.push(item.questionId)
  1473. item.scoreResult = checkboxScore;
  1474. score += checkboxScore;
  1475. // rightQuestionIds.push(item.questionId)
  1476. }
  1477. }
  1478. allScore += item.score;
  1479. if (item.ques && item.ques.length) {
  1480. doQuestionNum++;
  1481. doQuestionIds.push(item.questionId)
  1482. }
  1483. } else if (item.type == 3) {
  1484. if (item.ques == item.ans) {
  1485. item.scoreResult = item.score;
  1486. score += item.score;
  1487. number++;
  1488. rightQuestionIds.push(item.questionId)
  1489. } else {
  1490. item.scoreResult = 0;
  1491. doWrongQuestionIds.push(item.questionId)
  1492. }
  1493. allScore += item.score;
  1494. if (item.ques) {
  1495. doQuestionNum++;
  1496. doQuestionIds.push(item.questionId)
  1497. }
  1498. } else if (item.type == 4) {
  1499. allScore += item.score;
  1500. if (item.ques && item.ques.length) {
  1501. doQuestionNum++;
  1502. doQuestionIds.push(item.questionId)
  1503. }
  1504. } else if (item.type == 5) {
  1505. allScore += item.score;
  1506. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1507. doQuestionNum++;
  1508. doQuestionIds.push(item.questionId)
  1509. }
  1510. }
  1511. });
  1512. //大于及格
  1513. if(score >= passScore) {
  1514. reportStatus = 1
  1515. } else {
  1516. reportStatus = 0
  1517. }
  1518. //交卷
  1519. this.$api
  1520. .examRecordEdit({
  1521. examId: this.id,
  1522. goodsId: this.goodsId,
  1523. reportStatus:reportStatus,
  1524. recordId: this.recordId,
  1525. rightQuestionNum: number,
  1526. status: 1,
  1527. moduleExamId:this.moduleId || 0,
  1528. chapterExamId:this.chapterId || 0,
  1529. doQuestionIds:doQuestionIds.join(','),
  1530. rightQuestionIds:rightQuestionIds.join(','),
  1531. doQuestionNum: doQuestionNum,
  1532. performance: score,
  1533. totalScore: allScore,
  1534. examTime: parseInt(this.allTimes),
  1535. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1536. historyExamJson: JSON.stringify(this.questionList)
  1537. })
  1538. .then(res => {
  1539. this.isSubmit = true;
  1540. if (res.data.code == 200) {
  1541. uni.showToast({
  1542. title: '交卷成功',
  1543. duration: 1000,
  1544. icon: 'none'
  1545. });
  1546. setTimeout(() => {
  1547. uni.redirectTo({
  1548. url: '/pages2/bank/question_report?goodsId='+this.goodsId+'&chapterId='+this.chapterId+'&moduleId='+this.moduleId+'&examId='+this.id+'&id=' + this.recordId
  1549. });
  1550. }, 1000);
  1551. }
  1552. });
  1553. //错题集id提交(客观题)
  1554. this.$api.examWrongRecord({
  1555. examId: this.id,
  1556. goodsId: this.goodsId,
  1557. questionIds: doWrongQuestionIds,
  1558. recordId: this.recordId
  1559. }).then(res => {
  1560. });
  1561. },
  1562. /**
  1563. * @param {Object} state
  1564. * @param {Object} index
  1565. * 收藏
  1566. */
  1567. collect(state, index) {
  1568. if (!state) {
  1569. this.$api
  1570. .collectQuestion({
  1571. examId: this.id,
  1572. questionId: this.questionList[index].questionId,
  1573. goodsId: this.goodsId || ''
  1574. })
  1575. .then(res => {
  1576. if (res.data.code == 200) {
  1577. this.$set(this.collectList, index, true);
  1578. uni.showToast({
  1579. title: '收藏成功',
  1580. duration: 2000,
  1581. icon: 'none'
  1582. });
  1583. this.getCollectInfo(index)
  1584. }
  1585. });
  1586. } else {
  1587. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  1588. if (res.data.code == 200) {
  1589. this.$set(this.collectList, index, false);
  1590. uni.showToast({
  1591. title: '取消收藏成功',
  1592. duration: 2000,
  1593. icon: 'none'
  1594. });
  1595. }
  1596. });
  1597. }
  1598. return;
  1599. },
  1600. /**
  1601. * @param {Object} imgIndex
  1602. * @param {Object} bankIndex
  1603. * 删除简答图片
  1604. */
  1605. deleteImg(imgIndex, bankIndex) {
  1606. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1607. },
  1608. /**
  1609. * @param {Object} imgIndex
  1610. * @param {Object} bankIndex
  1611. * @param {Object} ansIndex
  1612. * 删除案例题简答图片
  1613. */
  1614. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1615. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1616. },
  1617. /**
  1618. * @param {Object} bankindex
  1619. * 选择上传图片
  1620. */
  1621. chooseImg(bankindex) {
  1622. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1623. uni.showToast({
  1624. icon:'none',
  1625. title:'最多选择4张'
  1626. })
  1627. return;
  1628. }
  1629. uni.chooseImage({
  1630. count: 1, //默认9
  1631. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1632. sourceType: ['album', 'camera'], //从相册选择
  1633. success: res => {
  1634. let self = this;
  1635. // console.log(JSON.stringify(res.tempFilePaths));
  1636. let img = res.tempFilePaths[0];
  1637. uni.getImageInfo({
  1638. src: img,
  1639. success: async res => {
  1640. let canvasWidth = res.width; //图片原始长宽
  1641. let canvasHeight = res.height;
  1642. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1643. uni.compressImage({
  1644. src: img,
  1645. quality: 75,
  1646. width: '50%',
  1647. height: '50%',
  1648. success: async rest => {
  1649. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1650. this.questionList[bankindex].ansText.imageList.push(dir);
  1651. }
  1652. });
  1653. } else {
  1654. const dir = await self.uploadFile(img, 0);
  1655. this.questionList[bankindex].ansText.imageList.push(dir);
  1656. }
  1657. }
  1658. });
  1659. }
  1660. });
  1661. },
  1662. /**
  1663. * @param {Object} bankindex
  1664. * @param {Object} ansindex
  1665. * 案例题选择上传图片
  1666. */
  1667. chooseImgChild(bankindex, ansindex) {
  1668. if(this.questionList[bankindex].jsonStr[ansindex] && this.questionList[bankindex].jsonStr[ansindex].ansText && this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length >= 4) {
  1669. uni.showToast({
  1670. icon:'none',
  1671. title:'最多选择4张'
  1672. })
  1673. return;
  1674. }
  1675. uni.chooseImage({
  1676. count: 1, //默认9
  1677. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1678. sourceType: ['album', 'camera'], //从相册选择
  1679. success: res => {
  1680. let self = this;
  1681. // console.log(JSON.stringify(res.tempFilePaths));
  1682. let img = res.tempFilePaths[0];
  1683. uni.getImageInfo({
  1684. src: img,
  1685. success: async res => {
  1686. let canvasWidth = res.width; //图片原始长宽
  1687. let canvasHeight = res.height;
  1688. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1689. uni.compressImage({
  1690. src: img,
  1691. quality: 75,
  1692. width: '50%',
  1693. height: '50%',
  1694. success: async rest => {
  1695. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1696. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1697. }
  1698. });
  1699. } else {
  1700. const dir = await self.uploadFile(img, 0);
  1701. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1702. }
  1703. }
  1704. });
  1705. }
  1706. });
  1707. },
  1708. uploadFile(options, int) {
  1709. var self = this;
  1710. return new Promise((resolve, reject) => {
  1711. var data = {
  1712. imageStatus: int
  1713. };
  1714. self.$api.aliyunpolicy(data).then(res => {
  1715. console.log(res.data, 6);
  1716. if (res.data.code != 200) {
  1717. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1718. return;
  1719. }
  1720. var ossToken = res.data.data.resultContent;
  1721. if (ossToken.host == null || ossToken.host == undefined) {
  1722. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1723. return;
  1724. }
  1725. uni.uploadFile({
  1726. url: ossToken.host,
  1727. name: 'file',
  1728. filePath: options,
  1729. fileType: 'image',
  1730. header: {
  1731. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1732. },
  1733. formData: {
  1734. key: ossToken.dir,
  1735. OSSAccessKeyId: ossToken.accessid,
  1736. policy: ossToken.policy,
  1737. Signature: ossToken.signature,
  1738. callback: ossToken.callback,
  1739. success_action_status: 200
  1740. },
  1741. success: result => {
  1742. if (result.statusCode === 200) {
  1743. resolve(ossToken.dir);
  1744. } else {
  1745. uni.showToast({
  1746. title: '上传失败',
  1747. icon: 'none'
  1748. });
  1749. return;
  1750. }
  1751. },
  1752. fail: error => {
  1753. uni.showToast({
  1754. title: '上传接口报错' + error,
  1755. icon: 'none'
  1756. });
  1757. return;
  1758. }
  1759. });
  1760. });
  1761. });
  1762. },
  1763. /**
  1764. * @param {Object} type
  1765. * @param {Object} bankindex
  1766. * 简答题答案确认
  1767. */
  1768. submitAns(bankindex) {
  1769. console.log(this.questionList[bankindex]);
  1770. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1771. uni.showToast({
  1772. title: '请输入内容或上传图片',
  1773. duration: 2000,
  1774. icon: 'none'
  1775. });
  1776. return;
  1777. }
  1778. this.$set(this.questionList[bankindex], 'ques', {
  1779. imageList: this.questionList[bankindex].ansText.imageList || [],
  1780. text: this.questionList[bankindex].ansText.text || ''
  1781. });
  1782. this.isDoOver()
  1783. },
  1784. /**
  1785. * @param {Object} bankindex
  1786. * @param {Object} ansindex
  1787. * 案例题简答答案确认
  1788. */
  1789. submitAnsChild(bankindex, ansindex) {
  1790. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1791. uni.showToast({
  1792. title: '请输入内容或上传图片',
  1793. duration: 2000,
  1794. icon: 'none'
  1795. });
  1796. return;
  1797. }
  1798. this.$set(this.questionList[bankindex].ques, ansindex, {
  1799. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList || [],
  1800. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || ''
  1801. });
  1802. this.isDoOver()
  1803. },
  1804. isRight(item, index) {
  1805. //单选
  1806. if (this.questionList[index].ques) {
  1807. if (item.type == 1) {
  1808. return this.questionList[index].ques == this.questionList[index].ans;
  1809. //多选
  1810. } else if (item.type == 2) {
  1811. //每一项都相等
  1812. return this.questionList[index].ans.every((item, i) => {
  1813. return item == this.questionList[index].ques[i];
  1814. });
  1815. //判断
  1816. } else if (item.type == 3) {
  1817. return this.questionList[index].ques == this.questionList[index].ans;
  1818. // } else if (item.type == 5) {
  1819. // if(this.questionList[index].ques.text){
  1820. // return true
  1821. // }else{
  1822. // return false
  1823. // }
  1824. } else {
  1825. return false;
  1826. }
  1827. } else {
  1828. return false;
  1829. }
  1830. },
  1831. right(bankIndex, ansIndex, option) {
  1832. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1833. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1834. return true;
  1835. } else {
  1836. return false;
  1837. }
  1838. } else {
  1839. return false;
  1840. }
  1841. },
  1842. wrong(bankIndex, ansIndex, option) {
  1843. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1844. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1845. return true;
  1846. } else {
  1847. return false;
  1848. }
  1849. } else {
  1850. return false;
  1851. }
  1852. },
  1853. isWrong(item, index) {
  1854. if (this.questionList[index].ques) {
  1855. //单选
  1856. if (item.type == 1) {
  1857. return this.questionList[index].ques != this.questionList[index].ans;
  1858. //多选
  1859. } else if (item.type == 2) {
  1860. //每一项都相等
  1861. return this.questionList[index].ans.some((item, i) => {
  1862. return item != this.questionList[index].ques[i];
  1863. });
  1864. //判断
  1865. } else if (item.type == 3) {
  1866. return this.questionList[index].ques != this.questionList[index].ans;
  1867. } else {
  1868. return false;
  1869. }
  1870. } else {
  1871. return false;
  1872. }
  1873. },
  1874. isOver(item,index) {
  1875. if(this.questionList[index].ques) {
  1876. if (item.type == 4) { //案例题
  1877. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1878. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  1879. if (item.ques[indexs]) {
  1880. return true;
  1881. } else {
  1882. return false;
  1883. }
  1884. } else if (jsonItem.type == 5) {
  1885. if (item.ques[indexs] && (item.ques[indexs].text || item.ques[indexs].imageList.length)) {
  1886. console.log('chil')
  1887. return true;
  1888. } else {
  1889. return false;
  1890. }
  1891. }
  1892. });
  1893. if (isOver) {
  1894. return true;
  1895. } else {
  1896. return false;
  1897. }
  1898. } else if (item.type == 5) { //简答题
  1899. //每一项都相等
  1900. if(item.ques && (item.ques.imageList.length || item.ques.text)) {
  1901. return true;
  1902. }
  1903. //判断
  1904. } else {
  1905. return false;
  1906. }
  1907. } else {
  1908. return false;
  1909. }
  1910. },
  1911. tabSelect(index, bankindex) {
  1912. this.$set(this.questionList[bankindex], 'current', index);
  1913. },
  1914. showPhoto(contentStr) {
  1915. if(contentStr && typeof contentStr == 'string') {
  1916. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  1917. let strArr = contentStr.match(reg);
  1918. strArr.forEach((str,index) => {
  1919. strArr[index] = str.replace(reg,'$1')
  1920. })
  1921. // 预览图片
  1922. uni.previewImage({
  1923. urls: strArr,
  1924. longPressActions: {
  1925. itemList: ['发送给朋友', '保存图片', '收藏'],
  1926. success: function(data) {
  1927. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  1928. },
  1929. fail: function(err) {
  1930. console.log(err.errMsg);
  1931. }
  1932. }
  1933. });
  1934. }
  1935. }
  1936. }
  1937. };
  1938. </script>
  1939. <style lang="scss" scoped>
  1940. .questionBank {
  1941. width:100%;
  1942. height:100vh;
  1943. display: flex;
  1944. flex-direction: column;
  1945. }
  1946. .swiper {
  1947. width: 100%;
  1948. flex:1;
  1949. }
  1950. .lisSty {
  1951. margin-bottom: 16rpx;
  1952. display: flex;
  1953. align-items: center;
  1954. .flex_auto {
  1955. flex: 1;
  1956. }
  1957. }
  1958. .activeTI {
  1959. vertical-align: middle;
  1960. display: inline-block;
  1961. border: 1rpx solid #eee;
  1962. border-radius: 50rpx;
  1963. height: 48rpx;
  1964. line-height: 46rpx;
  1965. text-align: center;
  1966. width: 48rpx;
  1967. margin-right: 15rpx;
  1968. color: #666;
  1969. font-size: 30rpx;
  1970. &.right {
  1971. color: #fff;
  1972. background: #36C75A;
  1973. }
  1974. &.wrong {
  1975. color: #fff;
  1976. background: #FF3B30;
  1977. }
  1978. &.checked {
  1979. color: #fff;
  1980. background: #007AFF;
  1981. }
  1982. }
  1983. .submit_checkbox {
  1984. position:fixed;
  1985. left:0;
  1986. right:0;
  1987. bottom:120rpx;
  1988. margin: 20rpx auto;
  1989. width: 526rpx;
  1990. height: 80rpx;
  1991. background: rgba(0, 122, 255, 1);
  1992. color: #fff;
  1993. text-align: center;
  1994. line-height: 80rpx;
  1995. font-size: 30rpx;
  1996. border-radius: 40rpx;
  1997. &.disabled {
  1998. opacity: 0.6;
  1999. }
  2000. }
  2001. .titles {
  2002. overflow: hidden;
  2003. margin-bottom: 24rpx;
  2004. }
  2005. .titBox {
  2006. padding: 41rpx 25rpx 24rpx 25rpx;
  2007. }
  2008. .titBox_title {
  2009. padding: 21rpx;
  2010. }
  2011. .tabs {
  2012. margin: 10rpx;
  2013. display: flex;
  2014. .tab {
  2015. margin: 0 4rpx;
  2016. padding:10rpx 13rpx;
  2017. text-align: center;
  2018. color: #007aff;
  2019. font-size: 28rpx;
  2020. border-radius: 16rpx;
  2021. background:#fff;
  2022. &.current {
  2023. color: #fff;
  2024. background: #007aff;
  2025. }
  2026. }
  2027. }
  2028. .ans {
  2029. margin: 8rpx 8rpx 8rpx;
  2030. .ans_input {
  2031. border-radius: 16rpx;
  2032. background: #fff;
  2033. .top {
  2034. border-bottom: 1rpx solid #eeeeee;
  2035. padding: 16rpx;
  2036. display: flex;
  2037. align-items: center;
  2038. .icon {
  2039. margin-right: 20rpx;
  2040. width: 40rpx;
  2041. height: 38rpx;
  2042. }
  2043. .progress {
  2044. flex: 1;
  2045. }
  2046. .submit {
  2047. width: 168rpx;
  2048. height: 48rpx;
  2049. line-height: 48rpx;
  2050. text-align: center;
  2051. color: #fff;
  2052. font-size: 30rpx;
  2053. background: #007aff;
  2054. border-radius: 24rpx;
  2055. &.disabled {
  2056. opacity: 0.6;
  2057. }
  2058. }
  2059. }
  2060. .textarea {
  2061. textarea {
  2062. width: 100%;
  2063. height: 287rpx;
  2064. padding: 10rpx;
  2065. }
  2066. }
  2067. .imgs {
  2068. overflow: hidden;
  2069. display: flex;
  2070. width: 100%;
  2071. .img {
  2072. width: 104rpx;
  2073. height: 104rpx;
  2074. border-radius: 8rpx;
  2075. position: relative;
  2076. margin: 20rpx;
  2077. text {
  2078. position: absolute;
  2079. right: -15rpx;
  2080. top: -15rpx;
  2081. width: 30rpx;
  2082. height: 30rpx;
  2083. text-align: center;
  2084. line-height: 30rpx;
  2085. color: #fff;
  2086. background: #FF3B30;
  2087. border-radius: 50%;
  2088. }
  2089. image {
  2090. width: 100%;
  2091. height: 100%;
  2092. }
  2093. }
  2094. }
  2095. }
  2096. .ans_submit {
  2097. padding: 16rpx;
  2098. border-radius: 16rpx;
  2099. background: #fff;
  2100. .imgs {
  2101. overflow: hidden;
  2102. display: flex;
  2103. width: 100%;
  2104. .img {
  2105. width: 104rpx;
  2106. height: 104rpx;
  2107. border-radius: 8rpx;
  2108. position: relative;
  2109. margin: 20rpx;
  2110. image {
  2111. width: 100%;
  2112. height: 100%;
  2113. }
  2114. }
  2115. }
  2116. }
  2117. }
  2118. .leftLetters {
  2119. display: flex;
  2120. align-items: center;
  2121. width: 220rpx;
  2122. .btnType {
  2123. padding: 5rpx 10rpx;
  2124. border: 1rpx solid #007aff;
  2125. border-radius: 10rpx;
  2126. background-color: rgba(0, 122, 255, 0.1);
  2127. font-size: 28rpx;
  2128. color: #007aff;
  2129. margin-right: 15rpx;
  2130. }
  2131. }
  2132. .firstLetter {
  2133. display: flex;
  2134. justify-content: space-between;
  2135. align-items: center;
  2136. margin-bottom: 30rpx;
  2137. }
  2138. .popupView {
  2139. height: 100%;
  2140. padding-bottom: 100rpx;
  2141. .popupTops {
  2142. height: 77rpx;
  2143. border-bottom: 1rpx solid #eee;
  2144. text-align: center;
  2145. line-height: 77rpx;
  2146. font-size: 24rpx;
  2147. color: #999;
  2148. position: relative;
  2149. .topIcon {
  2150. position: absolute;
  2151. top: 10rpx;
  2152. left: 50%;
  2153. transform: translateX(-50%);
  2154. width: 80rpx;
  2155. height: 8rpx;
  2156. background-color: #999;
  2157. border-radius: 4rpx;
  2158. }
  2159. }
  2160. .popupContent {
  2161. }
  2162. }
  2163. .pageContent {
  2164. position: relative;
  2165. background-color: #eaeef1;
  2166. height: 100%;
  2167. padding-top: 8rpx;
  2168. padding-bottom: 100rpx;
  2169. overflow-y: scroll;
  2170. }
  2171. .pad_8 {
  2172. background-color: #fff;
  2173. margin: 0rpx 8rpx 8rpx;
  2174. border-radius: 16rpx;
  2175. &.no-margin {
  2176. margin-top:-16rpx;
  2177. border-radius: 0 0 16rpx 16rpx;
  2178. }
  2179. }
  2180. .answer {
  2181. height: 80rpx;
  2182. line-height: 80rpx;
  2183. padding: 0rpx 24rpx;
  2184. display: flex;
  2185. align-items: center;
  2186. justify-content: space-between;
  2187. color: #666;
  2188. font-size: 30rpx;
  2189. }
  2190. .footer_btn {
  2191. background-color: #fff;
  2192. z-index: 10078;
  2193. position: fixed;
  2194. bottom: 0rpx;
  2195. display: flex;
  2196. align-items: center;
  2197. justify-content: space-between;
  2198. width: 100%;
  2199. height: 98rpx;
  2200. padding: 0rpx 38rpx;
  2201. border-top: 1rpx solid #eee;
  2202. .flex_center {
  2203. flex:1;
  2204. display: flex;
  2205. justify-content: center;
  2206. align-items: center;
  2207. flex-direction: column;
  2208. margin:0 200rpx;
  2209. font-size: 24rpx;
  2210. color: #999999;
  2211. .up-icon {
  2212. margin-bottom:18rpx;
  2213. width:100%;
  2214. display: flex;
  2215. justify-content: center;
  2216. image {
  2217. width:58rpx;
  2218. height:21rpx;
  2219. }
  2220. }
  2221. }
  2222. .collect {
  2223. visibility: hidden;
  2224. width:100rpx;
  2225. &.show {
  2226. visibility: visible;
  2227. }
  2228. >view {
  2229. display: flex;
  2230. flex-direction: column;
  2231. align-items: center;
  2232. justify-content: center;
  2233. image {
  2234. width:32rpx;
  2235. height:32rpx;
  2236. margin-bottom:6rpx;
  2237. }
  2238. view {
  2239. font-size: 24rpx;
  2240. color: #999999;
  2241. }
  2242. }
  2243. }
  2244. }
  2245. .boxSty {
  2246. padding: 44rpx 41rpx 0rpx;
  2247. }
  2248. .liListSty {
  2249. border: 1rpx solid #eeeeee;
  2250. width: 88rpx;
  2251. height: 88rpx;
  2252. border-radius: 32rpx;
  2253. text-align: center;
  2254. line-height: 88rpx;
  2255. color: #333;
  2256. font-size: 32rpx;
  2257. float: left;
  2258. margin: 20rpx 23rpx;
  2259. &.isRight {
  2260. border: 1rpx solid #eeeeee;
  2261. color: #fff;
  2262. background: #36C75A;
  2263. }
  2264. &.isWrong {
  2265. border: 1rpx solid #eeeeee;
  2266. color: #fff;
  2267. background: #FF3B30;
  2268. }
  2269. &.isOver {
  2270. border: 1rpx solid #eeeeee;
  2271. color: #fff;
  2272. background: blue;
  2273. }
  2274. }
  2275. .answerInfos {
  2276. padding: 25rpx 25rpx 25rpx 23rpx;
  2277. }
  2278. .answerTitle {
  2279. margin-bottom: 28rpx;
  2280. color: #666;
  2281. font-size: 30rpx;
  2282. }
  2283. .answerContent {
  2284. font-size: 30rpx;
  2285. color: #666;
  2286. }
  2287. .textChild {
  2288. display: inline-block;
  2289. vertical-align: middle;
  2290. }
  2291. .dialog {
  2292. position: fixed;
  2293. left: 0;
  2294. top: 0;
  2295. width: 100%;
  2296. height: 100%;
  2297. background-color: rgba(0, 0, 0, 0.8);
  2298. display: flex;
  2299. flex-direction: column;
  2300. align-items: center;
  2301. justify-content: center;
  2302. z-index: 20000;
  2303. .pointer {
  2304. width:338rpx;
  2305. height:240rpx;
  2306. }
  2307. .text {
  2308. font-size: 32rpx;
  2309. color: #ffffff;
  2310. text-align: center;
  2311. }
  2312. .btn {
  2313. width: 242rpx;
  2314. height: 82rpx;
  2315. border: 2rpx solid #ffffff;
  2316. border-radius: 16rpx;
  2317. text-align: center;
  2318. line-height: 82rpx;
  2319. margin: 41rpx auto;
  2320. color: #fff;
  2321. font-size: 32rpx;
  2322. }
  2323. }
  2324. .dialog-arrow {
  2325. padding-top:124rpx;
  2326. position: fixed;
  2327. left: 0;
  2328. top: 0;
  2329. width: 100%;
  2330. height: 100%;
  2331. background-color: rgba(0, 0, 0, 0.8);
  2332. z-index: 20000;
  2333. .pointer {
  2334. margin-left:87rpx;
  2335. display: block;
  2336. width:95rpx;
  2337. height:98rpx;
  2338. }
  2339. .text {
  2340. padding-left:177rpx;
  2341. font-size: 32rpx;
  2342. color: #ffffff;
  2343. }
  2344. .btn {
  2345. width: 242rpx;
  2346. height: 82rpx;
  2347. border: 2rpx solid #ffffff;
  2348. border-radius: 16rpx;
  2349. text-align: center;
  2350. line-height: 82rpx;
  2351. margin: 500rpx auto 0;
  2352. color: #fff;
  2353. font-size: 32rpx;
  2354. }
  2355. }
  2356. .dialog_wrap {
  2357. position: fixed;
  2358. left: 0;
  2359. top: 0;
  2360. width: 100%;
  2361. height: 100%;
  2362. z-index: 9999999999;
  2363. .bg {
  2364. background: rgba(0, 0, 0, 0.3);
  2365. position: absolute;
  2366. left: 0;
  2367. top: 0;
  2368. width: 100%;
  2369. height: 100%;
  2370. }
  2371. .dialog {
  2372. position: absolute;
  2373. left: 50%;
  2374. top: 50%;
  2375. transform: translate3D(-50%, -50%, 0);
  2376. width: 640rpx;
  2377. height: 439rpx;
  2378. background: #ffffff;
  2379. border-radius: 24rpx;
  2380. .title {
  2381. font-size: 30rpx;
  2382. font-weight: bold;
  2383. color: #333333;
  2384. line-height: 48rpx;
  2385. text-align: center;
  2386. margin-top: 40rpx;
  2387. }
  2388. .content {
  2389. margin: 35rpx 35rpx 0;
  2390. font-size: 30rpx;
  2391. color: #666666;
  2392. line-height: 48rpx;
  2393. }
  2394. .btns {
  2395. margin-top: 35rpx;
  2396. display: flex;
  2397. align-items: center;
  2398. justify-content: center;
  2399. .btn {
  2400. width: 200rpx;
  2401. height: 80rpx;
  2402. line-height: 80rpx;
  2403. text-align: center;
  2404. background: #f5f5f5;
  2405. border-radius: 40rpx;
  2406. font-size: 30rpx;
  2407. color: rgba(0, 122, 255, 1);
  2408. background: #f5f5f5;
  2409. margin: 0 20rpx;
  2410. &.active {
  2411. color: #f5f5f5;
  2412. background: rgba(0, 122, 255, 1);
  2413. }
  2414. }
  2415. }
  2416. }
  2417. }
  2418. .popboxs {
  2419. width: 100%;
  2420. height: 100%;
  2421. display: flex;
  2422. flex-direction: column;
  2423. align-items: center;
  2424. }
  2425. .classTops {
  2426. flex-shrink: 0;
  2427. padding: 39rpx 0rpx 4rpx;
  2428. font-weight: bold;
  2429. color: #333;
  2430. font-size: 30rpx;
  2431. }
  2432. .textStys {
  2433. width: 100%;
  2434. flex: 1;
  2435. padding: 36rpx;
  2436. }
  2437. .classFootsty {
  2438. flex-shrink: 0;
  2439. display: flex;
  2440. align-items: center;
  2441. justify-content: center;
  2442. padding: 10rpx 0rpx 40rpx;
  2443. .btnsty {
  2444. width: 200rpx;
  2445. height: 80rpx;
  2446. border-radius: 40rpx;
  2447. font-weight: bold;
  2448. font-size: 30rpx;
  2449. text-align: center;
  2450. line-height: 80rpx;
  2451. }
  2452. .btns1 {
  2453. background-color: #f5f5f5;
  2454. color: #007aff;
  2455. }
  2456. .btns2 {
  2457. margin-left: 40rpx;
  2458. background-color: #007aff;
  2459. color: #ffffff;
  2460. }
  2461. }
  2462. </style>