questionBank.vue 100 KB

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