questionBank.vue 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421
  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. item.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. console.log(item, 444);
  1132. }
  1133. }
  1134. } else if (item.type == 5) {
  1135. //简答题
  1136. if (hasSpecail) {
  1137. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  1138. console.log(5, item);
  1139. count++;
  1140. }
  1141. }
  1142. }
  1143. });
  1144. return count;
  1145. },
  1146. /**
  1147. * 是否做完所有题目
  1148. */
  1149. isDoOver() {
  1150. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1151. if (this.questionList.length == questionOverNum) {
  1152. //全部做完弹窗
  1153. this.cgType = 9;
  1154. this.showpopups = true;
  1155. }
  1156. },
  1157. /**
  1158. * 暂不交卷
  1159. */
  1160. noSubmit() {
  1161. //设为允许退出页面
  1162. this.needBack = false;
  1163. uni.navigateBack({
  1164. delta: 1,
  1165. });
  1166. },
  1167. /**
  1168. * 不离开
  1169. */
  1170. noLeave() {
  1171. this.isLastCount = false;
  1172. },
  1173. /**
  1174. * 立即离开并交卷
  1175. */
  1176. leaveNow() {
  1177. this.needBack = false;
  1178. this.isSubmit = true;
  1179. uni.navigateBack({
  1180. delta: 1,
  1181. });
  1182. let score = 0; //计算总分
  1183. let reportStatus = 0;
  1184. let number = 0; //做对的题目数量
  1185. let doQuestionNum = 0; //做过的题目数量
  1186. let allScore = 0; //总分
  1187. let passScore = 0;
  1188. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1189. let doQuestionIds = []; //做过的题目id
  1190. let lessQuestionNum = 0;
  1191. let rightQuestionIds = []; //做对的题目id
  1192. this.questionList.forEach((item, index) => {
  1193. // passScore = item.passScore
  1194. if (item.type == 1) {
  1195. //正确
  1196. if (item.ques == item.ans) {
  1197. item.scoreResult = item.score;
  1198. score += item.score;
  1199. number++;
  1200. rightQuestionIds.push(item.questionId);
  1201. } else {
  1202. //错误
  1203. item.scoreResult = 0;
  1204. if (item.ques) {
  1205. doWrongQuestionIds.push(item.questionId);
  1206. }
  1207. }
  1208. allScore += item.score;
  1209. if (item.ques) {
  1210. doQuestionNum++;
  1211. doQuestionIds.push(item.questionId);
  1212. }
  1213. } else if (item.type == 2) {
  1214. let isRight =
  1215. item.ans &&
  1216. item.ans.every((quesItem, quesIndex) => {
  1217. if (item.ques) {
  1218. return item.ques[quesIndex] == item.ans[quesIndex];
  1219. } else {
  1220. return false;
  1221. }
  1222. });
  1223. if (isRight) {
  1224. score += item.score;
  1225. number++;
  1226. item.scoreResult = item.score;
  1227. rightQuestionIds.push(item.questionId);
  1228. } else {
  1229. let hasPart = false;
  1230. let checkboxScore = 1; //获取单题总分数
  1231. item.ques &&
  1232. item.ques.forEach((ques, quesIndex) => {
  1233. //选错一个全扣
  1234. if (item.ques) {
  1235. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1236. checkboxScore = 0;
  1237. }
  1238. } else {
  1239. checkboxScore = 0;
  1240. }
  1241. });
  1242. console.log(checkboxScore);
  1243. //没选错
  1244. if (checkboxScore) {
  1245. checkboxScore = 0;
  1246. item.ans.forEach((ans, quesIndex) => {
  1247. //漏选只能得部分分数
  1248. if (item.ques) {
  1249. if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1250. checkboxScore = +item.partScore;
  1251. hasPart = true;
  1252. }
  1253. } else {
  1254. checkboxScore = 0;
  1255. }
  1256. });
  1257. }
  1258. if (!hasPart) {
  1259. //0分
  1260. item.scoreResult = 0;
  1261. if (item.ques) {
  1262. doWrongQuestionIds.push(item.questionId);
  1263. }
  1264. } else {
  1265. //部分分
  1266. // number++;
  1267. lessQuestionNum++;
  1268. // doWrongQuestionIds.push(item.questionId);
  1269. item.scoreResult = checkboxScore;
  1270. score += checkboxScore;
  1271. // rightQuestionIds.push(item.questionId)
  1272. }
  1273. }
  1274. allScore += item.score;
  1275. if (item.ques && item.ques.length) {
  1276. doQuestionNum++;
  1277. doQuestionIds.push(item.questionId);
  1278. }
  1279. } else if (item.type == 3) {
  1280. if (item.ques == item.ans) {
  1281. item.scoreResult = item.score;
  1282. score += item.score;
  1283. number++;
  1284. rightQuestionIds.push(item.questionId);
  1285. } else {
  1286. item.scoreResult = 0;
  1287. if (item.ques) {
  1288. doWrongQuestionIds.push(item.questionId);
  1289. }
  1290. }
  1291. allScore += item.score;
  1292. if (item.ques) {
  1293. doQuestionNum++;
  1294. doQuestionIds.push(item.questionId);
  1295. }
  1296. } else if (item.type == 4) {
  1297. allScore += item.score;
  1298. if (item.ques && item.ques.length) {
  1299. doQuestionNum++;
  1300. doQuestionIds.push(item.questionId);
  1301. }
  1302. } else if (item.type == 5) {
  1303. allScore += item.score;
  1304. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1305. doQuestionNum++;
  1306. doQuestionIds.push(item.questionId);
  1307. }
  1308. }
  1309. });
  1310. //大于60分及格
  1311. if (score >= 60) {
  1312. reportStatus = 1;
  1313. } else {
  1314. reportStatus = 0;
  1315. }
  1316. //交卷
  1317. this.$api
  1318. .examRecordEdit({
  1319. examId: this.id,
  1320. goodsId: this.goodsId,
  1321. orderGoodsId: this.orderGoodsId,
  1322. reportStatus: reportStatus,
  1323. recordId: this.recordId,
  1324. rightQuestionNum: number,
  1325. status: 1,
  1326. lessQuestionNum: lessQuestionNum,
  1327. moduleExamId: this.moduleId || 0,
  1328. chapterExamId: this.chapterId || 0,
  1329. doQuestionIds: doQuestionIds.join(","),
  1330. rightQuestionIds: rightQuestionIds.join(","),
  1331. doQuestionNum: doQuestionNum,
  1332. performance: score,
  1333. totalScore: allScore,
  1334. examTime: parseInt(this.allTimes),
  1335. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1336. historyExamJson: JSON.stringify(this.questionList),
  1337. })
  1338. .then((res) => {
  1339. this.isSubmit = true;
  1340. if (res.data.code == 200) {
  1341. this.entryType == "daily" && this.dailyExam();
  1342. }
  1343. });
  1344. //错题集id提交(客观题)
  1345. this.$api
  1346. .examWrongRecord({
  1347. orderGoodsId: this.orderGoodsId,
  1348. moduleExamId: this.moduleId || 0,
  1349. chapterExamId: this.chapterId || 0,
  1350. examId: this.id,
  1351. goodsId: this.goodsId,
  1352. questionIds: doWrongQuestionIds,
  1353. recordId: this.recordId,
  1354. type: 1, // 题库试卷传1
  1355. doMode: this.doMode,
  1356. })
  1357. .then((res) => {});
  1358. },
  1359. /**
  1360. * 立即交卷
  1361. */
  1362. submitNow() {
  1363. this.showpopups = false;
  1364. this.needBack = false;
  1365. this.submit();
  1366. },
  1367. /**
  1368. * 离开页面统计回答正确题数
  1369. */
  1370. examRecordEdit() {
  1371. if (!this.isSubmit) {
  1372. let number = 0;
  1373. let score = 0;
  1374. let doQuestionNum = 0;
  1375. let doQuestionIds = []; //做过的题目id
  1376. this.questionList.forEach((item, index) => {
  1377. if (item.type == 1) {
  1378. if (item.ques == item.ans) {
  1379. score += item.score;
  1380. number++;
  1381. }
  1382. if (item.ques) {
  1383. doQuestionNum++;
  1384. doQuestionIds.push(item.questionId);
  1385. }
  1386. } else if (item.type == 2) {
  1387. let isRight =
  1388. item.ans &&
  1389. item.ans.every((quesItem, quesIndex) => {
  1390. if (item.ques) {
  1391. return item.ques[quesIndex] == item.ans[quesIndex];
  1392. } else {
  1393. return false;
  1394. }
  1395. });
  1396. if (isRight) {
  1397. score += item.score;
  1398. number++;
  1399. } else {
  1400. let checkboxScore = 1; //获取单题总分数
  1401. item.ques &&
  1402. item.ques.forEach((ques, quesIndex) => {
  1403. //选错一个全扣
  1404. if (item.ques) {
  1405. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1406. checkboxScore = 0;
  1407. }
  1408. } else {
  1409. checkboxScore = 0;
  1410. }
  1411. });
  1412. console.log(checkboxScore);
  1413. //没选错
  1414. if (checkboxScore) {
  1415. checkboxScore = 0;
  1416. item.ans.forEach((ans, quesIndex) => {
  1417. //漏选扣一部分,对n题给n X partScore 分
  1418. if (item.ques) {
  1419. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  1420. checkboxScore += item.partScore;
  1421. }
  1422. } else {
  1423. checkboxScore = 0;
  1424. }
  1425. });
  1426. }
  1427. if (checkboxScore <= 0) {
  1428. //0分
  1429. } else {
  1430. //部分分
  1431. // number++;
  1432. score += checkboxScore;
  1433. }
  1434. }
  1435. if (item.ques && item.ques.length) {
  1436. doQuestionNum++;
  1437. doQuestionIds.push(item.questionId);
  1438. }
  1439. } else if (item.type == 3) {
  1440. if (item.ques == item.ans) {
  1441. score += item.score;
  1442. number++;
  1443. }
  1444. if (item.ques) {
  1445. doQuestionNum++;
  1446. doQuestionIds.push(item.questionId);
  1447. }
  1448. } else if (item == 4) {
  1449. if (item.ques.length) {
  1450. doQuestionNum++;
  1451. doQuestionIds.push(item.questionId);
  1452. }
  1453. } else if (item.type == 5) {
  1454. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1455. doQuestionNum++;
  1456. doQuestionIds.push(item.questionId);
  1457. }
  1458. }
  1459. });
  1460. this.$api
  1461. .examRecordEdit({
  1462. orderGoodsId: this.orderGoodsId,
  1463. examId: this.id,
  1464. goodsId: this.goodsId,
  1465. recordId: this.recordId,
  1466. doQuestionIds: doQuestionIds.join(","),
  1467. rightQuestionNum: number,
  1468. moduleExamId: this.moduleId || 0,
  1469. chapterExamId: this.chapterId || 0,
  1470. status: 0,
  1471. doQuestionNum: doQuestionNum,
  1472. historyExamJson: JSON.stringify(this.questionList),
  1473. })
  1474. .then((res) => {
  1475. if (res.data.code == 200) {
  1476. this.entryType == "daily" && this.dailyExam();
  1477. }
  1478. });
  1479. }
  1480. },
  1481. /**
  1482. * 记录总题数
  1483. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1484. */
  1485. examRecord(hasSpecial) {
  1486. let questionList = 0;
  1487. // if(!hasSpecial) {
  1488. this.questionList.forEach((item, index) => {
  1489. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1490. questionList++;
  1491. }
  1492. });
  1493. // } else {
  1494. // questionList = this.questionList.length;
  1495. // }
  1496. this.$api
  1497. .examRecord({
  1498. chapterExamId: this.chapterId || 0,
  1499. orderGoodsId: this.orderGoodsId,
  1500. moduleExamId: this.moduleId || 0,
  1501. examId: this.id,
  1502. goodsId: this.goodsId,
  1503. totalQuestionNum: questionList,
  1504. allQuestionNum: this.questionList.length,
  1505. doMode: this.doMode,
  1506. simulateExamId: this.simulateExamId,
  1507. })
  1508. .then((res) => {
  1509. this.recordId = res.data.data;
  1510. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1511. if (this.bankType == 1) {
  1512. this.examRecordEdit();
  1513. }
  1514. });
  1515. },
  1516. /**
  1517. * @param {Object} second倒计时过滤器
  1518. */
  1519. countdown(second) {
  1520. if (second) {
  1521. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1522. let m = parseInt((second / 60) % 60); // 计算分数
  1523. let s = parseInt(second % 60); // 计算当前秒数
  1524. if (h < 10) h = "0" + h;
  1525. if (m < 10) m = "0" + m;
  1526. if (s < 10) s = "0" + s;
  1527. return h + ":" + m + ":" + s;
  1528. } else {
  1529. return "";
  1530. }
  1531. },
  1532. hideDialog() {
  1533. this.showDialog = false;
  1534. },
  1535. // 请求随机练习题目列表
  1536. randomQuestionList() {
  1537. this.$http({
  1538. url: "/bank/exam/temp",
  1539. method: "post",
  1540. data: {
  1541. goodsId: this.goodsId,
  1542. orderGoodsId: this.orderGoodsId,
  1543. number: this.bankNum,
  1544. },
  1545. }).then((res) => {
  1546. if (res.data.code == 200) {
  1547. this.examData = res.data.data || {};
  1548. this.id = this.examData.examId;
  1549. if (!this.examData.questionList.length) {
  1550. this.hideDialog();
  1551. uni.showModal({
  1552. showCancel: false,
  1553. content: "该试卷暂无题目",
  1554. success: (k) => {
  1555. if (k.confirm) {
  1556. this.isSubmit = true;
  1557. uni.navigateBack();
  1558. }
  1559. },
  1560. });
  1561. return;
  1562. }
  1563. this.dataAnlyze(this.examData.questionList || []);
  1564. } else {
  1565. this.$u.toast(res.data.msg);
  1566. setTimeout(() => {
  1567. uni.navigateBack();
  1568. }, 2000);
  1569. }
  1570. });
  1571. },
  1572. /**
  1573. * 请求题目列表 app/common/bank/question/list
  1574. */
  1575. goodsQuestionList() {
  1576. this.$api[
  1577. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1578. ]({
  1579. examId: this.id,
  1580. goodsId: this.goodsId,
  1581. orderGoodsId: this.orderGoodsId,
  1582. }).then((res) => {
  1583. let data = res.data.data;
  1584. if (this.doMode == 3) {
  1585. this.simulateExamId = data.simulateExamId;
  1586. data = data.questionList;
  1587. }
  1588. if (!data.length) {
  1589. this.hideDialog();
  1590. uni.showModal({
  1591. showCancel: false,
  1592. content: "该试卷暂无题目",
  1593. success: (k) => {
  1594. if (k.confirm) {
  1595. this.isSubmit = true;
  1596. uni.navigateBack();
  1597. }
  1598. },
  1599. });
  1600. return;
  1601. }
  1602. this.allTimes = data[0].answerTime * 60;
  1603. this.lastTime = data[0].answerTime && data[0].answerTime * 60;
  1604. //考试时间到了自动交卷
  1605. if (this.lastTime) {
  1606. this.timer = setInterval(() => {
  1607. if (this.lastTime <= 0) {
  1608. clearInterval(this.timer);
  1609. uni.showToast({
  1610. icon: "none",
  1611. mask: true,
  1612. title: "考试时间已到,系统将自动交卷",
  1613. duration: 10000,
  1614. });
  1615. this.submit();
  1616. return;
  1617. }
  1618. this.lastTime--;
  1619. }, 1000);
  1620. } else {
  1621. }
  1622. this.dataAnlyze(data);
  1623. });
  1624. },
  1625. dataAnlyze(datas = []) {
  1626. console.log("datas:", datas);
  1627. datas.forEach((item, index) => {
  1628. // if (typeof item.jsonStr == 'string') {
  1629. item.jsonStr = JSON.parse(item.jsonStr);
  1630. if (item.type == 2) {
  1631. //多选
  1632. item.jsonStr.forEach((str) => {
  1633. str.optionsId = "" + str.optionsId;
  1634. });
  1635. let arr = item.answerQuestion.split(",");
  1636. arr.forEach((a, i) => {
  1637. arr[i] = "" + a;
  1638. });
  1639. item.ans = arr;
  1640. item.analysisContent &&
  1641. (item.analysisContent = item.analysisContent.replace(
  1642. /<img/gi,
  1643. '<img style="max-width:100%;"'
  1644. ));
  1645. item.content &&
  1646. (item.content = item.content.replace(
  1647. /<img/gi,
  1648. '<img style="max-width:100%;"'
  1649. ));
  1650. return;
  1651. } else if (item.type == 5) {
  1652. //简答题
  1653. item.ansText = {
  1654. text: "",
  1655. imageList: [],
  1656. };
  1657. item.ques = {
  1658. text: "",
  1659. imageList: [],
  1660. };
  1661. item.analysisContent &&
  1662. (item.analysisContent = item.analysisContent.replace(
  1663. /<img/gi,
  1664. '<img style="max-width:100%;"'
  1665. ));
  1666. item.content &&
  1667. (item.content = item.content.replace(
  1668. /<img/gi,
  1669. '<img style="max-width:100%;"'
  1670. ));
  1671. } else if (item.type == 4) {
  1672. //案例题
  1673. item.ques = [];
  1674. item.current = 0;
  1675. let ansArr = [];
  1676. item.jsonStr.forEach((json, index) => {
  1677. if (json.type == 1) {
  1678. ansArr[index] = json.answerQuestion;
  1679. json.content &&
  1680. (json.content = json.content.replace(
  1681. /<img/gi,
  1682. '<img style="max-width:100%;"'
  1683. ));
  1684. } else if (json.type == 2) {
  1685. json.optionsList.forEach((str) => {
  1686. str.optionsId = "" + str.optionsId;
  1687. });
  1688. let arr = json.answerQuestion.split(",");
  1689. arr.forEach((a, i) => {
  1690. arr[i] = "" + a;
  1691. });
  1692. ansArr[index] = arr;
  1693. json.content &&
  1694. (json.content = json.content.replace(
  1695. /<img/gi,
  1696. '<img style="max-width:100%;"'
  1697. ));
  1698. } else if (json.type == 3) {
  1699. ansArr[index] = json.answerQuestion;
  1700. json.content &&
  1701. (json.content = json.content.replace(
  1702. /<img/gi,
  1703. '<img style="max-width:100%;"'
  1704. ));
  1705. } else if (json.type == 5) {
  1706. ansArr[index] = {
  1707. text: json.answerQuestion,
  1708. imageList: [],
  1709. };
  1710. json.ansText = {
  1711. text: "",
  1712. imageList: [],
  1713. };
  1714. json.content &&
  1715. (json.content = json.content.replace(
  1716. /<img/gi,
  1717. '<img style="max-width:100%;"'
  1718. ));
  1719. }
  1720. });
  1721. item.analysisContent &&
  1722. (item.analysisContent = item.analysisContent.replace(
  1723. /<img/gi,
  1724. '<img style="max-width:100%;"'
  1725. ));
  1726. item.content &&
  1727. (item.content = item.content.replace(
  1728. /<img/gi,
  1729. '<img style="max-width:100%;"'
  1730. ));
  1731. item.ans = ansArr;
  1732. return;
  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 = item.answerQuestion;
  1745. // }
  1746. });
  1747. this.questionList = datas;
  1748. this.lastCount = this.questionList.length;
  1749. this.examRecord();
  1750. this.getCollectInfo(this.current);
  1751. },
  1752. /**
  1753. * @param {Object} e单选点击
  1754. */
  1755. radioSelect(optionsId, bindex) {
  1756. // if (this.questionList[bindex].ques) return;
  1757. if (this.questionList[bindex].ques && this.bankType == 1) {
  1758. return;
  1759. }
  1760. this.$set(this.questionList[bindex], "ques", optionsId);
  1761. // if ((bindex + 1) < this.questionList.length) {
  1762. // this.current = bindex + 1
  1763. // }
  1764. this.isDoOver();
  1765. // 回答错误
  1766. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1767. // // /exam/wwrong/record
  1768. // this.$api
  1769. // .examWrongRecord({
  1770. // orderGoodsId: this.orderGoodsId,
  1771. // examId: this.id,
  1772. // goodsId: this.goodsId,
  1773. // moduleExamId: this.moduleId || 0,
  1774. // chapterExamId: this.chapterId || 0,
  1775. // questionIds: [this.questionList[bindex].questionId],
  1776. // recordId: this.recordId,
  1777. // })
  1778. // .then((res) => {});
  1779. // } else {
  1780. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1781. // // if(question) {
  1782. // // this.$api.wrongRecordDelete({
  1783. // // "examId": +this.id,
  1784. // // "goodsId": +this.goodsId,
  1785. // // "questionId": this.questionList[bindex].questionId,
  1786. // // }).then(res => {
  1787. // // })
  1788. // // }
  1789. // }
  1790. },
  1791. /**
  1792. * @param {Object} e案例单选点击
  1793. */
  1794. radioSelectChild(optionsId, ansIndex, bindex) {
  1795. // if (this.questionList[bindex].ques[ansIndex]) return;
  1796. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1797. return;
  1798. }
  1799. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1800. this.isDoOver();
  1801. },
  1802. /**
  1803. * @param {Object} 多选点击
  1804. */
  1805. checkboxSelect(optionsId, bindex, index) {
  1806. if (this.questionList[bindex].ques && this.bankType == 1) {
  1807. return;
  1808. }
  1809. this.$set(
  1810. this.questionList[bindex].jsonStr[index],
  1811. "checked",
  1812. !this.questionList[bindex].jsonStr[index].checked
  1813. );
  1814. },
  1815. /**
  1816. * @param {Object} 案例多选点击
  1817. */
  1818. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1819. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1820. return;
  1821. }
  1822. this.$set(
  1823. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1824. "checked",
  1825. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1826. .checked
  1827. );
  1828. },
  1829. isCheckboxChecked(arr) {
  1830. return arr.some((item) => {
  1831. if (item.checked) {
  1832. return true;
  1833. }
  1834. });
  1835. },
  1836. /**
  1837. * @param {Object} 多选确认
  1838. */
  1839. checkboxSubmit(bindex) {
  1840. // console.log('')
  1841. // if (this.questionList[bindex].ques) return;
  1842. if (this.questionList[bindex].ques && this.bankType == 1) {
  1843. return;
  1844. }
  1845. let arr = [];
  1846. this.questionList[bindex].jsonStr.forEach((item) => {
  1847. if (item.checked) {
  1848. arr.push(item.optionsId);
  1849. }
  1850. });
  1851. if (!arr.length) {
  1852. delete this.questionList[bindex].ques;
  1853. uni.showToast({
  1854. title: "请选择答案",
  1855. icon: "none",
  1856. });
  1857. return;
  1858. }
  1859. this.$set(this.questionList[bindex], "ques", arr);
  1860. this.$u.toast("已确认答案");
  1861. this.isDoOver();
  1862. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1863. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1864. // })
  1865. // // 回答错误
  1866. // if (isWrong) {
  1867. // this.$api
  1868. // .examWrongRecord({
  1869. // orderGoodsId: this.orderGoodsId,
  1870. // examId: this.id,
  1871. // goodsId: this.goodsId,
  1872. // moduleExamId: this.moduleId || 0,
  1873. // chapterExamId: this.chapterId || 0,
  1874. // questionIds: [this.questionList[bindex].questionId],
  1875. // recordId: this.recordId,
  1876. // })
  1877. // .then((res) => {});
  1878. // } else {
  1879. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1880. // // if(question) {
  1881. // // this.$api.wrongRecordDelete({
  1882. // // "examId": +this.id,
  1883. // // "goodsId": +this.goodsId,
  1884. // // "questionId": this.questionList[bindex].questionId,
  1885. // // }).then(res => {
  1886. // // })
  1887. // // }
  1888. // }
  1889. },
  1890. /**
  1891. * @param {Object} 案例多选确认
  1892. */
  1893. checkboxSubmitChild(bindex, ansIndex) {
  1894. // if (this.questionList[bindex].ques[ansIndex]) return;
  1895. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1896. return;
  1897. }
  1898. let arr = [];
  1899. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1900. (item) => {
  1901. if (item.checked) {
  1902. arr.push(item.optionsId);
  1903. }
  1904. }
  1905. );
  1906. if (!arr.length) {
  1907. delete this.questionList[bindex].ques[ansIndex];
  1908. uni.showToast({
  1909. title: "请选择答案",
  1910. icon: "none",
  1911. });
  1912. return;
  1913. }
  1914. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1915. this.$u.toast("已确认答案");
  1916. this.isDoOver();
  1917. },
  1918. /**
  1919. * @param {Object} index
  1920. * @param {Object} bindex
  1921. * 判断题
  1922. */
  1923. judgeSelect(index, bindex) {
  1924. // if (this.questionList[bindex].ques) return;
  1925. if (this.questionList[bindex].ques && this.bankType == 1) {
  1926. return;
  1927. } // 答案: 判断题1正确 0错误
  1928. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  1929. console.log(
  1930. "this.questionList[bindex]:",
  1931. this.questionList[bindex].ques,
  1932. this.questionList[bindex].ans
  1933. );
  1934. this.isDoOver();
  1935. // 回答错误
  1936. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1937. // this.$api
  1938. // .examWrongRecord({
  1939. // orderGoodsId: this.orderGoodsId,
  1940. // examId: this.id,
  1941. // goodsId: this.goodsId,
  1942. // moduleExamId: this.moduleId || 0,
  1943. // chapterExamId: this.chapterId || 0,
  1944. // questionIds: [this.questionList[bindex].questionId],
  1945. // recordId: this.recordId,
  1946. // })
  1947. // .then((res) => {});
  1948. // } else {
  1949. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1950. // // if(question) {
  1951. // // this.$api.wrongRecordDelete({
  1952. // // "examId": +this.id,
  1953. // // "goodsId": +this.goodsId,
  1954. // // "questionId": this.questionList[bindex].questionId,
  1955. // // }).then(res => {
  1956. // // })
  1957. // // }
  1958. // }
  1959. },
  1960. /**
  1961. * @param {Object} ansindex
  1962. * @param {Object} childindex
  1963. * @param {Object} bindex
  1964. * 案例判断题
  1965. */
  1966. judgeSelectChild(ansindex, childindex, bindex) {
  1967. // if (this.questionList[bindex].ques[ansindex]) return;
  1968. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  1969. return;
  1970. }
  1971. this.$set(
  1972. this.questionList[bindex].ques,
  1973. ansindex,
  1974. childindex == 0 ? "1" : "0"
  1975. );
  1976. this.isDoOver();
  1977. },
  1978. openFooterTab() {
  1979. this.show = true;
  1980. },
  1981. changeIndex(index) {
  1982. this.current = index;
  1983. },
  1984. swiperChange(e) {
  1985. this.current = e.detail.current;
  1986. this.getCollectInfo(this.current);
  1987. },
  1988. /**
  1989. * @param {Object} current
  1990. * 获取收藏信息
  1991. */
  1992. getCollectInfo(current) {
  1993. this.$api
  1994. .getCollectInfo({
  1995. examId: this.id,
  1996. questionId: this.questionList[current].questionId,
  1997. goodsId: this.goodsId,
  1998. orderGoodsId: this.orderGoodsId,
  1999. })
  2000. .then((res) => {
  2001. if (res.data.code == 500) {
  2002. this.$set(this.collectList, current, false);
  2003. } else if (res.data.code == 200) {
  2004. this.$set(this.collectList, current, res.data.data);
  2005. }
  2006. });
  2007. },
  2008. pdsubmit() {
  2009. // if (this.bankType == 1) {
  2010. let ansCount = this.questionOverNum(true); //已答题数
  2011. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2012. //没有答完
  2013. if (this.lastCount !== 0) {
  2014. this.cgType = 6;
  2015. this.showpopups = true;
  2016. return;
  2017. }
  2018. // }
  2019. if (this.bankType == 2) {
  2020. if (this.lastTime > 0) {
  2021. let lastTime = this.countdown(this.lastTime);
  2022. uni.showModal({
  2023. title: "提示",
  2024. content: `时间还剩余${lastTime},确定交卷吗?`,
  2025. confirmText: "交卷",
  2026. cancelText: "继续答题",
  2027. success: (res) => {
  2028. if (res.confirm) {
  2029. //确定
  2030. this.submit();
  2031. } else {
  2032. //取消
  2033. }
  2034. },
  2035. });
  2036. return;
  2037. }
  2038. }
  2039. this.submit();
  2040. },
  2041. /**
  2042. * 交卷
  2043. */
  2044. submit() {
  2045. let score = 0; //计算总分
  2046. let reportStatus = 0;
  2047. let number = 0; //做对的题目数量
  2048. let doQuestionNum = 0; //做过的题目数量
  2049. let allScore = 0; //总分
  2050. let passScore = 0;
  2051. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2052. let doQuestionIds = []; //做过的题目id
  2053. let lessQuestionNum = 0;
  2054. let rightQuestionIds = []; //做对的题目id
  2055. this.questionList.forEach((item, index) => {
  2056. passScore = item.passScore;
  2057. if (item.type == 1) {
  2058. //正确
  2059. if (item.ques == item.ans) {
  2060. item.scoreResult = item.score;
  2061. score += item.score;
  2062. number++;
  2063. rightQuestionIds.push(item.questionId);
  2064. } else {
  2065. //错误
  2066. item.scoreResult = 0;
  2067. if (item.ques) {
  2068. doWrongQuestionIds.push(item.questionId);
  2069. }
  2070. }
  2071. allScore += item.score;
  2072. if (item.ques) {
  2073. doQuestionNum++;
  2074. doQuestionIds.push(item.questionId);
  2075. }
  2076. } else if (item.type == 2) {
  2077. let isRight =
  2078. item.ans &&
  2079. item.ans.every((quesItem, quesIndex) => {
  2080. if (item.ques) {
  2081. return item.ques[quesIndex] == item.ans[quesIndex];
  2082. } else {
  2083. return false;
  2084. }
  2085. });
  2086. if (isRight) {
  2087. score += item.score;
  2088. number++;
  2089. item.scoreResult = item.score;
  2090. rightQuestionIds.push(item.questionId);
  2091. } else {
  2092. let hasPart = false;
  2093. let checkboxScore = 1; //获取单题总分数
  2094. item.ques &&
  2095. item.ques.forEach((ques, quesIndex) => {
  2096. //选错一个全扣
  2097. if (item.ques) {
  2098. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2099. checkboxScore = 0;
  2100. }
  2101. } else {
  2102. checkboxScore = 0;
  2103. }
  2104. });
  2105. //没选错
  2106. if (checkboxScore) {
  2107. checkboxScore = 0;
  2108. item.ans.forEach((ans, quesIndex) => {
  2109. //漏选扣一部分,对n题给n X partScore 分
  2110. if (item.ques) {
  2111. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2112. checkboxScore += item.partScore;
  2113. hasPart = true;
  2114. }
  2115. } else {
  2116. checkboxScore = 0;
  2117. }
  2118. });
  2119. }
  2120. if (!hasPart) {
  2121. //0分
  2122. item.scoreResult = 0;
  2123. if (item.ques) {
  2124. doWrongQuestionIds.push(item.questionId);
  2125. }
  2126. } else {
  2127. //部分分
  2128. // number++;
  2129. lessQuestionNum++;
  2130. // doWrongQuestionIds.push(item.questionId);
  2131. item.scoreResult = checkboxScore;
  2132. score += checkboxScore;
  2133. // rightQuestionIds.push(item.questionId)
  2134. }
  2135. }
  2136. allScore += item.score;
  2137. if (item.ques && item.ques.length) {
  2138. doQuestionNum++;
  2139. doQuestionIds.push(item.questionId);
  2140. }
  2141. } else if (item.type == 3) {
  2142. if (item.ques == item.ans) {
  2143. item.scoreResult = item.score;
  2144. score += item.score;
  2145. number++;
  2146. rightQuestionIds.push(item.questionId);
  2147. } else {
  2148. item.scoreResult = 0;
  2149. if (item.ques) {
  2150. doWrongQuestionIds.push(item.questionId);
  2151. }
  2152. }
  2153. allScore += item.score;
  2154. if (item.ques) {
  2155. doQuestionNum++;
  2156. doQuestionIds.push(item.questionId);
  2157. }
  2158. } else if (item.type == 4) {
  2159. allScore += item.score;
  2160. if (item.ques && item.ques.length) {
  2161. doQuestionNum++;
  2162. doQuestionIds.push(item.questionId);
  2163. }
  2164. } else if (item.type == 5) {
  2165. allScore += item.score;
  2166. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2167. doQuestionNum++;
  2168. doQuestionIds.push(item.questionId);
  2169. }
  2170. }
  2171. });
  2172. //大于及格
  2173. if (score >= passScore) {
  2174. reportStatus = 1;
  2175. } else {
  2176. reportStatus = 0;
  2177. }
  2178. //交卷
  2179. this.$api
  2180. .examRecordEdit({
  2181. // courseId: this.courseId,
  2182. examId: this.id,
  2183. goodsId: this.goodsId,
  2184. reportStatus: reportStatus,
  2185. recordId: this.recordId,
  2186. rightQuestionNum: number,
  2187. orderGoodsId: this.orderGoodsId,
  2188. status: 1,
  2189. lessQuestionNum: lessQuestionNum,
  2190. moduleExamId: this.moduleId || 0,
  2191. chapterExamId: this.chapterId || 0,
  2192. doQuestionIds: doQuestionIds.join(","),
  2193. rightQuestionIds: rightQuestionIds.join(","),
  2194. doQuestionNum: doQuestionNum,
  2195. performance: score,
  2196. totalScore: allScore,
  2197. examTime: parseInt(this.allTimes),
  2198. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2199. historyExamJson: JSON.stringify(this.questionList),
  2200. // type: ''
  2201. })
  2202. .then((res) => {
  2203. this.isSubmit = true;
  2204. if (res.data.code == 200) {
  2205. this.entryType == "daily" && this.dailyExam();
  2206. uni.showToast({
  2207. title: "交卷成功",
  2208. duration: 1000,
  2209. icon: "none",
  2210. });
  2211. setTimeout(() => {
  2212. uni.redirectTo({
  2213. url:
  2214. "/pages2/bank/question_report?goodsId=" +
  2215. this.goodsId +
  2216. "&chapterId=" +
  2217. this.chapterId +
  2218. "&moduleId=" +
  2219. this.moduleId +
  2220. "&examId=" +
  2221. this.id +
  2222. "&id=" +
  2223. this.recordId +
  2224. "&orderGoodsId=" +
  2225. this.orderGoodsId +
  2226. "&entryType=" +
  2227. this.entryType +
  2228. "&bankNum=" +
  2229. this.bankNum,
  2230. });
  2231. }, 1000);
  2232. }
  2233. });
  2234. //错题集id提交(客观题)
  2235. this.$api
  2236. .examWrongRecord({
  2237. examId: this.id,
  2238. goodsId: this.goodsId,
  2239. orderGoodsId: this.orderGoodsId,
  2240. questionIds: doWrongQuestionIds,
  2241. recordId: this.recordId,
  2242. type: 1, // 题库试卷传1
  2243. doMode: this.doMode,
  2244. })
  2245. .then((res) => {});
  2246. },
  2247. // 每日一练试卷打卡
  2248. dailyExam() {
  2249. const dateStamp = parseInt(
  2250. new Date(new Date().toLocaleDateString()).getTime() / 1000
  2251. );
  2252. this.$http({
  2253. url: "/bank/question/special/exam/record",
  2254. method: "post",
  2255. data: {
  2256. examId: this.id,
  2257. chapterExamId: this.chapterId, // 章卷ID
  2258. moduleExamId: this.moduleId, //模块卷ID
  2259. goodsId: this.goodsId,
  2260. recordTime: dateStamp, // 传当天0点时间戳(秒)
  2261. },
  2262. }).then((res) => {
  2263. if (res.data.code == 200) {
  2264. }
  2265. });
  2266. },
  2267. /**
  2268. * @param {Object} state
  2269. * @param {Object} index
  2270. * 收藏
  2271. */
  2272. collect(state, index) {
  2273. if (!state) {
  2274. this.$api
  2275. .collectQuestion({
  2276. examId: this.id,
  2277. questionId: this.questionList[index].questionId,
  2278. goodsId: this.goodsId || "",
  2279. orderGoodsId: this.orderGoodsId,
  2280. doMode: this.doMode,
  2281. })
  2282. .then((res) => {
  2283. if (res.data.code == 200) {
  2284. this.$set(this.collectList, index, true);
  2285. uni.showToast({
  2286. title: "收藏成功",
  2287. duration: 2000,
  2288. icon: "none",
  2289. });
  2290. this.getCollectInfo(index);
  2291. }
  2292. });
  2293. } else {
  2294. this.$api
  2295. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2296. .then((res) => {
  2297. if (res.data.code == 200) {
  2298. this.$set(this.collectList, index, false);
  2299. uni.showToast({
  2300. title: "取消收藏成功",
  2301. duration: 2000,
  2302. icon: "none",
  2303. });
  2304. }
  2305. });
  2306. }
  2307. return;
  2308. },
  2309. /**
  2310. * @param {Object} imgIndex
  2311. * @param {Object} bankIndex
  2312. * 删除简答图片
  2313. */
  2314. deleteImg(imgIndex, bankIndex) {
  2315. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2316. },
  2317. /**
  2318. * @param {Object} imgIndex
  2319. * @param {Object} bankIndex
  2320. * @param {Object} ansIndex
  2321. * 删除案例题简答图片
  2322. */
  2323. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2324. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2325. imgIndex,
  2326. 1
  2327. );
  2328. },
  2329. /**
  2330. * @param {Object} bankindex
  2331. * 选择上传图片
  2332. */
  2333. chooseImg(bankindex) {
  2334. if (
  2335. this.questionList[bankindex] &&
  2336. this.questionList[bankindex].ansText &&
  2337. this.questionList[bankindex].ansText.imageList.length >= 4
  2338. ) {
  2339. uni.showToast({
  2340. icon: "none",
  2341. title: "最多选择4张",
  2342. });
  2343. return;
  2344. }
  2345. uni.chooseImage({
  2346. count: 1, //默认9
  2347. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2348. sourceType: ["album", "camera"], //从相册选择
  2349. success: (res) => {
  2350. let self = this;
  2351. // console.log(JSON.stringify(res.tempFilePaths));
  2352. let img = res.tempFilePaths[0];
  2353. uni.getImageInfo({
  2354. src: img,
  2355. success: async (res) => {
  2356. let canvasWidth = res.width; //图片原始长宽
  2357. let canvasHeight = res.height;
  2358. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2359. uni.compressImage({
  2360. src: img,
  2361. quality: 75,
  2362. width: "50%",
  2363. height: "50%",
  2364. success: async (rest) => {
  2365. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2366. this.questionList[bankindex].ansText.imageList.push(dir);
  2367. },
  2368. });
  2369. } else {
  2370. const dir = await self.uploadFile(img, 0);
  2371. this.questionList[bankindex].ansText.imageList.push(dir);
  2372. }
  2373. },
  2374. });
  2375. },
  2376. });
  2377. },
  2378. /**
  2379. * @param {Object} bankindex
  2380. * @param {Object} ansindex
  2381. * 案例题选择上传图片
  2382. */
  2383. chooseImgChild(bankindex, ansindex) {
  2384. if (
  2385. this.questionList[bankindex].jsonStr[ansindex] &&
  2386. this.questionList[bankindex].jsonStr[ansindex].ansText &&
  2387. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
  2388. .length >= 4
  2389. ) {
  2390. uni.showToast({
  2391. icon: "none",
  2392. title: "最多选择4张",
  2393. });
  2394. return;
  2395. }
  2396. uni.chooseImage({
  2397. count: 1, //默认9
  2398. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2399. sourceType: ["album", "camera"], //从相册选择
  2400. success: (res) => {
  2401. let self = this;
  2402. // console.log(JSON.stringify(res.tempFilePaths));
  2403. let img = res.tempFilePaths[0];
  2404. uni.getImageInfo({
  2405. src: img,
  2406. success: async (res) => {
  2407. let canvasWidth = res.width; //图片原始长宽
  2408. let canvasHeight = res.height;
  2409. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2410. uni.compressImage({
  2411. src: img,
  2412. quality: 75,
  2413. width: "50%",
  2414. height: "50%",
  2415. success: async (rest) => {
  2416. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2417. this.questionList[bankindex].jsonStr[
  2418. ansindex
  2419. ].ansText.imageList.push(dir);
  2420. },
  2421. });
  2422. } else {
  2423. const dir = await self.uploadFile(img, 0);
  2424. this.questionList[bankindex].jsonStr[
  2425. ansindex
  2426. ].ansText.imageList.push(dir);
  2427. }
  2428. },
  2429. });
  2430. },
  2431. });
  2432. },
  2433. uploadFile(options, int) {
  2434. var self = this;
  2435. return new Promise((resolve, reject) => {
  2436. var data = {
  2437. orderGoodsId: this.orderGoodsId,
  2438. imageStatus: int,
  2439. };
  2440. self.$api.aliyunpolicy(data).then((res) => {
  2441. console.log(res.data, 6);
  2442. if (res.data.code != 200) {
  2443. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  2444. return;
  2445. }
  2446. var ossToken = res.data.data.resultContent;
  2447. if (ossToken.host == null || ossToken.host == undefined) {
  2448. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  2449. return;
  2450. }
  2451. uni.uploadFile({
  2452. url: ossToken.host,
  2453. name: "file",
  2454. filePath: options,
  2455. fileType: "image",
  2456. header: {
  2457. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  2458. },
  2459. formData: {
  2460. key: ossToken.dir,
  2461. OSSAccessKeyId: ossToken.accessid,
  2462. policy: ossToken.policy,
  2463. Signature: ossToken.signature,
  2464. callback: ossToken.callback,
  2465. success_action_status: 200,
  2466. },
  2467. success: (result) => {
  2468. // if (result.statusCode === 200) {
  2469. resolve(ossToken.dir);
  2470. // } else {
  2471. // uni.showToast({
  2472. // title: "上传失败",
  2473. // icon: "none",
  2474. // });
  2475. // return;
  2476. // }
  2477. },
  2478. fail: (error) => {
  2479. uni.showToast({
  2480. title: "上传接口报错" + error,
  2481. icon: "none",
  2482. });
  2483. return;
  2484. },
  2485. });
  2486. });
  2487. });
  2488. },
  2489. /**
  2490. * @param {Object} type
  2491. * @param {Object} bankindex
  2492. * 简答题答案确认
  2493. */
  2494. submitAns(bankindex) {
  2495. console.log(this.questionList[bankindex]);
  2496. if (
  2497. !this.questionList[bankindex].ansText.text &&
  2498. !this.questionList[bankindex].ansText.imageList.length
  2499. ) {
  2500. uni.showToast({
  2501. title: "请输入内容或上传图片",
  2502. duration: 2000,
  2503. icon: "none",
  2504. });
  2505. return;
  2506. }
  2507. this.$set(this.questionList[bankindex], "ques", {
  2508. imageList: this.questionList[bankindex].ansText.imageList || [],
  2509. text: this.questionList[bankindex].ansText.text || "",
  2510. });
  2511. this.isDoOver();
  2512. },
  2513. /**
  2514. * @param {Object} bankindex
  2515. * @param {Object} ansindex
  2516. * 案例题简答答案确认
  2517. */
  2518. submitAnsChild(bankindex, ansindex) {
  2519. if (
  2520. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2521. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2522. ) {
  2523. uni.showToast({
  2524. title: "请输入内容或上传图片",
  2525. duration: 2000,
  2526. icon: "none",
  2527. });
  2528. return;
  2529. }
  2530. this.$set(this.questionList[bankindex].ques, ansindex, {
  2531. imageList:
  2532. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
  2533. [],
  2534. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
  2535. });
  2536. this.isDoOver();
  2537. },
  2538. isCheck(item, index) {
  2539. if (this.questionList[index].ques) {
  2540. return true;
  2541. }
  2542. },
  2543. isRight(item, index) {
  2544. //单选
  2545. if (this.questionList[index].ques) {
  2546. if (item.type == 1) {
  2547. return this.questionList[index].ques == this.questionList[index].ans;
  2548. //多选
  2549. } else if (item.type == 2) {
  2550. //每一项都相等
  2551. return this.questionList[index].ans.every((item, i) => {
  2552. return item == this.questionList[index].ques[i];
  2553. });
  2554. //判断
  2555. } else if (item.type == 3) {
  2556. return this.questionList[index].ques == this.questionList[index].ans;
  2557. // } else if (item.type == 5) {
  2558. // if(this.questionList[index].ques.text){
  2559. // return true
  2560. // }else{
  2561. // return false
  2562. // }
  2563. } else {
  2564. return false;
  2565. }
  2566. } else {
  2567. return false;
  2568. }
  2569. },
  2570. right(bankIndex, ansIndex, option) {
  2571. if (
  2572. this.questionList[bankIndex].ques[ansIndex] &&
  2573. this.questionList[bankIndex].ans[ansIndex]
  2574. ) {
  2575. if (
  2576. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2577. option.optionsId
  2578. ) != -1 ||
  2579. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2580. option.optionsId
  2581. ) != -1
  2582. ) {
  2583. return true;
  2584. } else {
  2585. return false;
  2586. }
  2587. } else {
  2588. return false;
  2589. }
  2590. },
  2591. wrong(bankIndex, ansIndex, option) {
  2592. if (
  2593. this.questionList[bankIndex].ques[ansIndex] &&
  2594. this.questionList[bankIndex].ans[ansIndex]
  2595. ) {
  2596. if (
  2597. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2598. option.optionsId
  2599. ) != -1 &&
  2600. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2601. option.optionsId
  2602. ) == -1
  2603. ) {
  2604. return true;
  2605. } else {
  2606. return false;
  2607. }
  2608. } else {
  2609. return false;
  2610. }
  2611. },
  2612. isWrong(item, index) {
  2613. if (this.questionList[index].ques) {
  2614. //单选
  2615. if (item.type == 1) {
  2616. return this.questionList[index].ques != this.questionList[index].ans;
  2617. //多选
  2618. } else if (item.type == 2) {
  2619. //每一项都相等
  2620. return this.questionList[index].ques.some((item, i) => {
  2621. return this.questionList[index].ans.indexOf(item) == -1;
  2622. });
  2623. //判断
  2624. } else if (item.type == 3) {
  2625. return this.questionList[index].ques != this.questionList[index].ans;
  2626. } else {
  2627. return false;
  2628. }
  2629. } else {
  2630. return false;
  2631. }
  2632. },
  2633. isPart(item, index) {
  2634. if (this.questionList[index].ques) {
  2635. if (item.type == 2) {
  2636. let isWrong = this.questionList[index].ques.some((item, i) => {
  2637. return this.questionList[index].ans.indexOf(item) == -1;
  2638. });
  2639. let isRight = this.questionList[index].ans.every((item, i) => {
  2640. return item == this.questionList[index].ques[i];
  2641. });
  2642. if (!isRight && !isWrong) {
  2643. return true;
  2644. }
  2645. }
  2646. } else {
  2647. return false;
  2648. }
  2649. },
  2650. isOver(item, index) {
  2651. if (this.questionList[index].ques) {
  2652. if (item.type == 4) {
  2653. //案例题
  2654. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2655. if (
  2656. jsonItem.type == 1 ||
  2657. jsonItem.type == 2 ||
  2658. jsonItem.type == 3
  2659. ) {
  2660. if (item.ques[indexs]) {
  2661. return true;
  2662. } else {
  2663. return false;
  2664. }
  2665. } else if (jsonItem.type == 5) {
  2666. if (
  2667. item.ques[indexs] &&
  2668. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2669. ) {
  2670. console.log("chil");
  2671. return true;
  2672. } else {
  2673. return false;
  2674. }
  2675. }
  2676. });
  2677. if (isOver) {
  2678. return true;
  2679. } else {
  2680. return false;
  2681. }
  2682. } else if (item.type == 5) {
  2683. //简答题
  2684. //每一项都相等
  2685. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2686. return true;
  2687. }
  2688. //判断
  2689. } else {
  2690. return false;
  2691. }
  2692. } else {
  2693. return false;
  2694. }
  2695. },
  2696. tabSelect(index, bankindex) {
  2697. this.$set(this.questionList[bankindex], "current", index);
  2698. },
  2699. showPhoto(contentStr) {
  2700. if (contentStr && typeof contentStr == "string") {
  2701. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  2702. let strArr = contentStr.match(reg);
  2703. strArr.forEach((str, index) => {
  2704. strArr[index] = str.replace(reg, "$1");
  2705. });
  2706. // 预览图片
  2707. uni.previewImage({
  2708. urls: strArr,
  2709. longPressActions: {
  2710. itemList: ["发送给朋友", "保存图片", "收藏"],
  2711. success: function (data) {
  2712. console.log(
  2713. "选中了第" +
  2714. (data.tapIndex + 1) +
  2715. "个按钮,第" +
  2716. (data.index + 1) +
  2717. "张图片"
  2718. );
  2719. },
  2720. fail: function (err) {
  2721. console.log(err.errMsg);
  2722. },
  2723. },
  2724. });
  2725. }
  2726. },
  2727. },
  2728. computed: {
  2729. doMode() {
  2730. // 做题模式 1章卷 2随机练习 3模拟组卷
  2731. return this.examData.simulateStatus
  2732. ? 3
  2733. : this.entryType == "random"
  2734. ? 2
  2735. : 1;
  2736. },
  2737. },
  2738. };
  2739. </script>
  2740. <style lang="scss" scoped>
  2741. .questionBank {
  2742. width: 100%;
  2743. height: 100vh;
  2744. display: flex;
  2745. flex-direction: column;
  2746. }
  2747. .swiper {
  2748. width: 100%;
  2749. flex: 1;
  2750. }
  2751. .lisSty {
  2752. margin-bottom: 16rpx;
  2753. display: flex;
  2754. align-items: center;
  2755. .flex_auto {
  2756. flex: 1;
  2757. }
  2758. }
  2759. .activeTI {
  2760. vertical-align: middle;
  2761. display: inline-block;
  2762. border: 1rpx solid #eee;
  2763. border-radius: 50rpx;
  2764. height: 48rpx;
  2765. line-height: 46rpx;
  2766. text-align: center;
  2767. width: 48rpx;
  2768. margin-right: 15rpx;
  2769. color: #666;
  2770. font-size: 30rpx;
  2771. &.right {
  2772. color: #fff;
  2773. background: #36c75a;
  2774. }
  2775. &.wrong {
  2776. color: #fff;
  2777. background: #ff3b30;
  2778. }
  2779. &.checked,
  2780. &.user_choose {
  2781. color: #fff;
  2782. background: #007aff;
  2783. }
  2784. }
  2785. .submit_checkbox {
  2786. position: fixed;
  2787. left: 0;
  2788. right: 0;
  2789. bottom: 120rpx;
  2790. margin: 20rpx auto;
  2791. width: 526rpx;
  2792. height: 80rpx;
  2793. background: rgba(0, 122, 255, 1);
  2794. color: #fff;
  2795. text-align: center;
  2796. line-height: 80rpx;
  2797. font-size: 30rpx;
  2798. border-radius: 40rpx;
  2799. &.disabled {
  2800. opacity: 0.6;
  2801. }
  2802. }
  2803. .titles {
  2804. overflow: hidden;
  2805. margin-bottom: 24rpx;
  2806. }
  2807. .titBox {
  2808. padding: 41rpx 25rpx 24rpx 25rpx;
  2809. }
  2810. .titBox_title {
  2811. padding: 21rpx;
  2812. }
  2813. .tabs {
  2814. margin: 10rpx;
  2815. display: flex;
  2816. .tab {
  2817. margin: 0 4rpx;
  2818. padding: 10rpx 13rpx;
  2819. text-align: center;
  2820. color: #007aff;
  2821. font-size: 28rpx;
  2822. border-radius: 16rpx;
  2823. background: #fff;
  2824. &.current {
  2825. color: #fff;
  2826. background: #007aff;
  2827. }
  2828. }
  2829. }
  2830. .ans {
  2831. margin: 8rpx 8rpx 8rpx;
  2832. .ans_input {
  2833. border-radius: 16rpx;
  2834. background: #fff;
  2835. .top {
  2836. border-bottom: 1rpx solid #eeeeee;
  2837. padding: 16rpx;
  2838. display: flex;
  2839. align-items: center;
  2840. .icon {
  2841. margin-right: 20rpx;
  2842. width: 40rpx;
  2843. height: 38rpx;
  2844. }
  2845. .progress {
  2846. flex: 1;
  2847. }
  2848. .submit {
  2849. width: 168rpx;
  2850. height: 48rpx;
  2851. line-height: 48rpx;
  2852. text-align: center;
  2853. color: #fff;
  2854. font-size: 30rpx;
  2855. background: #007aff;
  2856. border-radius: 24rpx;
  2857. &.disabled {
  2858. opacity: 0.6;
  2859. }
  2860. }
  2861. }
  2862. .textarea {
  2863. textarea {
  2864. width: 100%;
  2865. height: 287rpx;
  2866. padding: 10rpx;
  2867. }
  2868. }
  2869. .imgs {
  2870. overflow: hidden;
  2871. display: flex;
  2872. width: 100%;
  2873. .img {
  2874. width: 104rpx;
  2875. height: 104rpx;
  2876. border-radius: 8rpx;
  2877. position: relative;
  2878. margin: 20rpx;
  2879. text {
  2880. position: absolute;
  2881. right: -15rpx;
  2882. top: -15rpx;
  2883. width: 30rpx;
  2884. height: 30rpx;
  2885. text-align: center;
  2886. line-height: 30rpx;
  2887. color: #fff;
  2888. background: #ff3b30;
  2889. border-radius: 50%;
  2890. }
  2891. image {
  2892. width: 100%;
  2893. height: 100%;
  2894. }
  2895. }
  2896. }
  2897. }
  2898. .ans_submit {
  2899. padding: 16rpx;
  2900. border-radius: 16rpx;
  2901. background: #fff;
  2902. .imgs {
  2903. overflow: hidden;
  2904. display: flex;
  2905. width: 100%;
  2906. .img {
  2907. width: 104rpx;
  2908. height: 104rpx;
  2909. border-radius: 8rpx;
  2910. position: relative;
  2911. margin: 20rpx;
  2912. image {
  2913. width: 100%;
  2914. height: 100%;
  2915. }
  2916. }
  2917. }
  2918. }
  2919. }
  2920. .leftLetters {
  2921. display: flex;
  2922. align-items: center;
  2923. width: 220rpx;
  2924. .btnType {
  2925. padding: 5rpx 10rpx;
  2926. border: 1rpx solid #007aff;
  2927. border-radius: 10rpx;
  2928. background-color: rgba(0, 122, 255, 0.1);
  2929. font-size: 28rpx;
  2930. color: #007aff;
  2931. margin-right: 15rpx;
  2932. }
  2933. }
  2934. .firstLetter {
  2935. display: flex;
  2936. justify-content: space-between;
  2937. align-items: center;
  2938. margin-bottom: 30rpx;
  2939. }
  2940. .popupView {
  2941. height: 100%;
  2942. padding-bottom: 100rpx;
  2943. .popupTops {
  2944. height: 77rpx;
  2945. border-bottom: 1rpx solid #eee;
  2946. text-align: center;
  2947. line-height: 77rpx;
  2948. font-size: 24rpx;
  2949. color: #999;
  2950. position: relative;
  2951. .topIcon {
  2952. position: absolute;
  2953. top: 10rpx;
  2954. left: 50%;
  2955. transform: translateX(-50%);
  2956. width: 80rpx;
  2957. height: 8rpx;
  2958. background-color: #999;
  2959. border-radius: 4rpx;
  2960. }
  2961. }
  2962. .popupContent {
  2963. }
  2964. }
  2965. .pageContent {
  2966. position: relative;
  2967. background-color: #eaeef1;
  2968. height: 100%;
  2969. padding-top: 8rpx;
  2970. padding-bottom: 100rpx;
  2971. overflow-y: scroll;
  2972. }
  2973. .pad_8 {
  2974. background-color: #fff;
  2975. margin: 0rpx 8rpx 8rpx;
  2976. border-radius: 16rpx;
  2977. &.no-margin {
  2978. margin-top: -16rpx;
  2979. border-radius: 0 0 16rpx 16rpx;
  2980. }
  2981. }
  2982. .answer {
  2983. height: 80rpx;
  2984. line-height: 80rpx;
  2985. padding: 0rpx 24rpx;
  2986. display: flex;
  2987. align-items: center;
  2988. justify-content: space-between;
  2989. color: #666;
  2990. font-size: 30rpx;
  2991. }
  2992. .footer_btn {
  2993. background-color: #fff;
  2994. z-index: 10078;
  2995. position: fixed;
  2996. bottom: 0rpx;
  2997. display: flex;
  2998. align-items: center;
  2999. justify-content: space-between;
  3000. width: 100%;
  3001. height: 98rpx;
  3002. padding: 0rpx 38rpx;
  3003. border-top: 1rpx solid #eee;
  3004. .flex_center {
  3005. flex: 1;
  3006. display: flex;
  3007. justify-content: center;
  3008. align-items: center;
  3009. flex-direction: column;
  3010. margin: 0 200rpx;
  3011. font-size: 24rpx;
  3012. color: #999999;
  3013. .up-icon {
  3014. margin-bottom: 18rpx;
  3015. width: 100%;
  3016. display: flex;
  3017. justify-content: center;
  3018. image {
  3019. width: 58rpx;
  3020. height: 21rpx;
  3021. }
  3022. }
  3023. }
  3024. .collect {
  3025. visibility: hidden;
  3026. width: 100rpx;
  3027. &.show {
  3028. visibility: visible;
  3029. }
  3030. > view {
  3031. display: flex;
  3032. flex-direction: column;
  3033. align-items: center;
  3034. justify-content: center;
  3035. image {
  3036. width: 32rpx;
  3037. height: 32rpx;
  3038. margin-bottom: 6rpx;
  3039. }
  3040. view {
  3041. font-size: 24rpx;
  3042. color: #999999;
  3043. }
  3044. }
  3045. }
  3046. }
  3047. .boxSty {
  3048. padding: 44rpx 41rpx 0rpx;
  3049. }
  3050. .liListSty {
  3051. border: 1rpx solid #eeeeee;
  3052. width: 88rpx;
  3053. height: 88rpx;
  3054. border-radius: 32rpx;
  3055. text-align: center;
  3056. line-height: 88rpx;
  3057. color: #333;
  3058. font-size: 32rpx;
  3059. float: left;
  3060. margin: 20rpx 23rpx;
  3061. &.isRight {
  3062. border: 1rpx solid #eeeeee;
  3063. color: #fff;
  3064. background: #36c75a;
  3065. }
  3066. &.isWrong {
  3067. border: 1rpx solid #eeeeee;
  3068. color: #fff;
  3069. background: #ff3b30;
  3070. }
  3071. &.isPart {
  3072. border: 1rpx solid #eeeeee;
  3073. color: #fff;
  3074. background: #ffc53d;
  3075. }
  3076. &.isOver {
  3077. border: 1rpx solid #eeeeee;
  3078. color: #fff;
  3079. background: blue;
  3080. }
  3081. &.check_ans {
  3082. border: 1rpx solid #eeeeee;
  3083. color: #fff;
  3084. background: #007aff;
  3085. }
  3086. }
  3087. .answerInfos {
  3088. padding: 25rpx 25rpx 25rpx 23rpx;
  3089. }
  3090. .answerTitle {
  3091. margin-bottom: 28rpx;
  3092. color: #666;
  3093. font-size: 30rpx;
  3094. }
  3095. .answerContent {
  3096. font-size: 30rpx;
  3097. color: #666;
  3098. }
  3099. .textChild {
  3100. display: inline-block;
  3101. vertical-align: middle;
  3102. }
  3103. .dialog {
  3104. position: fixed;
  3105. left: 0;
  3106. top: 0;
  3107. width: 100%;
  3108. height: 100%;
  3109. background-color: rgba(0, 0, 0, 0.8);
  3110. display: flex;
  3111. flex-direction: column;
  3112. align-items: center;
  3113. justify-content: center;
  3114. z-index: 20000;
  3115. .pointer {
  3116. width: 338rpx;
  3117. height: 240rpx;
  3118. }
  3119. .text {
  3120. font-size: 32rpx;
  3121. color: #ffffff;
  3122. text-align: center;
  3123. }
  3124. .btn {
  3125. width: 242rpx;
  3126. height: 82rpx;
  3127. border: 2rpx solid #ffffff;
  3128. border-radius: 16rpx;
  3129. text-align: center;
  3130. line-height: 82rpx;
  3131. margin: 41rpx auto;
  3132. color: #fff;
  3133. font-size: 32rpx;
  3134. }
  3135. }
  3136. .dialog-arrow {
  3137. padding-top: 124rpx;
  3138. position: fixed;
  3139. left: 0;
  3140. top: 0;
  3141. width: 100%;
  3142. height: 100%;
  3143. background-color: rgba(0, 0, 0, 0.8);
  3144. z-index: 20000;
  3145. .pointer {
  3146. margin-left: 87rpx;
  3147. display: block;
  3148. width: 95rpx;
  3149. height: 98rpx;
  3150. }
  3151. .text {
  3152. padding-left: 177rpx;
  3153. font-size: 32rpx;
  3154. color: #ffffff;
  3155. }
  3156. .btn {
  3157. width: 242rpx;
  3158. height: 82rpx;
  3159. border: 2rpx solid #ffffff;
  3160. border-radius: 16rpx;
  3161. text-align: center;
  3162. line-height: 82rpx;
  3163. margin: 500rpx auto 0;
  3164. color: #fff;
  3165. font-size: 32rpx;
  3166. }
  3167. }
  3168. .dialog_wrap {
  3169. position: fixed;
  3170. left: 0;
  3171. top: 0;
  3172. width: 100%;
  3173. height: 100%;
  3174. z-index: 9999999999;
  3175. .bg {
  3176. background: rgba(0, 0, 0, 0.3);
  3177. position: absolute;
  3178. left: 0;
  3179. top: 0;
  3180. width: 100%;
  3181. height: 100%;
  3182. }
  3183. .dialog {
  3184. position: absolute;
  3185. left: 50%;
  3186. top: 50%;
  3187. transform: translate3D(-50%, -50%, 0);
  3188. width: 640rpx;
  3189. height: 439rpx;
  3190. background: #ffffff;
  3191. border-radius: 24rpx;
  3192. .title {
  3193. font-size: 30rpx;
  3194. font-weight: bold;
  3195. color: #333333;
  3196. line-height: 48rpx;
  3197. text-align: center;
  3198. margin-top: 40rpx;
  3199. }
  3200. .content {
  3201. margin: 35rpx 35rpx 0;
  3202. font-size: 30rpx;
  3203. color: #666666;
  3204. line-height: 48rpx;
  3205. }
  3206. .btns {
  3207. margin-top: 35rpx;
  3208. display: flex;
  3209. align-items: center;
  3210. justify-content: center;
  3211. .btn {
  3212. width: 200rpx;
  3213. height: 80rpx;
  3214. line-height: 80rpx;
  3215. text-align: center;
  3216. background: #f5f5f5;
  3217. border-radius: 40rpx;
  3218. font-size: 30rpx;
  3219. color: rgba(0, 122, 255, 1);
  3220. background: #f5f5f5;
  3221. margin: 0 20rpx;
  3222. &.active {
  3223. color: #f5f5f5;
  3224. background: rgba(0, 122, 255, 1);
  3225. }
  3226. }
  3227. }
  3228. }
  3229. }
  3230. .popboxs {
  3231. width: 100%;
  3232. height: 100%;
  3233. display: flex;
  3234. flex-direction: column;
  3235. align-items: center;
  3236. }
  3237. .classTops {
  3238. flex-shrink: 0;
  3239. padding: 39rpx 0rpx 4rpx;
  3240. font-weight: bold;
  3241. color: #333;
  3242. font-size: 30rpx;
  3243. }
  3244. .textStys {
  3245. width: 100%;
  3246. flex: 1;
  3247. padding: 36rpx;
  3248. }
  3249. .classFootsty {
  3250. flex-shrink: 0;
  3251. display: flex;
  3252. align-items: center;
  3253. justify-content: center;
  3254. padding: 10rpx 0rpx 40rpx;
  3255. .btnsty {
  3256. width: 200rpx;
  3257. height: 80rpx;
  3258. border-radius: 40rpx;
  3259. font-weight: bold;
  3260. font-size: 30rpx;
  3261. text-align: center;
  3262. line-height: 80rpx;
  3263. }
  3264. .btns1 {
  3265. background-color: #f5f5f5;
  3266. color: #007aff;
  3267. }
  3268. .btns2 {
  3269. margin-left: 40rpx;
  3270. background-color: #007aff;
  3271. color: #ffffff;
  3272. }
  3273. }
  3274. </style>