questionBank.vue 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar
  4. @clickLeft="clickLeft"
  5. left-icon="back"
  6. ref="navbar"
  7. :statusBar="true"
  8. :title="examData.examName"
  9. ></uni-nav-bar>
  10. <swiper class="swiper" :current="current" @change="swiperChange">
  11. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  12. <view class="pageContent">
  13. <view class="pad_8 titBox">
  14. <view class="firstLetter">
  15. <view class="leftLetters">
  16. <view class="btnType">
  17. <text v-if="bank.type == 1">单选</text>
  18. <text v-if="bank.type == 2">多选</text>
  19. <text v-if="bank.type == 3">判断</text>
  20. <text v-if="bank.type == 4">案例</text>
  21. <text v-if="bank.type == 5">简答</text>
  22. </view>
  23. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  24. </view>
  25. <view style="color: #666; font-size: 28rpx">{{
  26. countdown(lastTime)
  27. }}</view>
  28. </view>
  29. <view class="titles" @click="showPhoto(bank.content)"
  30. ><rich-text :nodes="bank.content"></rich-text
  31. ></view>
  32. </view>
  33. <template v-if="bank.type == 1">
  34. <view class="pad_8 titBox no-margin">
  35. <view v-if="!bank.ques">
  36. <view
  37. v-for="(item, index) in bank.jsonStr"
  38. :key="index"
  39. class="lisSty"
  40. @click="radioSelect(item.optionsId, bankIndex)"
  41. >
  42. <view class="activeTI">{{ ast[index] }}</view>
  43. <view class="flex_auto"
  44. >{{ item.content }}
  45. <view v-if="item.imgUrl">
  46. <image
  47. style="width: 600rpx"
  48. mode="widthFix"
  49. :src="$method.splitImgHost(item.imgUrl)"
  50. ></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="bank.ques">
  56. <view
  57. v-for="(item, index) in bank.jsonStr"
  58. :key="index"
  59. class="lisSty"
  60. @click="radioSelect(item.optionsId, bankIndex)"
  61. >
  62. <text
  63. :class="{
  64. right:
  65. bankType == 1 &&
  66. (item.optionsId == bank.ques ||
  67. item.optionsId == bank.ans),
  68. wrong:
  69. bankType == 1 &&
  70. item.optionsId == bank.ques &&
  71. bank.ques != bank.ans,
  72. user_choose: bankType == 2 && item.optionsId == bank.ques,
  73. }"
  74. class="activeTI"
  75. >
  76. {{ ast[index] }}
  77. </text>
  78. <view class="flex_auto">
  79. {{ item.content }}
  80. <view v-if="item.imgUrl">
  81. <image
  82. style="width: 600rpx"
  83. mode="widthFix"
  84. :src="$method.splitImgHost(item.imgUrl)"
  85. ></image>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view v-if="bankType == 1 && bank.ques">
  92. <view class="pad_8 answer">
  93. <view>题目答案:{{ ast[bank.ans - 1] }} </view>
  94. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  95. </view>
  96. <view class="pad_8 answerInfos">
  97. <view class="answerTitle">答案解析</view>
  98. <view class="answerContent"
  99. ><rich-text :nodes="bank.analysisContent"></rich-text
  100. ></view>
  101. </view>
  102. </view>
  103. </template>
  104. <template v-if="bank.type == 2">
  105. <view class="pad_8 titBox no-margin">
  106. <view v-if="!bank.ques">
  107. <view
  108. v-for="(item, index) in bank.jsonStr"
  109. :key="index"
  110. class="lisSty"
  111. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  112. >
  113. <view :class="{ checked: item.checked }" class="activeTI">{{
  114. ast[index]
  115. }}</view>
  116. <view class="flex_auto">
  117. {{ item.content }}
  118. <view v-if="item.imgUrl">
  119. <image
  120. style="width: 600rpx"
  121. mode="widthFix"
  122. :src="$method.splitImgHost(item.imgUrl)"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. <view v-if="bank.ques">
  129. <view
  130. v-for="(item, index) in bank.jsonStr"
  131. :key="index"
  132. class="lisSty"
  133. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  134. >
  135. <text
  136. :class="{
  137. right:
  138. bankType == 1 &&
  139. (bank.ques.indexOf(item.optionsId) != -1 ||
  140. bank.ans.indexOf(item.optionsId) != -1),
  141. wrong:
  142. bankType == 1 &&
  143. bank.ques.indexOf(item.optionsId) != -1 &&
  144. bank.ans.indexOf(item.optionsId) == -1,
  145. user_choose: bankType == 2 && item.checked,
  146. }"
  147. class="activeTI"
  148. >
  149. {{ ast[index] }}
  150. </text>
  151. <view class="flex_auto">
  152. {{ item.content }}
  153. <view v-if="item.imgUrl">
  154. <image
  155. style="width: 600rpx"
  156. mode="widthFix"
  157. :src="$method.splitImgHost(item.imgUrl)"
  158. ></image>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view
  164. v-if="bankType == 2 || (bankType == 1 && !bank.ques)"
  165. class="submit_checkbox"
  166. :class="{ disabled: !isCheckboxChecked(bank.jsonStr) }"
  167. @click="checkboxSubmit(bankIndex)"
  168. >确认答案</view
  169. >
  170. </view>
  171. <view v-if="bankType == 1 && bank.ques">
  172. <view class="pad_8 answer">
  173. <view>
  174. 题目答案:
  175. <text
  176. v-for="(ansItem, ansIndex) in bank.ans"
  177. :key="ansIndex"
  178. >{{ ast[ansItem - 1] }}</text
  179. >
  180. </view>
  181. <view>
  182. 我的答案:
  183. <text
  184. v-for="(quesItem, quesIndex) in bank.ques"
  185. :key="quesIndex"
  186. >{{ ast[quesItem - 1] }}</text
  187. >
  188. </view>
  189. </view>
  190. <view class="pad_8 answerInfos">
  191. <view class="answerTitle">答案解析</view>
  192. <view class="answerContent"
  193. ><rich-text :nodes="bank.analysisContent"></rich-text
  194. ></view>
  195. </view>
  196. </view>
  197. </template>
  198. <template v-if="bank.type == 3">
  199. <view class="pad_8 titBox no-margin">
  200. <view v-if="!bank.ques">
  201. <view
  202. v-for="(item, index) in judge"
  203. :key="index"
  204. class="lisSty"
  205. @click="judgeSelect(index, bankIndex)"
  206. >
  207. <view class="activeTI">{{ ast[index] }}</view>
  208. <view class="flex_auto">
  209. {{ item }}
  210. <view v-if="item.imgUrl">
  211. <image
  212. style="width: 600rpx"
  213. mode="widthFix"
  214. :src="$method.splitImgHost(item.imgUrl)"
  215. ></image>
  216. </view>
  217. </view>
  218. </view>
  219. </view>
  220. <view v-if="bank.ques">
  221. <view
  222. v-for="(item, index) in judge"
  223. :key="index"
  224. class="lisSty"
  225. @click="judgeSelect(index, bankIndex)"
  226. >
  227. <!-- right: bankType == 1 && (index == bank.ques || index == bank.ans),
  228. wrong: bankType == 1 && (index == bank.ques && bank.ques != bank.ans),
  229. user_choose: bankType == 2 && (index == bank.ques), -->
  230. <text
  231. :class="{
  232. right:
  233. bankType == 1 &&
  234. (index == (bank.ques == 1 ? 0 : 1) ||
  235. index != bank.ans),
  236. wrong:
  237. bankType == 1 &&
  238. index == (bank.ques == 1 ? 0 : 1) &&
  239. bank.ques != bank.ans,
  240. user_choose:
  241. bankType == 2 && index == (bank.ques == 1 ? 0 : 1),
  242. }"
  243. class="activeTI"
  244. >
  245. {{ ast[index] }}
  246. </text>
  247. <view class="flex_auto">
  248. {{ item }}
  249. <view v-if="item.imgUrl">
  250. <image
  251. style="width: 600rpx"
  252. mode="widthFix"
  253. :src="$method.splitImgHost(item.imgUrl)"
  254. ></image>
  255. </view>
  256. </view>
  257. </view>
  258. </view>
  259. </view>
  260. <view v-if="bankType == 1 && bank.ques">
  261. <view class="pad_8 answer">
  262. <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
  263. <view>我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
  264. </view>
  265. <view class="pad_8 answerInfos">
  266. <view class="answerTitle">答案解析</view>
  267. <view class="answerContent"
  268. ><rich-text :nodes="bank.analysisContent"></rich-text
  269. ></view>
  270. </view>
  271. </view>
  272. </template>
  273. <!-- 简答题 -->
  274. <template v-if="bank.type == 5">
  275. <view class="pad_8 titBox">
  276. <view class="ans">
  277. <view
  278. class="ans_input"
  279. v-if="
  280. bankType == 2 ||
  281. (bankType == 1 &&
  282. (!bank.ques ||
  283. (!bank.ques.imageList.length && !bank.ques.text)))
  284. "
  285. >
  286. <view class="top flex">
  287. <image
  288. :data-index="bankIndex"
  289. class="icon"
  290. @click="chooseImg(bankIndex)"
  291. src="/static/camera.png"
  292. mode=""
  293. ></image>
  294. <view class="progress"
  295. >{{ bank.ansText.imageList.length || "0" }}/4</view
  296. >
  297. <view
  298. class="submit"
  299. :class="{ disabled: !bank.ansText.text && hasImgs(bank) }"
  300. @click="submitAns(bankIndex)"
  301. >确认答案</view
  302. >
  303. </view>
  304. <view class="textarea">
  305. <textarea
  306. v-model="bank.ansText.text"
  307. placeholder="在此输入答案"
  308. ></textarea>
  309. </view>
  310. <view class="imgs">
  311. <view
  312. class="img"
  313. v-for="(img, imgIndex) in bank.ansText.imageList"
  314. :key="imgIndex"
  315. >
  316. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  317. <image :src="$method.splitImgHost(img, true)"></image>
  318. </view>
  319. </view>
  320. </view>
  321. <view
  322. class="ans_submit answerInfos"
  323. v-if="
  324. bankType == 1 &&
  325. bank.ques &&
  326. (bank.ques.imageList.length || bank.ques.text)
  327. "
  328. >
  329. <view class="answerTitle">我的答案:</view>
  330. {{ bank.ques.text }}
  331. <view class="imgs"
  332. ><image
  333. class="img"
  334. :key="quesIndex"
  335. v-for="(ques, quesIndex) in bank.ques.imageList"
  336. :src="$method.splitImgHost(ques, true)"
  337. ></image
  338. ></view>
  339. </view>
  340. </view>
  341. </view>
  342. <view
  343. v-if="
  344. bankType == 1 &&
  345. bank.ques &&
  346. (bank.ques.imageList.length || bank.ques.text)
  347. "
  348. >
  349. <view class="pad_8 answerInfos">
  350. <view class="answerTitle">答案解析:</view>
  351. <view class="answerContent"
  352. ><rich-text :nodes="bank.analysisContent"></rich-text
  353. ></view>
  354. </view>
  355. </view>
  356. </template>
  357. <!-- 案例题 -->
  358. <template v-if="bank.type == 4">
  359. <view class="tabs">
  360. <view
  361. class="tab"
  362. :class="{ current: tabIndex == bank.current }"
  363. :key="tabIndex"
  364. v-for="(tab, tabIndex) in bank.jsonStr"
  365. @click="tabSelect(tabIndex, bankIndex)"
  366. >
  367. 问题{{ tabIndex + 1 }}
  368. </view>
  369. </view>
  370. <view
  371. v-for="(ansItem, ansIndex) in bank.jsonStr"
  372. v-if="bank.current == ansIndex"
  373. :key="ansIndex"
  374. >
  375. <template v-if="ansItem.type == 1">
  376. <view class="pad_8 titBox">
  377. <view class="leftLetters">
  378. <view class="btnType">
  379. <text>单选</text>
  380. </view>
  381. </view>
  382. <view class="titles"
  383. ><rich-text :nodes="ansItem.content"></rich-text
  384. ></view>
  385. <view v-if="!bank.ques[ansIndex]">
  386. <view
  387. v-for="(option, childIndex) in ansItem.optionsList"
  388. :key="childIndex"
  389. class="lisSty"
  390. @click="
  391. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  392. "
  393. >
  394. <view class="activeTI">{{ ast[childIndex] }}</view>
  395. <view class="flex_auto">
  396. <rich-text
  397. class="textChild"
  398. :nodes="option.content"
  399. ></rich-text>
  400. <view v-if="option.imgUrl">
  401. <image
  402. style="width: 600rpx"
  403. mode="widthFix"
  404. :src="$method.splitImgHost(option.imgUrl)"
  405. ></image>
  406. </view>
  407. </view>
  408. </view>
  409. </view>
  410. <view v-if="bank.ques[ansIndex]">
  411. <view
  412. v-for="(option, childIndex) in ansItem.optionsList"
  413. :key="childIndex"
  414. class="lisSty"
  415. @click="
  416. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  417. "
  418. >
  419. <text
  420. :class="{
  421. right:
  422. bankType == 1 &&
  423. (option.optionsId == bank.ques[ansIndex] ||
  424. option.optionsId == bank.ans[ansIndex]),
  425. wrong:
  426. bankType == 1 &&
  427. option.optionsId == bank.ques[ansIndex] &&
  428. bank.ques[ansIndex] != bank.ans[ansIndex],
  429. user_choose:
  430. bankType == 2 &&
  431. option.optionsId == bank.ques[ansIndex],
  432. }"
  433. class="activeTI"
  434. >
  435. {{ ast[childIndex] }}
  436. </text>
  437. <view class="flex_auto">
  438. <rich-text :nodes="option.content"></rich-text>
  439. <view v-if="option.imgUrl">
  440. <image
  441. style="width: 600rpx"
  442. mode="widthFix"
  443. :src="$method.splitImgHost(option.imgUrl)"
  444. ></image>
  445. </view>
  446. </view>
  447. </view>
  448. </view>
  449. </view>
  450. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  451. <view class="pad_8 answer">
  452. <view>题目答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  453. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  454. </view>
  455. <view class="pad_8 answerInfos">
  456. <view class="answerTitle">答案解析</view>
  457. <view class="answerContent"
  458. ><rich-text :nodes="option.analysisContent"></rich-text
  459. ></view>
  460. </view>
  461. </view>
  462. </template>
  463. <template v-if="ansItem.type == 2">
  464. <view class="pad_8 titBox">
  465. <view class="leftLetters">
  466. <view class="btnType">
  467. <text>多选</text>
  468. </view>
  469. </view>
  470. <view class="titles"
  471. ><rich-text :nodes="ansItem.content"></rich-text
  472. ></view>
  473. <view v-if="!bank.ques[ansIndex]">
  474. <view
  475. v-for="(option, childindex) in ansItem.optionsList"
  476. :key="childindex"
  477. class="lisSty"
  478. @click="
  479. checkboxSelectChild(bankIndex, ansIndex, childindex)
  480. "
  481. >
  482. <view
  483. :class="{ checked: option.checked }"
  484. class="activeTI"
  485. >{{ ast[childindex] }}</view
  486. >
  487. <view class="flex_auto">
  488. <rich-text :nodes="option.content"></rich-text>
  489. <view v-if="option.imgUrl">
  490. <image
  491. style="width: 600rpx"
  492. mode="widthFix"
  493. :src="$method.splitImgHost(option.imgUrl)"
  494. ></image>
  495. </view>
  496. </view>
  497. </view>
  498. </view>
  499. <view
  500. v-if="
  501. bankType == 2 || (bankType == 1 && !bank.ques[ansIndex])
  502. "
  503. class="submit_checkbox"
  504. :class="{
  505. disabled: !isCheckboxChecked(ansItem.optionsList),
  506. }"
  507. @click="checkboxSubmitChild(bankIndex, ansIndex)"
  508. >确认答案</view
  509. >
  510. <view v-if="bank.ques && bank.ques[ansIndex]">
  511. <view
  512. v-for="(option, childindex) in ansItem.optionsList"
  513. :key="childindex"
  514. class="lisSty"
  515. @click="
  516. checkboxSelectChild(bankIndex, ansIndex, childindex)
  517. "
  518. >
  519. <text
  520. :class="{
  521. right:
  522. bankType == 1 && right(bankIndex, ansIndex, option),
  523. wrong:
  524. bankType == 1 && wrong(bankIndex, ansIndex, option),
  525. user_choose: bankType == 2 && option.checked,
  526. }"
  527. class="activeTI"
  528. >
  529. {{ ast[childindex] }}
  530. </text>
  531. <view class="flex_auto">
  532. <rich-text :nodes="option.content"></rich-text>
  533. <view v-if="option.imgUrl">
  534. <image
  535. style="width: 600rpx"
  536. mode="widthFix"
  537. :src="$method.splitImgHost(option.imgUrl)"
  538. ></image>
  539. </view>
  540. </view>
  541. </view>
  542. </view>
  543. </view>
  544. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  545. <view class="pad_8 answer">
  546. <view>
  547. 题目答案:
  548. <text
  549. :key="ansItemIndex1"
  550. v-for="(ansItem1, ansItemIndex1) in bank.ans[ansIndex]"
  551. >{{ ast[ansItem1 - 1] }}</text
  552. >
  553. </view>
  554. <view>
  555. 我的答案:
  556. <text
  557. :key="quesItemIndex"
  558. v-for="(quesItem, quesItemIndex) in bank.ques[ansIndex]"
  559. >{{ ast[quesItem - 1] }}</text
  560. >
  561. </view>
  562. </view>
  563. <view class="pad_8 answerInfos">
  564. <view class="answerTitle">答案解析</view>
  565. <view class="answerContent"
  566. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  567. ></view>
  568. </view>
  569. </view>
  570. </template>
  571. <template v-if="ansItem.type == 3">
  572. <view class="pad_8 titBox">
  573. <view class="leftLetters">
  574. <view class="btnType">
  575. <text>判断</text>
  576. </view>
  577. </view>
  578. <view class="titles"
  579. ><rich-text :nodes="ansItem.content"></rich-text
  580. ></view>
  581. <view v-if="!bank.ques[ansIndex]">
  582. <view
  583. v-for="(option, childindex) in judge"
  584. :key="childindex"
  585. class="lisSty"
  586. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  587. >
  588. <view class="activeTI">{{ ast[childindex] }}</view>
  589. <view class="flex_auto">
  590. {{ option }}
  591. <view v-if="option.imgUrl">
  592. <image
  593. style="width: 600rpx"
  594. mode="widthFix"
  595. :src="$method.splitImgHost(option.imgUrl)"
  596. ></image>
  597. </view>
  598. </view>
  599. </view>
  600. </view>
  601. <view v-if="bank.ques[ansIndex]">
  602. <view
  603. v-for="(option, childindex) in judge"
  604. :key="childindex"
  605. class="lisSty"
  606. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  607. >
  608. <text
  609. :class="{
  610. right:
  611. bankType == 1 &&
  612. (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
  613. childindex != bank.ans[ansIndex]),
  614. wrong:
  615. bankType == 1 &&
  616. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
  617. bank.ques[ansIndex] != bank.ans[ansIndex],
  618. user_choose:
  619. bankType == 2 &&
  620. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1),
  621. }"
  622. class="activeTI"
  623. >
  624. {{ ast[childindex] }}
  625. </text>
  626. <view class="flex_auto">
  627. {{ option }}
  628. <view v-if="option.imgUrl">
  629. <image
  630. style="width: 600rpx"
  631. mode="widthFix"
  632. :src="$method.splitImgHost(option.imgUrl)"
  633. ></image>
  634. </view>
  635. </view>
  636. </view>
  637. </view>
  638. </view>
  639. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  640. <view class="pad_8 answer">
  641. <view
  642. >题目答案:{{
  643. ast[bank.ans[ansIndex] == 1 ? 0 : 1]
  644. }}</view
  645. >
  646. <view
  647. >我的答案:{{
  648. ast[bank.ques[ansIndex] == 1 ? 0 : 1]
  649. }}</view
  650. >
  651. </view>
  652. <view class="pad_8 answerInfos">
  653. <view class="answerTitle">答案解析</view>
  654. <view class="answerContent"
  655. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  656. ></view>
  657. </view>
  658. </view>
  659. </template>
  660. <!-- 简答题 -->
  661. <template v-if="ansItem.type == 5">
  662. <view class="pad_8 titBox_title">
  663. <view class="leftLetters">
  664. <view class="btnType">
  665. <text>简答</text>
  666. </view>
  667. </view>
  668. <view><rich-text :nodes="ansItem.content"></rich-text></view>
  669. </view>
  670. <view class="pad_8 titBox_title">
  671. <view class="ans">
  672. <view
  673. class="ans_input"
  674. v-if="
  675. bankType == 2 ||
  676. (bankType == 1 &&
  677. (!bank.ques[ansIndex] ||
  678. (!bank.ques[ansIndex].text &&
  679. !bank.ques[ansIndex].imageList.length)))
  680. "
  681. >
  682. <view class="top flex">
  683. <image
  684. class="icon"
  685. @click="chooseImgChild(bankIndex, ansIndex)"
  686. src="/static/camera.png"
  687. mode=""
  688. ></image>
  689. <view class="progress"
  690. >{{ ansItem.ansText.imageList.length || "0" }}/4</view
  691. >
  692. <view
  693. class="submit"
  694. :class="{
  695. disabled: !ansItem.ansText.text && hasImgs(ansItem),
  696. }"
  697. @click="submitAnsChild(bankIndex, ansIndex)"
  698. >确认答案</view
  699. >
  700. </view>
  701. <view class="textarea">
  702. <textarea
  703. v-model="ansItem.ansText.text"
  704. placeholder="在此输入答案"
  705. ></textarea>
  706. </view>
  707. <view class="imgs">
  708. <view
  709. class="img"
  710. v-for="(img, imgIndex) in ansItem.ansText.imageList"
  711. :key="imgIndex"
  712. >
  713. <text
  714. @click="
  715. deleteImgChild(imgIndex, bankIndex, ansIndex)
  716. "
  717. >x</text
  718. >
  719. <image :src="$method.splitImgHost(img, true)"></image>
  720. </view>
  721. </view>
  722. </view>
  723. <view
  724. class="ans_submit answerInfos"
  725. v-if="
  726. bankType == 1 &&
  727. bank.ques[ansIndex] &&
  728. (bank.ques[ansIndex].imageList.length ||
  729. bank.ques[ansIndex].text)
  730. "
  731. >
  732. <view class="answerTitle">我的答案</view>
  733. {{ bank.ques[ansIndex].text || "" }}
  734. <view class="imgs">
  735. <image
  736. class="img"
  737. v-for="(ques, quesIndex) in bank.ques[ansIndex]
  738. .imageList"
  739. :key="quesIndex"
  740. :src="$method.splitImgHost(ques, true)"
  741. ></image>
  742. </view>
  743. </view>
  744. </view>
  745. </view>
  746. <view
  747. v-if="
  748. bankType == 1 &&
  749. (bank.ques[ansIndex].imageList.length ||
  750. bank.ques[ansIndex].text)
  751. "
  752. >
  753. <view class="pad_8 answerInfos">
  754. <view class="answerTitle">答案解析</view>
  755. <view class="answerContent"
  756. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  757. ></view>
  758. </view>
  759. </view>
  760. </template>
  761. </view>
  762. </template>
  763. <view class="footer_btn">
  764. <view
  765. class="collect"
  766. :class="{ show: goodsId && !isFromVideo ? true : false }"
  767. @click="collect(collectList[bankIndex], bankIndex)"
  768. >
  769. <view v-if="collectList[bankIndex]">
  770. <image src="/static/icon/collected.png" mode=""></image>
  771. <view>取消收藏</view>
  772. </view>
  773. <view v-if="!collectList[bankIndex]">
  774. <image src="/static/icon/collect.png" mode=""></image>
  775. <view>收藏</view>
  776. </view>
  777. </view>
  778. <view class="flex_center" @click="openFooterTab">
  779. <view class="up-icon">
  780. <image src="/static/up.png"></image>
  781. </view>
  782. 答题卡
  783. </view>
  784. <view class="collect show" @click="pdsubmit">
  785. <view>
  786. <image src="/static/jj.png" mode=""></image>
  787. <view>交卷</view>
  788. </view>
  789. </view>
  790. </view>
  791. </view>
  792. </swiper-item>
  793. </swiper>
  794. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  795. <view class="popupView">
  796. <view class="popupTops">
  797. <view class="topIcon"></view>
  798. 点击编号即可跳转至对应题目
  799. </view>
  800. <view class="popupContent">
  801. <scroll-view scroll-y="true" style="height: 506rpx">
  802. <view class="boxSty">
  803. <view
  804. v-for="(item, index) in questionList"
  805. :key="index"
  806. @click="changeIndex(index)"
  807. :class="{
  808. isRight: bankType == 1 && isRight(item, index),
  809. isWrong: bankType == 1 && isWrong(item, index),
  810. isPart: bankType == 1 && isPart(item, index),
  811. isOver: bankType == 1 && isOver(item, index),
  812. check_ans: bankType == 2 && isCheck(item, index),
  813. }"
  814. class="liListSty"
  815. >
  816. {{ index + 1 }}
  817. </view>
  818. </view>
  819. </scroll-view>
  820. </view>
  821. </view>
  822. </u-popup>
  823. <view class="dialog" v-if="showDialog">
  824. <image class="pointer" src="/static/pointer.png" mode=""></image>
  825. <view class="text">左右滑动切换上下题</view>
  826. <view class="btn" @click="showDialog = false">我知道了</view>
  827. </view>
  828. <view class="dialog-arrow" v-if="showArrow">
  829. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  830. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  831. <view class="btn" @click="showArrow = false">我知道了</view>
  832. </view>
  833. <view class="dialog_wrap" v-if="testOver">
  834. <view class="bg"></view>
  835. <view class="dialog">
  836. <view class="title">温馨提示</view>
  837. <view class="content">
  838. <view>您已完成所有题目,</view>
  839. <view>快去交卷吧!</view>
  840. </view>
  841. <view class="btns">
  842. <view class="btn" @click="noSubmit()">暂不交卷</view>
  843. <view class="btn active" @click="submitNow()">立即交卷</view>
  844. </view>
  845. </view>
  846. </view>
  847. <view class="dialog_wrap" v-if="isLastCount">
  848. <view class="bg"></view>
  849. <view class="dialog">
  850. <view class="title">温馨提示</view>
  851. <view class="content">
  852. <view
  853. >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
  854. >
  855. </view>
  856. <view class="btns">
  857. <view class="btn" @click="noLeave()">暂不离开</view>
  858. <view class="btn active" @click="leaveNow()">继续离开</view>
  859. </view>
  860. </view>
  861. </view>
  862. <u-popup
  863. v-model="showpopups"
  864. mode="center"
  865. border-radius="24"
  866. height="439rpx"
  867. width="640rpx"
  868. :mask-close-able="false"
  869. >
  870. <view class="popboxs">
  871. <view class="classTops">温馨提示</view>
  872. <view class="textStys">
  873. {{
  874. cgType === 7
  875. ? "您还未交卷,确定结束做题吗?"
  876. : cgType === 8
  877. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  878. : cgType === 6
  879. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  880. : cgType == 9
  881. ? `您已完成所有题目,快去交卷吧!`
  882. : ""
  883. }}
  884. </view>
  885. <view class="classFootsty" v-if="cgType === 6">
  886. <view class="btnsty btns1" @click="submit">立即交卷</view>
  887. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  888. </view>
  889. <view class="classFootsty" v-if="cgType === 7">
  890. <view class="btnsty btns1" @click="backPages">下次继续</view>
  891. <view class="btnsty btns2" @click="submit">结束做题</view>
  892. </view>
  893. <view class="classFootsty" v-if="cgType === 8">
  894. <view class="btnsty btns1" @click="backPages()">下次继续</view>
  895. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  896. </view>
  897. <view class="classFootsty" v-if="cgType === 9">
  898. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  899. <view class="btnsty btns2" @click="submit">立即交卷</view>
  900. </view>
  901. </view>
  902. </u-popup>
  903. </view>
  904. </template>
  905. <script>
  906. export default {
  907. data() {
  908. return {
  909. showpopups: false,
  910. id: "",
  911. current: 0,
  912. questionList: [],
  913. ast: ["A", "B", "C", "D", "E", "F", "G"],
  914. judge: ["正确", "错误"],
  915. ans: [],
  916. ques: [],
  917. show: false,
  918. showDialog: false,
  919. bankList: [],
  920. collectList: [],
  921. goodsId: "",
  922. recordId: "",
  923. isSubmit: false,
  924. lastTime: 0, //剩余考试时长
  925. allTimes: 0, //总考试时长
  926. timer: null,
  927. wrongList: [],
  928. bankType: 0, //试卷类型
  929. needBack: false, //是否是考试
  930. testOver: false,
  931. isLastCount: false, //是否有未答题目
  932. lastCount: 0, //剩余没有回答的题目数
  933. chapterId: 0,
  934. moduleId: 0,
  935. showArrow: false, //退出提示
  936. isFromVideo: "",
  937. gradeId: "",
  938. examData: {},
  939. orderGoodsId: "",
  940. cgType: 0, //对应设计稿弹窗编码
  941. // courseId: '',
  942. entryType: "", // 进入做题页面的入口类型,daily-每日一练进来,random-随机练习, 其他的-题库做题进入
  943. bankNum: 5, // 随机练习的题目数量
  944. simulateExamId: undefined,
  945. };
  946. },
  947. async onLoad(option) {
  948. this.entryType = option.entryType || "";
  949. this.bankNum = option.bankNum;
  950. // this.courseId = option.courseId || ''
  951. this.orderGoodsId = option.orderGoodsId || 0;
  952. this.current = +option.current || 0;
  953. this.id = option.id;
  954. this.goodsId = option.goodsid;
  955. this.chapterId = option.chapterId || 0;
  956. this.moduleId = option.moduleId || 0;
  957. this.isFromVideo = option.isFromVideo || "";
  958. this.gradeId = option.gradeId || "";
  959. let isBack = option.isback;
  960. let showDialog = uni.getStorageSync("showDialog");
  961. if (showDialog) {
  962. this.showDialog = false;
  963. } else {
  964. this.showDialog = true;
  965. uni.setStorageSync("showDialog", "1");
  966. }
  967. //考试被迫返回
  968. if (isBack) {
  969. let app = getApp();
  970. let globalData = app.globalData;
  971. for (var k in globalData.bankData) {
  972. this[k] = globalData.bankData[k];
  973. }
  974. this.showArrow = true;
  975. this.timer = setInterval(() => {
  976. if (this.lastTime <= 0) {
  977. clearInterval(this.timer);
  978. uni.showToast({
  979. icon: "none",
  980. mask: true,
  981. title: "考试时间已到,系统将自动交卷",
  982. duration: 10000,
  983. });
  984. this.submit();
  985. return;
  986. }
  987. this.lastTime--;
  988. }, 1000);
  989. } else {
  990. if (this.entryType == "random") {
  991. this.bankType = 1; // 随机练习全部都是练习类型
  992. this.randomQuestionList();
  993. } else {
  994. //进入页面
  995. await this.bankExam();
  996. // 请求题目列表
  997. this.goodsQuestionList();
  998. }
  999. }
  1000. },
  1001. onUnload() {
  1002. if (this.isSubmit) {
  1003. clearInterval(this.timer);
  1004. return;
  1005. }
  1006. //考试试卷 阻止ios手势返回,自动跳回答题页
  1007. if (this.needBack) {
  1008. let app = getApp();
  1009. app.globalData.bankData = this.$data;
  1010. clearInterval(this.timer);
  1011. uni.navigateTo({
  1012. url:
  1013. "/pages2/bank/questionBank?id=" +
  1014. this.id +
  1015. "&goodsid=" +
  1016. this.goodsId +
  1017. "&isback=true&orderGoodsId=" +
  1018. this.orderGoodsId,
  1019. });
  1020. } else {
  1021. //点击返回按钮确认允许退出,记录答题记录
  1022. clearInterval(this.timer);
  1023. this.examRecordEdit();
  1024. }
  1025. },
  1026. methods: {
  1027. /**
  1028. * 是否有上传图片
  1029. */
  1030. hasImgs(bank) {
  1031. return bank.ansText.imageList.length == 0;
  1032. },
  1033. /**
  1034. * 获取试卷类型2考试,1练习
  1035. * bank/exam + data
  1036. */
  1037. bankExam() {
  1038. return new Promise((resolve) => {
  1039. this.$api.bankExam(this.id).then((res) => {
  1040. if (this.entryType == "daily") {
  1041. // 每日一练类型都是为练习
  1042. this.bankType = 1;
  1043. } else {
  1044. this.bankType = res.data.data.doType;
  1045. }
  1046. this.examData = res.data.data;
  1047. if (this.bankType == 2) {
  1048. this.needBack = true;
  1049. }
  1050. resolve();
  1051. });
  1052. });
  1053. },
  1054. /**
  1055. * 点击后退按钮
  1056. */
  1057. clickLeft() {
  1058. if (this.bankType == 1) {
  1059. let ansCount = this.questionOverNum(true); //已答题数
  1060. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1061. //所有题目答完
  1062. if (this.lastCount == 0) {
  1063. // this.testOver = true;
  1064. this.cgType = 7;
  1065. //未答完
  1066. } else {
  1067. this.cgType = 8;
  1068. // this.isLastCount = true;
  1069. }
  1070. this.showpopups = true;
  1071. } else if (this.bankType == 2) {
  1072. let ansCount = this.questionOverNum(true); //已答题数
  1073. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1074. //所有题目答完
  1075. if (this.lastCount == 0) {
  1076. this.testOver = true;
  1077. //未答完
  1078. } else {
  1079. this.isLastCount = true;
  1080. }
  1081. }
  1082. },
  1083. /**
  1084. * 返回上一页
  1085. */
  1086. backPages() {
  1087. this.needBack = false;
  1088. uni.navigateBack({
  1089. delta: 1,
  1090. });
  1091. },
  1092. /**
  1093. * 获取已经回答的题目数
  1094. * hasSpecail (是否包含简答和案例)
  1095. */
  1096. questionOverNum(hasSpecail) {
  1097. let count = 0;
  1098. this.questionList.forEach((item) => {
  1099. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1100. if (item.ques) {
  1101. count++;
  1102. }
  1103. } else if (item.type == 4) {
  1104. //案例题
  1105. if (hasSpecail) {
  1106. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1107. if (
  1108. jsonItem.type == 1 ||
  1109. jsonItem.type == 2 ||
  1110. jsonItem.type == 3
  1111. ) {
  1112. if (item.ques[indexs]) {
  1113. return true;
  1114. } else {
  1115. return false;
  1116. }
  1117. } else if (jsonItem.type == 5) {
  1118. if (
  1119. item.ques[indexs] &&
  1120. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  1121. ) {
  1122. console.log("chil");
  1123. return true;
  1124. } else {
  1125. return false;
  1126. }
  1127. }
  1128. });
  1129. if (isOver) {
  1130. count++;
  1131. }
  1132. }
  1133. } else if (item.type == 5) {
  1134. //简答题
  1135. if (hasSpecail) {
  1136. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  1137. console.log(5, item);
  1138. count++;
  1139. }
  1140. }
  1141. }
  1142. });
  1143. return count;
  1144. },
  1145. /**
  1146. * 是否做完所有题目
  1147. */
  1148. isDoOver() {
  1149. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1150. if (this.questionList.length == questionOverNum) {
  1151. //全部做完弹窗
  1152. this.cgType = 9;
  1153. this.showpopups = true;
  1154. }
  1155. },
  1156. /**
  1157. * 暂不交卷
  1158. */
  1159. noSubmit() {
  1160. //设为允许退出页面
  1161. this.needBack = false;
  1162. uni.navigateBack({
  1163. delta: 1,
  1164. });
  1165. },
  1166. /**
  1167. * 不离开
  1168. */
  1169. noLeave() {
  1170. this.isLastCount = false;
  1171. },
  1172. /**
  1173. * 立即离开并交卷
  1174. */
  1175. leaveNow() {
  1176. this.needBack = false;
  1177. this.isSubmit = true;
  1178. uni.navigateBack({
  1179. delta: 1,
  1180. });
  1181. let score = 0; //计算总分
  1182. let reportStatus = 0;
  1183. let number = 0; //做对的题目数量
  1184. let doQuestionNum = 0; //做过的题目数量
  1185. let allScore = 0; //总分
  1186. let passScore = 0;
  1187. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1188. let doQuestionIds = []; //做过的题目id
  1189. let lessQuestionNum = 0;
  1190. let rightQuestionIds = []; //做对的题目id
  1191. this.questionList.forEach((item, index) => {
  1192. // passScore = item.passScore
  1193. if (item.type == 1) {
  1194. //正确
  1195. if (item.ques == item.ans) {
  1196. item.scoreResult = item.score;
  1197. score += item.score;
  1198. number++;
  1199. rightQuestionIds.push(item.questionId);
  1200. } else {
  1201. //错误
  1202. item.scoreResult = 0;
  1203. if (item.ques) {
  1204. doWrongQuestionIds.push(item.questionId);
  1205. }
  1206. }
  1207. allScore += item.score;
  1208. if (item.ques) {
  1209. doQuestionNum++;
  1210. doQuestionIds.push(item.questionId);
  1211. }
  1212. } else if (item.type == 2) {
  1213. let isRight =
  1214. item.ans &&
  1215. item.ans.every((quesItem, quesIndex) => {
  1216. if (item.ques) {
  1217. return item.ques[quesIndex] == item.ans[quesIndex];
  1218. } else {
  1219. return false;
  1220. }
  1221. });
  1222. if (isRight) {
  1223. score += item.score;
  1224. number++;
  1225. item.scoreResult = item.score;
  1226. rightQuestionIds.push(item.questionId);
  1227. } else {
  1228. let hasPart = false;
  1229. let checkboxScore = 1; //获取单题总分数
  1230. item.ques &&
  1231. item.ques.forEach((ques, quesIndex) => {
  1232. //选错一个全扣
  1233. if (item.ques) {
  1234. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1235. checkboxScore = 0;
  1236. }
  1237. } else {
  1238. checkboxScore = 0;
  1239. }
  1240. });
  1241. console.log(checkboxScore);
  1242. //没选错
  1243. if (checkboxScore) {
  1244. checkboxScore = 0;
  1245. item.ans.forEach((ans, quesIndex) => {
  1246. //漏选只能得部分分数
  1247. if (item.ques) {
  1248. if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1249. checkboxScore = +item.partScore;
  1250. hasPart = true;
  1251. }
  1252. } else {
  1253. checkboxScore = 0;
  1254. }
  1255. });
  1256. }
  1257. if (!hasPart) {
  1258. //0分
  1259. item.scoreResult = 0;
  1260. if (item.ques) {
  1261. doWrongQuestionIds.push(item.questionId);
  1262. }
  1263. } else {
  1264. //部分分
  1265. // number++;
  1266. lessQuestionNum++;
  1267. // doWrongQuestionIds.push(item.questionId);
  1268. item.scoreResult = checkboxScore;
  1269. score += checkboxScore;
  1270. // rightQuestionIds.push(item.questionId)
  1271. }
  1272. }
  1273. allScore += item.score;
  1274. if (item.ques && item.ques.length) {
  1275. doQuestionNum++;
  1276. doQuestionIds.push(item.questionId);
  1277. }
  1278. } else if (item.type == 3) {
  1279. if (item.ques == item.ans) {
  1280. item.scoreResult = item.score;
  1281. score += item.score;
  1282. number++;
  1283. rightQuestionIds.push(item.questionId);
  1284. } else {
  1285. item.scoreResult = 0;
  1286. if (item.ques) {
  1287. doWrongQuestionIds.push(item.questionId);
  1288. }
  1289. }
  1290. allScore += item.score;
  1291. if (item.ques) {
  1292. doQuestionNum++;
  1293. doQuestionIds.push(item.questionId);
  1294. }
  1295. } else if (item.type == 4) {
  1296. allScore += item.score;
  1297. if (item.ques && item.ques.length) {
  1298. doQuestionNum++;
  1299. doQuestionIds.push(item.questionId);
  1300. }
  1301. } else if (item.type == 5) {
  1302. allScore += item.score;
  1303. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1304. doQuestionNum++;
  1305. doQuestionIds.push(item.questionId);
  1306. }
  1307. }
  1308. });
  1309. //大于60分及格
  1310. if (score >= 60) {
  1311. reportStatus = 1;
  1312. } else {
  1313. reportStatus = 0;
  1314. }
  1315. //交卷
  1316. this.$api
  1317. .examRecordEdit({
  1318. examId: this.id,
  1319. goodsId: this.goodsId,
  1320. orderGoodsId: this.orderGoodsId,
  1321. reportStatus: reportStatus,
  1322. recordId: this.recordId,
  1323. rightQuestionNum: number,
  1324. status: 1,
  1325. lessQuestionNum: lessQuestionNum,
  1326. moduleExamId: this.moduleId || 0,
  1327. chapterExamId: this.chapterId || 0,
  1328. doQuestionIds: doQuestionIds.join(","),
  1329. rightQuestionIds: rightQuestionIds.join(","),
  1330. doQuestionNum: doQuestionNum,
  1331. performance: score,
  1332. totalScore: allScore,
  1333. examTime: parseInt(this.allTimes),
  1334. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1335. historyExamJson: JSON.stringify(this.questionList),
  1336. })
  1337. .then((res) => {
  1338. this.isSubmit = true;
  1339. if (res.data.code == 200) {
  1340. this.entryType == "daily" && this.dailyExam();
  1341. }
  1342. });
  1343. //错题集id提交(客观题)
  1344. this.$api
  1345. .examWrongRecord({
  1346. orderGoodsId: this.orderGoodsId,
  1347. moduleExamId: this.moduleId || 0,
  1348. chapterExamId: this.chapterId || 0,
  1349. examId: this.id,
  1350. goodsId: this.goodsId,
  1351. questionIds: doWrongQuestionIds,
  1352. recordId: this.recordId,
  1353. type: 1, // 题库试卷传1
  1354. doMode: this.doMode,
  1355. })
  1356. .then((res) => {});
  1357. },
  1358. /**
  1359. * 立即交卷
  1360. */
  1361. submitNow() {
  1362. this.showpopups = false;
  1363. this.needBack = false;
  1364. this.submit();
  1365. },
  1366. /**
  1367. * 离开页面统计回答正确题数
  1368. */
  1369. examRecordEdit() {
  1370. if (!this.isSubmit) {
  1371. let number = 0;
  1372. let score = 0;
  1373. let doQuestionNum = 0;
  1374. let doQuestionIds = []; //做过的题目id
  1375. this.questionList.forEach((item, index) => {
  1376. if (item.type == 1) {
  1377. if (item.ques == item.ans) {
  1378. score += item.score;
  1379. number++;
  1380. }
  1381. if (item.ques) {
  1382. doQuestionNum++;
  1383. doQuestionIds.push(item.questionId);
  1384. }
  1385. } else if (item.type == 2) {
  1386. let isRight =
  1387. item.ans &&
  1388. item.ans.every((quesItem, quesIndex) => {
  1389. if (item.ques) {
  1390. return item.ques[quesIndex] == item.ans[quesIndex];
  1391. } else {
  1392. return false;
  1393. }
  1394. });
  1395. if (isRight) {
  1396. score += item.score;
  1397. number++;
  1398. } else {
  1399. let checkboxScore = 1; //获取单题总分数
  1400. item.ques &&
  1401. item.ques.forEach((ques, quesIndex) => {
  1402. //选错一个全扣
  1403. if (item.ques) {
  1404. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1405. checkboxScore = 0;
  1406. }
  1407. } else {
  1408. checkboxScore = 0;
  1409. }
  1410. });
  1411. console.log(checkboxScore);
  1412. //没选错
  1413. if (checkboxScore) {
  1414. checkboxScore = 0;
  1415. item.ans.forEach((ans, quesIndex) => {
  1416. //漏选扣一部分,对n题给n X partScore 分
  1417. if (item.ques) {
  1418. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  1419. checkboxScore += item.partScore;
  1420. }
  1421. } else {
  1422. checkboxScore = 0;
  1423. }
  1424. });
  1425. }
  1426. if (checkboxScore <= 0) {
  1427. //0分
  1428. } else {
  1429. //部分分
  1430. // number++;
  1431. score += checkboxScore;
  1432. }
  1433. }
  1434. if (item.ques && item.ques.length) {
  1435. doQuestionNum++;
  1436. doQuestionIds.push(item.questionId);
  1437. }
  1438. } else if (item.type == 3) {
  1439. if (item.ques == item.ans) {
  1440. score += item.score;
  1441. number++;
  1442. }
  1443. if (item.ques) {
  1444. doQuestionNum++;
  1445. doQuestionIds.push(item.questionId);
  1446. }
  1447. } else if (item == 4) {
  1448. if (item.ques.length) {
  1449. doQuestionNum++;
  1450. doQuestionIds.push(item.questionId);
  1451. }
  1452. } else if (item.type == 5) {
  1453. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1454. doQuestionNum++;
  1455. doQuestionIds.push(item.questionId);
  1456. }
  1457. }
  1458. });
  1459. this.$api
  1460. .examRecordEdit({
  1461. orderGoodsId: this.orderGoodsId,
  1462. examId: this.id,
  1463. goodsId: this.goodsId,
  1464. recordId: this.recordId,
  1465. doQuestionIds: doQuestionIds.join(","),
  1466. rightQuestionNum: number,
  1467. moduleExamId: this.moduleId || 0,
  1468. chapterExamId: this.chapterId || 0,
  1469. status: 0,
  1470. doQuestionNum: doQuestionNum,
  1471. historyExamJson: JSON.stringify(this.questionList),
  1472. })
  1473. .then((res) => {
  1474. if (res.data.code == 200) {
  1475. this.entryType == "daily" && this.dailyExam();
  1476. }
  1477. });
  1478. }
  1479. },
  1480. /**
  1481. * 记录总题数
  1482. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1483. */
  1484. examRecord(hasSpecial) {
  1485. let questionList = 0;
  1486. // if(!hasSpecial) {
  1487. this.questionList.forEach((item, index) => {
  1488. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1489. questionList++;
  1490. }
  1491. });
  1492. // } else {
  1493. // questionList = this.questionList.length;
  1494. // }
  1495. this.$api
  1496. .examRecord({
  1497. chapterExamId: this.chapterId || 0,
  1498. orderGoodsId: this.orderGoodsId,
  1499. moduleExamId: this.moduleId || 0,
  1500. examId: this.id,
  1501. goodsId: this.goodsId,
  1502. totalQuestionNum: questionList,
  1503. allQuestionNum: this.questionList.length,
  1504. doMode: this.doMode,
  1505. simulateExamId: this.simulateExamId,
  1506. })
  1507. .then((res) => {
  1508. this.recordId = res.data.data;
  1509. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1510. if (this.bankType == 1) {
  1511. this.examRecordEdit();
  1512. }
  1513. });
  1514. },
  1515. /**
  1516. * @param {Object} second倒计时过滤器
  1517. */
  1518. countdown(second) {
  1519. if (second) {
  1520. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1521. let m = parseInt((second / 60) % 60); // 计算分数
  1522. let s = parseInt(second % 60); // 计算当前秒数
  1523. if (h < 10) h = "0" + h;
  1524. if (m < 10) m = "0" + m;
  1525. if (s < 10) s = "0" + s;
  1526. return h + ":" + m + ":" + s;
  1527. } else {
  1528. return "";
  1529. }
  1530. },
  1531. hideDialog() {
  1532. this.showDialog = false;
  1533. },
  1534. // 请求随机练习题目列表
  1535. randomQuestionList() {
  1536. this.$http({
  1537. url: "/bank/exam/temp",
  1538. method: "post",
  1539. data: {
  1540. goodsId: this.goodsId,
  1541. orderGoodsId: this.orderGoodsId,
  1542. number: this.bankNum,
  1543. },
  1544. }).then((res) => {
  1545. if (res.data.code == 200) {
  1546. this.examData = res.data.data || {};
  1547. this.id = this.examData.examId;
  1548. if (!this.examData.questionList.length) {
  1549. this.hideDialog();
  1550. uni.showModal({
  1551. showCancel: false,
  1552. content: "该试卷暂无题目",
  1553. success: (k) => {
  1554. if (k.confirm) {
  1555. this.isSubmit = true;
  1556. uni.navigateBack();
  1557. }
  1558. },
  1559. });
  1560. return;
  1561. }
  1562. this.dataAnlyze(this.examData.questionList || []);
  1563. } else {
  1564. this.$u.toast(res.data.msg);
  1565. setTimeout(() => {
  1566. uni.navigateBack();
  1567. }, 2000);
  1568. }
  1569. });
  1570. },
  1571. /**
  1572. * 请求题目列表 app/common/bank/question/list
  1573. */
  1574. goodsQuestionList() {
  1575. this.$api[
  1576. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1577. ]({
  1578. examId: this.id,
  1579. goodsId: this.goodsId,
  1580. orderGoodsId: this.orderGoodsId,
  1581. from: 1,
  1582. }).then((res) => {
  1583. if (res.data.code == 500) {
  1584. uni.showModal({
  1585. showCancel: false,
  1586. content: "你已完成所有题目",
  1587. success: (k) => {
  1588. if (k.confirm) {
  1589. this.isSubmit = true;
  1590. uni.navigateBack();
  1591. }
  1592. },
  1593. });
  1594. return;
  1595. }
  1596. let data = res.data.data;
  1597. if (this.doMode == 3) {
  1598. this.simulateExamId = data.simulateExamId;
  1599. data = data.questionList;
  1600. }
  1601. if (!data.length) {
  1602. this.hideDialog();
  1603. uni.showModal({
  1604. showCancel: false,
  1605. content: "该试卷暂无题目",
  1606. success: (k) => {
  1607. if (k.confirm) {
  1608. this.isSubmit = true;
  1609. uni.navigateBack();
  1610. }
  1611. },
  1612. });
  1613. return;
  1614. }
  1615. this.allTimes = data[0].answerTime * 60;
  1616. this.lastTime = data[0].answerTime && data[0].answerTime * 60;
  1617. //考试时间到了自动交卷
  1618. if (this.lastTime) {
  1619. this.timer = setInterval(() => {
  1620. if (this.lastTime <= 0) {
  1621. clearInterval(this.timer);
  1622. uni.showToast({
  1623. icon: "none",
  1624. mask: true,
  1625. title: "考试时间已到,系统将自动交卷",
  1626. duration: 10000,
  1627. });
  1628. this.submit();
  1629. return;
  1630. }
  1631. this.lastTime--;
  1632. }, 1000);
  1633. } else {
  1634. }
  1635. this.dataAnlyze(data);
  1636. });
  1637. },
  1638. dataAnlyze(datas = []) {
  1639. console.log("datas:", datas);
  1640. datas.forEach((item, index) => {
  1641. // if (typeof item.jsonStr == 'string') {
  1642. item.jsonStr = JSON.parse(item.jsonStr);
  1643. if (item.type == 2) {
  1644. //多选
  1645. item.jsonStr.forEach((str) => {
  1646. str.optionsId = "" + str.optionsId;
  1647. });
  1648. let arr = item.answerQuestion.split(",");
  1649. arr.forEach((a, i) => {
  1650. arr[i] = "" + a;
  1651. });
  1652. item.ans = arr;
  1653. item.analysisContent &&
  1654. (item.analysisContent = item.analysisContent.replace(
  1655. /<img/gi,
  1656. '<img style="max-width:100%;"'
  1657. ));
  1658. item.content &&
  1659. (item.content = item.content.replace(
  1660. /<img/gi,
  1661. '<img style="max-width:100%;"'
  1662. ));
  1663. return;
  1664. } else if (item.type == 5) {
  1665. //简答题
  1666. item.ansText = {
  1667. text: "",
  1668. imageList: [],
  1669. };
  1670. item.ques = {
  1671. text: "",
  1672. imageList: [],
  1673. };
  1674. item.analysisContent &&
  1675. (item.analysisContent = item.analysisContent.replace(
  1676. /<img/gi,
  1677. '<img style="max-width:100%;"'
  1678. ));
  1679. item.content &&
  1680. (item.content = item.content.replace(
  1681. /<img/gi,
  1682. '<img style="max-width:100%;"'
  1683. ));
  1684. } else if (item.type == 4) {
  1685. //案例题
  1686. item.ques = [];
  1687. item.current = 0;
  1688. let ansArr = [];
  1689. item.jsonStr.forEach((json, index) => {
  1690. if (json.type == 1) {
  1691. ansArr[index] = json.answerQuestion;
  1692. json.content &&
  1693. (json.content = json.content.replace(
  1694. /<img/gi,
  1695. '<img style="max-width:100%;"'
  1696. ));
  1697. } else if (json.type == 2) {
  1698. json.optionsList.forEach((str) => {
  1699. str.optionsId = "" + str.optionsId;
  1700. });
  1701. let arr = json.answerQuestion.split(",");
  1702. arr.forEach((a, i) => {
  1703. arr[i] = "" + a;
  1704. });
  1705. ansArr[index] = arr;
  1706. json.content &&
  1707. (json.content = json.content.replace(
  1708. /<img/gi,
  1709. '<img style="max-width:100%;"'
  1710. ));
  1711. } else if (json.type == 3) {
  1712. ansArr[index] = json.answerQuestion;
  1713. json.content &&
  1714. (json.content = json.content.replace(
  1715. /<img/gi,
  1716. '<img style="max-width:100%;"'
  1717. ));
  1718. } else if (json.type == 5) {
  1719. ansArr[index] = {
  1720. text: json.answerQuestion,
  1721. imageList: [],
  1722. };
  1723. json.ansText = {
  1724. text: "",
  1725. imageList: [],
  1726. };
  1727. json.content &&
  1728. (json.content = json.content.replace(
  1729. /<img/gi,
  1730. '<img style="max-width:100%;"'
  1731. ));
  1732. }
  1733. });
  1734. item.analysisContent &&
  1735. (item.analysisContent = item.analysisContent.replace(
  1736. /<img/gi,
  1737. '<img style="max-width:100%;"'
  1738. ));
  1739. item.content &&
  1740. (item.content = item.content.replace(
  1741. /<img/gi,
  1742. '<img style="max-width:100%;"'
  1743. ));
  1744. item.ans = ansArr;
  1745. return;
  1746. }
  1747. item.analysisContent &&
  1748. (item.analysisContent = item.analysisContent.replace(
  1749. /<img/gi,
  1750. '<img style="max-width:100%;"'
  1751. ));
  1752. item.content &&
  1753. (item.content = item.content.replace(
  1754. /<img/gi,
  1755. '<img style="max-width:100%;"'
  1756. ));
  1757. item.ans = item.answerQuestion;
  1758. // }
  1759. });
  1760. this.questionList = datas;
  1761. this.lastCount = this.questionList.length;
  1762. this.examRecord();
  1763. this.getCollectInfo(this.current);
  1764. },
  1765. /**
  1766. * @param {Object} e单选点击
  1767. */
  1768. radioSelect(optionsId, bindex) {
  1769. // if (this.questionList[bindex].ques) return;
  1770. if (this.questionList[bindex].ques && this.bankType == 1) {
  1771. return;
  1772. }
  1773. this.$set(this.questionList[bindex], "ques", optionsId);
  1774. // if ((bindex + 1) < this.questionList.length) {
  1775. // this.current = bindex + 1
  1776. // }
  1777. this.isDoOver();
  1778. // 回答错误
  1779. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1780. // // /exam/wwrong/record
  1781. // this.$api
  1782. // .examWrongRecord({
  1783. // orderGoodsId: this.orderGoodsId,
  1784. // examId: this.id,
  1785. // goodsId: this.goodsId,
  1786. // moduleExamId: this.moduleId || 0,
  1787. // chapterExamId: this.chapterId || 0,
  1788. // questionIds: [this.questionList[bindex].questionId],
  1789. // recordId: this.recordId,
  1790. // })
  1791. // .then((res) => {});
  1792. // } else {
  1793. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1794. // // if(question) {
  1795. // // this.$api.wrongRecordDelete({
  1796. // // "examId": +this.id,
  1797. // // "goodsId": +this.goodsId,
  1798. // // "questionId": this.questionList[bindex].questionId,
  1799. // // }).then(res => {
  1800. // // })
  1801. // // }
  1802. // }
  1803. },
  1804. /**
  1805. * @param {Object} e案例单选点击
  1806. */
  1807. radioSelectChild(optionsId, ansIndex, bindex) {
  1808. // if (this.questionList[bindex].ques[ansIndex]) return;
  1809. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1810. return;
  1811. }
  1812. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1813. this.isDoOver();
  1814. },
  1815. /**
  1816. * @param {Object} 多选点击
  1817. */
  1818. checkboxSelect(optionsId, bindex, index) {
  1819. if (this.questionList[bindex].ques && this.bankType == 1) {
  1820. return;
  1821. }
  1822. this.$set(
  1823. this.questionList[bindex].jsonStr[index],
  1824. "checked",
  1825. !this.questionList[bindex].jsonStr[index].checked
  1826. );
  1827. },
  1828. /**
  1829. * @param {Object} 案例多选点击
  1830. */
  1831. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1832. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1833. return;
  1834. }
  1835. this.$set(
  1836. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1837. "checked",
  1838. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1839. .checked
  1840. );
  1841. },
  1842. isCheckboxChecked(arr) {
  1843. return arr.some((item) => {
  1844. if (item.checked) {
  1845. return true;
  1846. }
  1847. });
  1848. },
  1849. /**
  1850. * @param {Object} 多选确认
  1851. */
  1852. checkboxSubmit(bindex) {
  1853. // console.log('')
  1854. // if (this.questionList[bindex].ques) return;
  1855. if (this.questionList[bindex].ques && this.bankType == 1) {
  1856. return;
  1857. }
  1858. let arr = [];
  1859. this.questionList[bindex].jsonStr.forEach((item) => {
  1860. if (item.checked) {
  1861. arr.push(item.optionsId);
  1862. }
  1863. });
  1864. if (!arr.length) {
  1865. delete this.questionList[bindex].ques;
  1866. uni.showToast({
  1867. title: "请选择答案",
  1868. icon: "none",
  1869. });
  1870. return;
  1871. }
  1872. this.$set(this.questionList[bindex], "ques", arr);
  1873. this.$u.toast("已确认答案");
  1874. this.isDoOver();
  1875. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1876. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1877. // })
  1878. // // 回答错误
  1879. // if (isWrong) {
  1880. // this.$api
  1881. // .examWrongRecord({
  1882. // orderGoodsId: this.orderGoodsId,
  1883. // examId: this.id,
  1884. // goodsId: this.goodsId,
  1885. // moduleExamId: this.moduleId || 0,
  1886. // chapterExamId: this.chapterId || 0,
  1887. // questionIds: [this.questionList[bindex].questionId],
  1888. // recordId: this.recordId,
  1889. // })
  1890. // .then((res) => {});
  1891. // } else {
  1892. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1893. // // if(question) {
  1894. // // this.$api.wrongRecordDelete({
  1895. // // "examId": +this.id,
  1896. // // "goodsId": +this.goodsId,
  1897. // // "questionId": this.questionList[bindex].questionId,
  1898. // // }).then(res => {
  1899. // // })
  1900. // // }
  1901. // }
  1902. },
  1903. /**
  1904. * @param {Object} 案例多选确认
  1905. */
  1906. checkboxSubmitChild(bindex, ansIndex) {
  1907. // if (this.questionList[bindex].ques[ansIndex]) return;
  1908. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1909. return;
  1910. }
  1911. let arr = [];
  1912. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1913. (item) => {
  1914. if (item.checked) {
  1915. arr.push(item.optionsId);
  1916. }
  1917. }
  1918. );
  1919. if (!arr.length) {
  1920. delete this.questionList[bindex].ques[ansIndex];
  1921. uni.showToast({
  1922. title: "请选择答案",
  1923. icon: "none",
  1924. });
  1925. return;
  1926. }
  1927. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1928. this.$u.toast("已确认答案");
  1929. this.isDoOver();
  1930. },
  1931. /**
  1932. * @param {Object} index
  1933. * @param {Object} bindex
  1934. * 判断题
  1935. */
  1936. judgeSelect(index, bindex) {
  1937. // if (this.questionList[bindex].ques) return;
  1938. if (this.questionList[bindex].ques && this.bankType == 1) {
  1939. return;
  1940. } // 答案: 判断题1正确 0错误
  1941. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  1942. console.log(
  1943. "this.questionList[bindex]:",
  1944. this.questionList[bindex].ques,
  1945. this.questionList[bindex].ans
  1946. );
  1947. this.isDoOver();
  1948. // 回答错误
  1949. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1950. // this.$api
  1951. // .examWrongRecord({
  1952. // orderGoodsId: this.orderGoodsId,
  1953. // examId: this.id,
  1954. // goodsId: this.goodsId,
  1955. // moduleExamId: this.moduleId || 0,
  1956. // chapterExamId: this.chapterId || 0,
  1957. // questionIds: [this.questionList[bindex].questionId],
  1958. // recordId: this.recordId,
  1959. // })
  1960. // .then((res) => {});
  1961. // } else {
  1962. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1963. // // if(question) {
  1964. // // this.$api.wrongRecordDelete({
  1965. // // "examId": +this.id,
  1966. // // "goodsId": +this.goodsId,
  1967. // // "questionId": this.questionList[bindex].questionId,
  1968. // // }).then(res => {
  1969. // // })
  1970. // // }
  1971. // }
  1972. },
  1973. /**
  1974. * @param {Object} ansindex
  1975. * @param {Object} childindex
  1976. * @param {Object} bindex
  1977. * 案例判断题
  1978. */
  1979. judgeSelectChild(ansindex, childindex, bindex) {
  1980. // if (this.questionList[bindex].ques[ansindex]) return;
  1981. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  1982. return;
  1983. }
  1984. this.$set(
  1985. this.questionList[bindex].ques,
  1986. ansindex,
  1987. childindex == 0 ? "1" : "0"
  1988. );
  1989. this.isDoOver();
  1990. },
  1991. openFooterTab() {
  1992. this.show = true;
  1993. },
  1994. changeIndex(index) {
  1995. this.current = index;
  1996. },
  1997. swiperChange(e) {
  1998. this.current = e.detail.current;
  1999. this.getCollectInfo(this.current);
  2000. },
  2001. /**
  2002. * @param {Object} current
  2003. * 获取收藏信息
  2004. */
  2005. getCollectInfo(current) {
  2006. this.$api
  2007. .getCollectInfo({
  2008. examId: this.id,
  2009. questionId: this.questionList[current].questionId,
  2010. goodsId: this.goodsId,
  2011. orderGoodsId: this.orderGoodsId,
  2012. })
  2013. .then((res) => {
  2014. if (res.data.code == 500) {
  2015. this.$set(this.collectList, current, false);
  2016. } else if (res.data.code == 200) {
  2017. this.$set(this.collectList, current, res.data.data);
  2018. }
  2019. });
  2020. },
  2021. pdsubmit() {
  2022. // if (this.bankType == 1) {
  2023. let ansCount = this.questionOverNum(true); //已答题数
  2024. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2025. //没有答完
  2026. if (this.lastCount !== 0) {
  2027. this.cgType = 6;
  2028. this.showpopups = true;
  2029. return;
  2030. }
  2031. // }
  2032. if (this.bankType == 2) {
  2033. if (this.lastTime > 0) {
  2034. let lastTime = this.countdown(this.lastTime);
  2035. uni.showModal({
  2036. title: "提示",
  2037. content: `时间还剩余${lastTime},确定交卷吗?`,
  2038. confirmText: "交卷",
  2039. cancelText: "继续答题",
  2040. success: (res) => {
  2041. if (res.confirm) {
  2042. //确定
  2043. this.submit();
  2044. } else {
  2045. //取消
  2046. }
  2047. },
  2048. });
  2049. return;
  2050. }
  2051. }
  2052. this.submit();
  2053. },
  2054. /**
  2055. * 交卷
  2056. */
  2057. submit() {
  2058. let score = 0; //计算总分
  2059. let reportStatus = 0;
  2060. let number = 0; //做对的题目数量
  2061. let doQuestionNum = 0; //做过的题目数量
  2062. let allScore = 0; //总分
  2063. let passScore = 0;
  2064. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2065. let doQuestionIds = []; //做过的题目id
  2066. let lessQuestionNum = 0;
  2067. let rightQuestionIds = []; //做对的题目id
  2068. this.questionList.forEach((item, index) => {
  2069. passScore = item.passScore;
  2070. if (item.type == 1) {
  2071. //正确
  2072. if (item.ques == item.ans) {
  2073. item.scoreResult = item.score;
  2074. score += item.score;
  2075. number++;
  2076. rightQuestionIds.push(item.questionId);
  2077. } else {
  2078. //错误
  2079. item.scoreResult = 0;
  2080. if (item.ques) {
  2081. doWrongQuestionIds.push(item.questionId);
  2082. }
  2083. }
  2084. allScore += item.score;
  2085. if (item.ques) {
  2086. doQuestionNum++;
  2087. doQuestionIds.push(item.questionId);
  2088. }
  2089. } else if (item.type == 2) {
  2090. let isRight =
  2091. item.ans &&
  2092. item.ans.every((quesItem, quesIndex) => {
  2093. if (item.ques) {
  2094. return item.ques[quesIndex] == item.ans[quesIndex];
  2095. } else {
  2096. return false;
  2097. }
  2098. });
  2099. if (isRight) {
  2100. score += item.score;
  2101. number++;
  2102. item.scoreResult = item.score;
  2103. rightQuestionIds.push(item.questionId);
  2104. } else {
  2105. let hasPart = false;
  2106. let checkboxScore = 1; //获取单题总分数
  2107. item.ques &&
  2108. item.ques.forEach((ques, quesIndex) => {
  2109. //选错一个全扣
  2110. if (item.ques) {
  2111. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2112. checkboxScore = 0;
  2113. }
  2114. } else {
  2115. checkboxScore = 0;
  2116. }
  2117. });
  2118. //没选错
  2119. if (checkboxScore) {
  2120. checkboxScore = 0;
  2121. item.ans.forEach((ans, quesIndex) => {
  2122. //漏选扣一部分,对n题给n X partScore 分
  2123. if (item.ques) {
  2124. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2125. checkboxScore += item.partScore;
  2126. hasPart = true;
  2127. }
  2128. } else {
  2129. checkboxScore = 0;
  2130. }
  2131. });
  2132. }
  2133. if (!hasPart) {
  2134. //0分
  2135. item.scoreResult = 0;
  2136. if (item.ques) {
  2137. doWrongQuestionIds.push(item.questionId);
  2138. }
  2139. } else {
  2140. //部分分
  2141. // number++;
  2142. lessQuestionNum++;
  2143. // doWrongQuestionIds.push(item.questionId);
  2144. item.scoreResult = checkboxScore;
  2145. score += checkboxScore;
  2146. // rightQuestionIds.push(item.questionId)
  2147. }
  2148. }
  2149. allScore += item.score;
  2150. if (item.ques && item.ques.length) {
  2151. doQuestionNum++;
  2152. doQuestionIds.push(item.questionId);
  2153. }
  2154. } else if (item.type == 3) {
  2155. if (item.ques == item.ans) {
  2156. item.scoreResult = item.score;
  2157. score += item.score;
  2158. number++;
  2159. rightQuestionIds.push(item.questionId);
  2160. } else {
  2161. item.scoreResult = 0;
  2162. if (item.ques) {
  2163. doWrongQuestionIds.push(item.questionId);
  2164. }
  2165. }
  2166. allScore += item.score;
  2167. if (item.ques) {
  2168. doQuestionNum++;
  2169. doQuestionIds.push(item.questionId);
  2170. }
  2171. } else if (item.type == 4) {
  2172. allScore += item.score;
  2173. if (item.ques && item.ques.length) {
  2174. doQuestionNum++;
  2175. doQuestionIds.push(item.questionId);
  2176. }
  2177. } else if (item.type == 5) {
  2178. allScore += item.score;
  2179. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2180. doQuestionNum++;
  2181. doQuestionIds.push(item.questionId);
  2182. }
  2183. }
  2184. });
  2185. //大于及格
  2186. if (score >= passScore) {
  2187. reportStatus = 1;
  2188. } else {
  2189. reportStatus = 0;
  2190. }
  2191. //交卷
  2192. this.$api
  2193. .examRecordEdit({
  2194. // courseId: this.courseId,
  2195. examId: this.id,
  2196. goodsId: this.goodsId,
  2197. reportStatus: reportStatus,
  2198. recordId: this.recordId,
  2199. rightQuestionNum: number,
  2200. orderGoodsId: this.orderGoodsId,
  2201. status: 1,
  2202. lessQuestionNum: lessQuestionNum,
  2203. moduleExamId: this.moduleId || 0,
  2204. chapterExamId: this.chapterId || 0,
  2205. doQuestionIds: doQuestionIds.join(","),
  2206. rightQuestionIds: rightQuestionIds.join(","),
  2207. doQuestionNum: doQuestionNum,
  2208. performance: score,
  2209. totalScore: allScore,
  2210. examTime: parseInt(this.allTimes),
  2211. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2212. historyExamJson: JSON.stringify(this.questionList),
  2213. // type: ''
  2214. })
  2215. .then((res) => {
  2216. this.isSubmit = true;
  2217. if (res.data.code == 200) {
  2218. this.entryType == "daily" && this.dailyExam();
  2219. uni.showToast({
  2220. title: "交卷成功",
  2221. duration: 1000,
  2222. icon: "none",
  2223. });
  2224. setTimeout(() => {
  2225. uni.redirectTo({
  2226. url:
  2227. "/pages2/bank/question_report?goodsId=" +
  2228. this.goodsId +
  2229. "&chapterId=" +
  2230. this.chapterId +
  2231. "&moduleId=" +
  2232. this.moduleId +
  2233. "&examId=" +
  2234. this.id +
  2235. "&id=" +
  2236. this.recordId +
  2237. "&orderGoodsId=" +
  2238. this.orderGoodsId +
  2239. "&entryType=" +
  2240. this.entryType +
  2241. "&bankNum=" +
  2242. this.bankNum +
  2243. "&doMode=" +
  2244. this.doMode +
  2245. "&courseType=1",
  2246. });
  2247. }, 1000);
  2248. }
  2249. });
  2250. //错题集id提交(客观题)
  2251. this.$api
  2252. .examWrongRecord({
  2253. examId: this.id,
  2254. goodsId: this.goodsId,
  2255. orderGoodsId: this.orderGoodsId,
  2256. questionIds: doWrongQuestionIds,
  2257. recordId: this.recordId,
  2258. type: 1, // 题库试卷传1
  2259. doMode: this.doMode,
  2260. })
  2261. .then((res) => {});
  2262. },
  2263. // 每日一练试卷打卡
  2264. dailyExam() {
  2265. const dateStamp = parseInt(
  2266. new Date(new Date().toLocaleDateString()).getTime() / 1000
  2267. );
  2268. this.$http({
  2269. url: "/bank/question/special/exam/record",
  2270. method: "post",
  2271. data: {
  2272. examId: this.id,
  2273. chapterExamId: this.chapterId, // 章卷ID
  2274. moduleExamId: this.moduleId, //模块卷ID
  2275. goodsId: this.goodsId,
  2276. recordTime: dateStamp, // 传当天0点时间戳(秒)
  2277. },
  2278. }).then((res) => {
  2279. if (res.data.code == 200) {
  2280. }
  2281. });
  2282. },
  2283. /**
  2284. * @param {Object} state
  2285. * @param {Object} index
  2286. * 收藏
  2287. */
  2288. collect(state, index) {
  2289. if (!state) {
  2290. this.$api
  2291. .collectQuestion({
  2292. examId: this.id,
  2293. questionId: this.questionList[index].questionId,
  2294. goodsId: this.goodsId || "",
  2295. orderGoodsId: this.orderGoodsId,
  2296. doMode: this.doMode,
  2297. })
  2298. .then((res) => {
  2299. if (res.data.code == 200) {
  2300. this.$set(this.collectList, index, true);
  2301. uni.showToast({
  2302. title: "收藏成功",
  2303. duration: 2000,
  2304. icon: "none",
  2305. });
  2306. this.getCollectInfo(index);
  2307. }
  2308. });
  2309. } else {
  2310. this.$api
  2311. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2312. .then((res) => {
  2313. if (res.data.code == 200) {
  2314. this.$set(this.collectList, index, false);
  2315. uni.showToast({
  2316. title: "取消收藏成功",
  2317. duration: 2000,
  2318. icon: "none",
  2319. });
  2320. }
  2321. });
  2322. }
  2323. return;
  2324. },
  2325. /**
  2326. * @param {Object} imgIndex
  2327. * @param {Object} bankIndex
  2328. * 删除简答图片
  2329. */
  2330. deleteImg(imgIndex, bankIndex) {
  2331. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2332. },
  2333. /**
  2334. * @param {Object} imgIndex
  2335. * @param {Object} bankIndex
  2336. * @param {Object} ansIndex
  2337. * 删除案例题简答图片
  2338. */
  2339. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2340. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2341. imgIndex,
  2342. 1
  2343. );
  2344. },
  2345. /**
  2346. * @param {Object} bankindex
  2347. * 选择上传图片
  2348. */
  2349. chooseImg(bankindex) {
  2350. if (
  2351. this.questionList[bankindex] &&
  2352. this.questionList[bankindex].ansText &&
  2353. this.questionList[bankindex].ansText.imageList.length >= 4
  2354. ) {
  2355. uni.showToast({
  2356. icon: "none",
  2357. title: "最多选择4张",
  2358. });
  2359. return;
  2360. }
  2361. uni.chooseImage({
  2362. count: 1, //默认9
  2363. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2364. sourceType: ["album", "camera"], //从相册选择
  2365. success: (res) => {
  2366. let self = this;
  2367. // console.log(JSON.stringify(res.tempFilePaths));
  2368. let img = res.tempFilePaths[0];
  2369. uni.getImageInfo({
  2370. src: img,
  2371. success: async (res) => {
  2372. let canvasWidth = res.width; //图片原始长宽
  2373. let canvasHeight = res.height;
  2374. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2375. uni.compressImage({
  2376. src: img,
  2377. quality: 75,
  2378. width: "50%",
  2379. height: "50%",
  2380. success: async (rest) => {
  2381. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2382. this.questionList[bankindex].ansText.imageList.push(dir);
  2383. },
  2384. });
  2385. } else {
  2386. const dir = await self.uploadFile(img, 0);
  2387. this.questionList[bankindex].ansText.imageList.push(dir);
  2388. }
  2389. },
  2390. });
  2391. },
  2392. });
  2393. },
  2394. /**
  2395. * @param {Object} bankindex
  2396. * @param {Object} ansindex
  2397. * 案例题选择上传图片
  2398. */
  2399. chooseImgChild(bankindex, ansindex) {
  2400. if (
  2401. this.questionList[bankindex].jsonStr[ansindex] &&
  2402. this.questionList[bankindex].jsonStr[ansindex].ansText &&
  2403. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
  2404. .length >= 4
  2405. ) {
  2406. uni.showToast({
  2407. icon: "none",
  2408. title: "最多选择4张",
  2409. });
  2410. return;
  2411. }
  2412. uni.chooseImage({
  2413. count: 1, //默认9
  2414. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2415. sourceType: ["album", "camera"], //从相册选择
  2416. success: (res) => {
  2417. let self = this;
  2418. // console.log(JSON.stringify(res.tempFilePaths));
  2419. let img = res.tempFilePaths[0];
  2420. uni.getImageInfo({
  2421. src: img,
  2422. success: async (res) => {
  2423. let canvasWidth = res.width; //图片原始长宽
  2424. let canvasHeight = res.height;
  2425. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2426. uni.compressImage({
  2427. src: img,
  2428. quality: 75,
  2429. width: "50%",
  2430. height: "50%",
  2431. success: async (rest) => {
  2432. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2433. this.questionList[bankindex].jsonStr[
  2434. ansindex
  2435. ].ansText.imageList.push(dir);
  2436. },
  2437. });
  2438. } else {
  2439. const dir = await self.uploadFile(img, 0);
  2440. this.questionList[bankindex].jsonStr[
  2441. ansindex
  2442. ].ansText.imageList.push(dir);
  2443. }
  2444. },
  2445. });
  2446. },
  2447. });
  2448. },
  2449. uploadFile(options, int) {
  2450. var self = this;
  2451. return new Promise((resolve, reject) => {
  2452. var data = {
  2453. orderGoodsId: this.orderGoodsId,
  2454. imageStatus: int,
  2455. };
  2456. self.$api.aliyunpolicy(data).then((res) => {
  2457. console.log(res.data, 6);
  2458. if (res.data.code != 200) {
  2459. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  2460. return;
  2461. }
  2462. var ossToken = res.data.data.resultContent;
  2463. if (ossToken.host == null || ossToken.host == undefined) {
  2464. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  2465. return;
  2466. }
  2467. uni.uploadFile({
  2468. url: ossToken.host,
  2469. name: "file",
  2470. filePath: options,
  2471. fileType: "image",
  2472. header: {
  2473. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  2474. },
  2475. formData: {
  2476. key: ossToken.dir,
  2477. OSSAccessKeyId: ossToken.accessid,
  2478. policy: ossToken.policy,
  2479. Signature: ossToken.signature,
  2480. callback: ossToken.callback,
  2481. success_action_status: 200,
  2482. },
  2483. success: (result) => {
  2484. // if (result.statusCode === 200) {
  2485. resolve(ossToken.dir);
  2486. // } else {
  2487. // uni.showToast({
  2488. // title: "上传失败",
  2489. // icon: "none",
  2490. // });
  2491. // return;
  2492. // }
  2493. },
  2494. fail: (error) => {
  2495. uni.showToast({
  2496. title: "上传接口报错" + error,
  2497. icon: "none",
  2498. });
  2499. return;
  2500. },
  2501. });
  2502. });
  2503. });
  2504. },
  2505. /**
  2506. * @param {Object} type
  2507. * @param {Object} bankindex
  2508. * 简答题答案确认
  2509. */
  2510. submitAns(bankindex) {
  2511. if (
  2512. !this.questionList[bankindex].ansText.text &&
  2513. !this.questionList[bankindex].ansText.imageList.length
  2514. ) {
  2515. uni.showToast({
  2516. title: "请输入内容或上传图片",
  2517. duration: 2000,
  2518. icon: "none",
  2519. });
  2520. return;
  2521. }
  2522. this.$set(this.questionList[bankindex], "ques", {
  2523. imageList: this.questionList[bankindex].ansText.imageList || [],
  2524. text: this.questionList[bankindex].ansText.text || "",
  2525. });
  2526. this.$u.toast("已确认答案");
  2527. this.isDoOver();
  2528. },
  2529. /**
  2530. * @param {Object} bankindex
  2531. * @param {Object} ansindex
  2532. * 案例题简答答案确认
  2533. */
  2534. submitAnsChild(bankindex, ansindex) {
  2535. if (
  2536. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2537. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2538. ) {
  2539. uni.showToast({
  2540. title: "请输入内容或上传图片",
  2541. duration: 2000,
  2542. icon: "none",
  2543. });
  2544. return;
  2545. }
  2546. this.$set(this.questionList[bankindex].ques, ansindex, {
  2547. imageList:
  2548. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
  2549. [],
  2550. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
  2551. });
  2552. this.$u.toast("已确认答案");
  2553. this.isDoOver();
  2554. },
  2555. isCheck(item, index) {
  2556. if (this.questionList[index].ques) {
  2557. return true;
  2558. }
  2559. },
  2560. isRight(item, index) {
  2561. //单选
  2562. if (this.questionList[index].ques) {
  2563. if (item.type == 1) {
  2564. return this.questionList[index].ques == this.questionList[index].ans;
  2565. //多选
  2566. } else if (item.type == 2) {
  2567. //每一项都相等
  2568. return this.questionList[index].ans.every((item, i) => {
  2569. return item == this.questionList[index].ques[i];
  2570. });
  2571. //判断
  2572. } else if (item.type == 3) {
  2573. return this.questionList[index].ques == this.questionList[index].ans;
  2574. // } else if (item.type == 5) {
  2575. // if(this.questionList[index].ques.text){
  2576. // return true
  2577. // }else{
  2578. // return false
  2579. // }
  2580. } else {
  2581. return false;
  2582. }
  2583. } else {
  2584. return false;
  2585. }
  2586. },
  2587. right(bankIndex, ansIndex, option) {
  2588. if (
  2589. this.questionList[bankIndex].ques[ansIndex] &&
  2590. this.questionList[bankIndex].ans[ansIndex]
  2591. ) {
  2592. if (
  2593. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2594. option.optionsId
  2595. ) != -1 ||
  2596. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2597. option.optionsId
  2598. ) != -1
  2599. ) {
  2600. return true;
  2601. } else {
  2602. return false;
  2603. }
  2604. } else {
  2605. return false;
  2606. }
  2607. },
  2608. wrong(bankIndex, ansIndex, option) {
  2609. if (
  2610. this.questionList[bankIndex].ques[ansIndex] &&
  2611. this.questionList[bankIndex].ans[ansIndex]
  2612. ) {
  2613. if (
  2614. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2615. option.optionsId
  2616. ) != -1 &&
  2617. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2618. option.optionsId
  2619. ) == -1
  2620. ) {
  2621. return true;
  2622. } else {
  2623. return false;
  2624. }
  2625. } else {
  2626. return false;
  2627. }
  2628. },
  2629. isWrong(item, index) {
  2630. if (this.questionList[index].ques) {
  2631. //单选
  2632. if (item.type == 1) {
  2633. return this.questionList[index].ques != this.questionList[index].ans;
  2634. //多选
  2635. } else if (item.type == 2) {
  2636. //每一项都相等
  2637. return this.questionList[index].ques.some((item, i) => {
  2638. return this.questionList[index].ans.indexOf(item) == -1;
  2639. });
  2640. //判断
  2641. } else if (item.type == 3) {
  2642. return this.questionList[index].ques != this.questionList[index].ans;
  2643. } else {
  2644. return false;
  2645. }
  2646. } else {
  2647. return false;
  2648. }
  2649. },
  2650. isPart(item, index) {
  2651. if (this.questionList[index].ques) {
  2652. if (item.type == 2) {
  2653. let isWrong = this.questionList[index].ques.some((item, i) => {
  2654. return this.questionList[index].ans.indexOf(item) == -1;
  2655. });
  2656. let isRight = this.questionList[index].ans.every((item, i) => {
  2657. return item == this.questionList[index].ques[i];
  2658. });
  2659. if (!isRight && !isWrong) {
  2660. return true;
  2661. }
  2662. }
  2663. } else {
  2664. return false;
  2665. }
  2666. },
  2667. isOver(item, index) {
  2668. if (this.questionList[index].ques) {
  2669. if (item.type == 4) {
  2670. //案例题
  2671. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2672. if (
  2673. jsonItem.type == 1 ||
  2674. jsonItem.type == 2 ||
  2675. jsonItem.type == 3
  2676. ) {
  2677. if (item.ques[indexs]) {
  2678. return true;
  2679. } else {
  2680. return false;
  2681. }
  2682. } else if (jsonItem.type == 5) {
  2683. if (
  2684. item.ques[indexs] &&
  2685. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2686. ) {
  2687. console.log("chil");
  2688. return true;
  2689. } else {
  2690. return false;
  2691. }
  2692. }
  2693. });
  2694. if (isOver) {
  2695. return true;
  2696. } else {
  2697. return false;
  2698. }
  2699. } else if (item.type == 5) {
  2700. //简答题
  2701. //每一项都相等
  2702. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2703. return true;
  2704. }
  2705. //判断
  2706. } else {
  2707. return false;
  2708. }
  2709. } else {
  2710. return false;
  2711. }
  2712. },
  2713. tabSelect(index, bankindex) {
  2714. this.$set(this.questionList[bankindex], "current", index);
  2715. },
  2716. showPhoto(contentStr) {
  2717. if (contentStr && typeof contentStr == "string") {
  2718. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  2719. let strArr = contentStr.match(reg);
  2720. strArr.forEach((str, index) => {
  2721. strArr[index] = str.replace(reg, "$1");
  2722. });
  2723. // 预览图片
  2724. uni.previewImage({
  2725. urls: strArr,
  2726. longPressActions: {
  2727. itemList: ["发送给朋友", "保存图片", "收藏"],
  2728. success: function (data) {
  2729. console.log(
  2730. "选中了第" +
  2731. (data.tapIndex + 1) +
  2732. "个按钮,第" +
  2733. (data.index + 1) +
  2734. "张图片"
  2735. );
  2736. },
  2737. fail: function (err) {
  2738. console.log(err.errMsg);
  2739. },
  2740. },
  2741. });
  2742. }
  2743. },
  2744. },
  2745. computed: {
  2746. doMode() {
  2747. // 做题模式 1章卷 2随机练习 3模拟组卷
  2748. return this.examData.simulateStatus
  2749. ? 3
  2750. : this.entryType == "random"
  2751. ? 2
  2752. : 1;
  2753. },
  2754. },
  2755. };
  2756. </script>
  2757. <style lang="scss" scoped>
  2758. .questionBank {
  2759. width: 100%;
  2760. height: 100vh;
  2761. display: flex;
  2762. flex-direction: column;
  2763. }
  2764. .swiper {
  2765. width: 100%;
  2766. flex: 1;
  2767. }
  2768. .lisSty {
  2769. margin-bottom: 16rpx;
  2770. display: flex;
  2771. align-items: center;
  2772. .flex_auto {
  2773. word-break: break-all;
  2774. flex: 1;
  2775. }
  2776. }
  2777. .activeTI {
  2778. vertical-align: middle;
  2779. display: inline-block;
  2780. border: 1rpx solid #eee;
  2781. border-radius: 50rpx;
  2782. height: 48rpx;
  2783. line-height: 46rpx;
  2784. text-align: center;
  2785. width: 48rpx;
  2786. margin-right: 15rpx;
  2787. color: #666;
  2788. font-size: 30rpx;
  2789. &.right {
  2790. color: #fff;
  2791. background: #36c75a;
  2792. }
  2793. &.wrong {
  2794. color: #fff;
  2795. background: #ff3b30;
  2796. }
  2797. &.checked,
  2798. &.user_choose {
  2799. color: #fff;
  2800. background: #007aff;
  2801. }
  2802. }
  2803. .submit_checkbox {
  2804. position: fixed;
  2805. left: 0;
  2806. right: 0;
  2807. bottom: 120rpx;
  2808. margin: 20rpx auto;
  2809. width: 526rpx;
  2810. height: 80rpx;
  2811. background: rgba(0, 122, 255, 1);
  2812. color: #fff;
  2813. text-align: center;
  2814. line-height: 80rpx;
  2815. font-size: 30rpx;
  2816. border-radius: 40rpx;
  2817. &.disabled {
  2818. opacity: 0.6;
  2819. }
  2820. }
  2821. .titles {
  2822. overflow: hidden;
  2823. margin-bottom: 24rpx;
  2824. }
  2825. .titBox {
  2826. padding: 41rpx 25rpx 24rpx 25rpx;
  2827. }
  2828. .titBox_title {
  2829. padding: 21rpx;
  2830. }
  2831. .tabs {
  2832. margin: 10rpx;
  2833. display: flex;
  2834. .tab {
  2835. margin: 0 4rpx;
  2836. padding: 10rpx 13rpx;
  2837. text-align: center;
  2838. color: #007aff;
  2839. font-size: 28rpx;
  2840. border-radius: 16rpx;
  2841. background: #fff;
  2842. &.current {
  2843. color: #fff;
  2844. background: #007aff;
  2845. }
  2846. }
  2847. }
  2848. .ans {
  2849. margin: 8rpx 8rpx 8rpx;
  2850. .ans_input {
  2851. border-radius: 16rpx;
  2852. background: #fff;
  2853. .top {
  2854. border-bottom: 1rpx solid #eeeeee;
  2855. padding: 16rpx;
  2856. display: flex;
  2857. align-items: center;
  2858. .icon {
  2859. margin-right: 20rpx;
  2860. width: 40rpx;
  2861. height: 38rpx;
  2862. }
  2863. .progress {
  2864. flex: 1;
  2865. }
  2866. .submit {
  2867. width: 168rpx;
  2868. height: 48rpx;
  2869. line-height: 48rpx;
  2870. text-align: center;
  2871. color: #fff;
  2872. font-size: 30rpx;
  2873. background: #007aff;
  2874. border-radius: 24rpx;
  2875. &.disabled {
  2876. opacity: 0.6;
  2877. }
  2878. }
  2879. }
  2880. .textarea {
  2881. textarea {
  2882. width: 100%;
  2883. height: 287rpx;
  2884. padding: 10rpx;
  2885. }
  2886. }
  2887. .imgs {
  2888. overflow: hidden;
  2889. display: flex;
  2890. width: 100%;
  2891. .img {
  2892. width: 104rpx;
  2893. height: 104rpx;
  2894. border-radius: 8rpx;
  2895. position: relative;
  2896. margin: 20rpx;
  2897. text {
  2898. position: absolute;
  2899. right: -15rpx;
  2900. top: -15rpx;
  2901. width: 30rpx;
  2902. height: 30rpx;
  2903. text-align: center;
  2904. line-height: 30rpx;
  2905. color: #fff;
  2906. background: #ff3b30;
  2907. border-radius: 50%;
  2908. }
  2909. image {
  2910. width: 100%;
  2911. height: 100%;
  2912. }
  2913. }
  2914. }
  2915. }
  2916. .ans_submit {
  2917. padding: 16rpx;
  2918. border-radius: 16rpx;
  2919. background: #fff;
  2920. .imgs {
  2921. overflow: hidden;
  2922. display: flex;
  2923. width: 100%;
  2924. .img {
  2925. width: 104rpx;
  2926. height: 104rpx;
  2927. border-radius: 8rpx;
  2928. position: relative;
  2929. margin: 20rpx;
  2930. image {
  2931. width: 100%;
  2932. height: 100%;
  2933. }
  2934. }
  2935. }
  2936. }
  2937. }
  2938. .leftLetters {
  2939. display: flex;
  2940. align-items: center;
  2941. width: 220rpx;
  2942. .btnType {
  2943. padding: 5rpx 10rpx;
  2944. border: 1rpx solid #007aff;
  2945. border-radius: 10rpx;
  2946. background-color: rgba(0, 122, 255, 0.1);
  2947. font-size: 28rpx;
  2948. color: #007aff;
  2949. margin-right: 15rpx;
  2950. }
  2951. }
  2952. .firstLetter {
  2953. display: flex;
  2954. justify-content: space-between;
  2955. align-items: center;
  2956. margin-bottom: 30rpx;
  2957. }
  2958. .popupView {
  2959. height: 100%;
  2960. padding-bottom: 100rpx;
  2961. .popupTops {
  2962. height: 77rpx;
  2963. border-bottom: 1rpx solid #eee;
  2964. text-align: center;
  2965. line-height: 77rpx;
  2966. font-size: 24rpx;
  2967. color: #999;
  2968. position: relative;
  2969. .topIcon {
  2970. position: absolute;
  2971. top: 10rpx;
  2972. left: 50%;
  2973. transform: translateX(-50%);
  2974. width: 80rpx;
  2975. height: 8rpx;
  2976. background-color: #999;
  2977. border-radius: 4rpx;
  2978. }
  2979. }
  2980. .popupContent {
  2981. }
  2982. }
  2983. .pageContent {
  2984. position: relative;
  2985. background-color: #eaeef1;
  2986. height: 100%;
  2987. padding-top: 8rpx;
  2988. padding-bottom: 100rpx;
  2989. overflow-y: scroll;
  2990. }
  2991. .pad_8 {
  2992. background-color: #fff;
  2993. margin: 0rpx 8rpx 8rpx;
  2994. border-radius: 16rpx;
  2995. &.no-margin {
  2996. margin-top: -16rpx;
  2997. border-radius: 0 0 16rpx 16rpx;
  2998. }
  2999. }
  3000. .answer {
  3001. height: 80rpx;
  3002. line-height: 80rpx;
  3003. padding: 0rpx 24rpx;
  3004. display: flex;
  3005. align-items: center;
  3006. justify-content: space-between;
  3007. color: #666;
  3008. font-size: 30rpx;
  3009. }
  3010. .footer_btn {
  3011. background-color: #fff;
  3012. z-index: 10078;
  3013. position: fixed;
  3014. bottom: 0rpx;
  3015. display: flex;
  3016. align-items: center;
  3017. justify-content: space-between;
  3018. width: 100%;
  3019. height: 98rpx;
  3020. padding: 0rpx 38rpx;
  3021. border-top: 1rpx solid #eee;
  3022. .flex_center {
  3023. flex: 1;
  3024. display: flex;
  3025. justify-content: center;
  3026. align-items: center;
  3027. flex-direction: column;
  3028. margin: 0 200rpx;
  3029. font-size: 24rpx;
  3030. color: #999999;
  3031. .up-icon {
  3032. margin-bottom: 18rpx;
  3033. width: 100%;
  3034. display: flex;
  3035. justify-content: center;
  3036. image {
  3037. width: 58rpx;
  3038. height: 21rpx;
  3039. }
  3040. }
  3041. }
  3042. .collect {
  3043. visibility: hidden;
  3044. width: 100rpx;
  3045. &.show {
  3046. visibility: visible;
  3047. }
  3048. > view {
  3049. display: flex;
  3050. flex-direction: column;
  3051. align-items: center;
  3052. justify-content: center;
  3053. image {
  3054. width: 32rpx;
  3055. height: 32rpx;
  3056. margin-bottom: 6rpx;
  3057. }
  3058. view {
  3059. font-size: 24rpx;
  3060. color: #999999;
  3061. }
  3062. }
  3063. }
  3064. }
  3065. .boxSty {
  3066. padding: 44rpx 41rpx 0rpx;
  3067. }
  3068. .liListSty {
  3069. border: 1rpx solid #eeeeee;
  3070. width: 88rpx;
  3071. height: 88rpx;
  3072. border-radius: 32rpx;
  3073. text-align: center;
  3074. line-height: 88rpx;
  3075. color: #333;
  3076. font-size: 32rpx;
  3077. float: left;
  3078. margin: 20rpx 23rpx;
  3079. &.isRight {
  3080. border: 1rpx solid #eeeeee;
  3081. color: #fff;
  3082. background: #36c75a;
  3083. }
  3084. &.isWrong {
  3085. border: 1rpx solid #eeeeee;
  3086. color: #fff;
  3087. background: #ff3b30;
  3088. }
  3089. &.isPart {
  3090. border: 1rpx solid #eeeeee;
  3091. color: #fff;
  3092. background: #ffc53d;
  3093. }
  3094. &.isOver {
  3095. border: 1rpx solid #eeeeee;
  3096. color: #fff;
  3097. background: blue;
  3098. }
  3099. &.check_ans {
  3100. border: 1rpx solid #eeeeee;
  3101. color: #fff;
  3102. background: #007aff;
  3103. }
  3104. }
  3105. .answerInfos {
  3106. padding: 25rpx 25rpx 25rpx 23rpx;
  3107. }
  3108. .answerTitle {
  3109. margin-bottom: 28rpx;
  3110. color: #666;
  3111. font-size: 30rpx;
  3112. }
  3113. .answerContent {
  3114. font-size: 30rpx;
  3115. color: #666;
  3116. }
  3117. .textChild {
  3118. display: inline-block;
  3119. vertical-align: middle;
  3120. }
  3121. .dialog {
  3122. position: fixed;
  3123. left: 0;
  3124. top: 0;
  3125. width: 100%;
  3126. height: 100%;
  3127. background-color: rgba(0, 0, 0, 0.8);
  3128. display: flex;
  3129. flex-direction: column;
  3130. align-items: center;
  3131. justify-content: center;
  3132. z-index: 20000;
  3133. .pointer {
  3134. width: 338rpx;
  3135. height: 240rpx;
  3136. }
  3137. .text {
  3138. font-size: 32rpx;
  3139. color: #ffffff;
  3140. text-align: center;
  3141. }
  3142. .btn {
  3143. width: 242rpx;
  3144. height: 82rpx;
  3145. border: 2rpx solid #ffffff;
  3146. border-radius: 16rpx;
  3147. text-align: center;
  3148. line-height: 82rpx;
  3149. margin: 41rpx auto;
  3150. color: #fff;
  3151. font-size: 32rpx;
  3152. }
  3153. }
  3154. .dialog-arrow {
  3155. padding-top: 124rpx;
  3156. position: fixed;
  3157. left: 0;
  3158. top: 0;
  3159. width: 100%;
  3160. height: 100%;
  3161. background-color: rgba(0, 0, 0, 0.8);
  3162. z-index: 20000;
  3163. .pointer {
  3164. margin-left: 87rpx;
  3165. display: block;
  3166. width: 95rpx;
  3167. height: 98rpx;
  3168. }
  3169. .text {
  3170. padding-left: 177rpx;
  3171. font-size: 32rpx;
  3172. color: #ffffff;
  3173. }
  3174. .btn {
  3175. width: 242rpx;
  3176. height: 82rpx;
  3177. border: 2rpx solid #ffffff;
  3178. border-radius: 16rpx;
  3179. text-align: center;
  3180. line-height: 82rpx;
  3181. margin: 500rpx auto 0;
  3182. color: #fff;
  3183. font-size: 32rpx;
  3184. }
  3185. }
  3186. .dialog_wrap {
  3187. position: fixed;
  3188. left: 0;
  3189. top: 0;
  3190. width: 100%;
  3191. height: 100%;
  3192. z-index: 9999999999;
  3193. .bg {
  3194. background: rgba(0, 0, 0, 0.3);
  3195. position: absolute;
  3196. left: 0;
  3197. top: 0;
  3198. width: 100%;
  3199. height: 100%;
  3200. }
  3201. .dialog {
  3202. position: absolute;
  3203. left: 50%;
  3204. top: 50%;
  3205. transform: translate3D(-50%, -50%, 0);
  3206. width: 640rpx;
  3207. height: 439rpx;
  3208. background: #ffffff;
  3209. border-radius: 24rpx;
  3210. .title {
  3211. font-size: 30rpx;
  3212. font-weight: bold;
  3213. color: #333333;
  3214. line-height: 48rpx;
  3215. text-align: center;
  3216. margin-top: 40rpx;
  3217. }
  3218. .content {
  3219. margin: 35rpx 35rpx 0;
  3220. font-size: 30rpx;
  3221. color: #666666;
  3222. line-height: 48rpx;
  3223. }
  3224. .btns {
  3225. margin-top: 35rpx;
  3226. display: flex;
  3227. align-items: center;
  3228. justify-content: center;
  3229. .btn {
  3230. width: 200rpx;
  3231. height: 80rpx;
  3232. line-height: 80rpx;
  3233. text-align: center;
  3234. background: #f5f5f5;
  3235. border-radius: 40rpx;
  3236. font-size: 30rpx;
  3237. color: rgba(0, 122, 255, 1);
  3238. background: #f5f5f5;
  3239. margin: 0 20rpx;
  3240. &.active {
  3241. color: #f5f5f5;
  3242. background: rgba(0, 122, 255, 1);
  3243. }
  3244. }
  3245. }
  3246. }
  3247. }
  3248. .popboxs {
  3249. width: 100%;
  3250. height: 100%;
  3251. display: flex;
  3252. flex-direction: column;
  3253. align-items: center;
  3254. }
  3255. .classTops {
  3256. flex-shrink: 0;
  3257. padding: 39rpx 0rpx 4rpx;
  3258. font-weight: bold;
  3259. color: #333;
  3260. font-size: 30rpx;
  3261. }
  3262. .textStys {
  3263. width: 100%;
  3264. flex: 1;
  3265. padding: 36rpx;
  3266. }
  3267. .classFootsty {
  3268. flex-shrink: 0;
  3269. display: flex;
  3270. align-items: center;
  3271. justify-content: center;
  3272. padding: 10rpx 0rpx 40rpx;
  3273. .btnsty {
  3274. width: 200rpx;
  3275. height: 80rpx;
  3276. border-radius: 40rpx;
  3277. font-weight: bold;
  3278. font-size: 30rpx;
  3279. text-align: center;
  3280. line-height: 80rpx;
  3281. }
  3282. .btns1 {
  3283. background-color: #f5f5f5;
  3284. color: #007aff;
  3285. }
  3286. .btns2 {
  3287. margin-left: 40rpx;
  3288. background-color: #007aff;
  3289. color: #ffffff;
  3290. }
  3291. }
  3292. </style>