questionBank.vue 68 KB

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