questionBank.vue 100 KB

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