questionBank.vue 69 KB

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