questionBank.vue 101 KB

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