questionBank.vue 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar class="navbar" @clickLeft="clickLeft" left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
  4. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  5. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  6. <view class="pageContent">
  7. <view class="pad_8 titBox">
  8. <view class="firstLetter">
  9. <view class="leftLetters">
  10. <view class="btnType">
  11. <text v-if="bank.type == 1">单选</text>
  12. <text v-if="bank.type == 2">多选</text>
  13. <text v-if="bank.type == 3">判断</text>
  14. <text v-if="bank.type == 4">案例</text>
  15. <text v-if="bank.type == 5">简答</text>
  16. </view>
  17. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  18. </view>
  19. <view style="color: #666;font-size: 28rpx;">{{ countdown(lastTime) }}</view>
  20. <view class="leftLetters"></view>
  21. </view>
  22. <view class="titles"><rich-text :nodes="bank.content"></rich-text></view>
  23. </view>
  24. <template v-if="bank.type == 1">
  25. <view class="pad_8 titBox no-margin">
  26. <view v-if="!bank.ques">
  27. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId, bankIndex)">
  28. <view class="activeTI">{{ ast[index] }}</view>
  29. <view class="flex_auto">{{ item.content }}</view>
  30. </view>
  31. </view>
  32. <view v-if="bank.ques">
  33. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  34. <text
  35. :class="{ right: item.optionsId == bank.ques || item.optionsId == bank.ans, wrong: item.optionsId == bank.ques && bank.ques != bank.ans }"
  36. class="activeTI"
  37. >
  38. {{ ast[index] }}
  39. </text>
  40. <view class="flex_auto">{{ item.content }}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="bank.ques">
  45. <view class="pad_8 answer">
  46. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  47. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  48. </view>
  49. <view class="pad_8 answerInfos">
  50. <view class="answerTitle">答案解析</view>
  51. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  52. </view>
  53. </view>
  54. </template>
  55. <template v-if="bank.type == 2">
  56. <view class="pad_8 titBox no-margin">
  57. <view v-if="!bank.ques">
  58. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId, bankIndex, index)">
  59. <view :class="{ checked: item.checked }" class="activeTI">{{ ast[index] }}</view>
  60. <view class="flex_auto">{{ item.content }}</view>
  61. </view>
  62. </view>
  63. <view v-if="!bank.ques" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(bank.jsonStr)}" @click="checkboxSubmit(bankIndex)">确认答案</view>
  64. <view v-if="bank.ques">
  65. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  66. <text
  67. :class="{
  68. right: bank.ques.indexOf(item.optionsId) != -1 || bank.ans.indexOf(item.optionsId) != -1,
  69. wrong: bank.ques.indexOf(item.optionsId) != -1 && bank.ans.indexOf(item.optionsId) == -1
  70. }"
  71. class="activeTI"
  72. >
  73. {{ ast[index] }}
  74. </text>
  75. <view class="flex_auto">{{ item.content }}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view v-if="bank.ques">
  80. <view class="pad_8 answer">
  81. <view>
  82. 正确答案:
  83. <text v-for="(ansItem,ansItemIndex) in bank.ans" :key="ansItemIndex">{{ ast[ansItem - 1] }}</text>
  84. </view>
  85. <view>
  86. 我的答案:
  87. <text v-for="(quesItem,quesItemIndex) in bank.ques" :key="quesItemIndex">{{ ast[quesItem - 1] }}</text>
  88. </view>
  89. </view>
  90. <view class="pad_8 answerInfos">
  91. <view class="answerTitle">答案解析</view>
  92. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  93. </view>
  94. </view>
  95. </template>
  96. <template v-if="bank.type == 3">
  97. <view class="pad_8 titBox no-margin">
  98. <view v-if="!bank.ques">
  99. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index, bankIndex)">
  100. <view class="activeTI">{{ ast[index] }}</view>
  101. <view class="flex_auto">
  102. {{ item }}
  103. </view>
  104. </view>
  105. </view>
  106. <view v-if="bank.ques">
  107. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  108. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  109. {{ ast[index] }}
  110. </text>
  111. <view class="flex_auto">
  112. {{ item }}
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view v-if="bank.ques">
  118. <view class="pad_8 answer">
  119. <view>正确答案:{{ ast[bank.ans] }}</view>
  120. <view>我的答案:{{ ast[bank.ques] }}</view>
  121. </view>
  122. <view class="pad_8 answerInfos">
  123. <view class="answerTitle">答案解析</view>
  124. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  125. </view>
  126. </view>
  127. </template>
  128. <!-- 简答题 -->
  129. <template v-if="bank.type == 5">
  130. <view class="pad_8 titBox">
  131. <view class="ans">
  132. <view class="ans_input" v-if="!bank.ques || (!bank.ques.text && !bank.ques.imageList.length)">
  133. <view class="top flex">
  134. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/camera.png" mode=""></image>
  135. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  136. <view class="submit" :class="{disabled:!bank.ansText.text && hasImgs(bank)}" @click="submitAns(bankIndex)">确认答案</view>
  137. </view>
  138. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  139. <view class="imgs">
  140. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList" :key="imgIndex">
  141. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  142. <image :src="$method.splitImgHost(img, true)"></image>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="ans_submit answerInfos" v-if="bank.ques.text || bank.ques.imageList.length">
  147. <view class="answerTitle">我的答案:</view>
  148. {{ bank.ques.text }}
  149. <view class="imgs"><image class="img" v-for="(ques,quesIndex) in bank.ques.imageList" :key="quesIndex" :src="$method.splitImgHost(ques, true)"></image></view>
  150. </view>
  151. </view>
  152. </view>
  153. <view v-if="bank.ques && (bank.ques.text || bank.ques.imageList.length)">
  154. <view class="pad_8 answerInfos">
  155. <view class="answerTitle">答案解析:</view>
  156. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  157. </view>
  158. </view>
  159. </template>
  160. <!-- 案例题 -->
  161. <template v-if="bank.type == 4">
  162. <view class="tabs">
  163. <view
  164. class="tab"
  165. :class="{ current: tabIndex == bank.current }"
  166. :key="tabIndex"
  167. v-for="(tab, tabIndex) in bank.jsonStr"
  168. @click="tabSelect(tabIndex, bankIndex)"
  169. >
  170. 问题{{ tabIndex+1 }}
  171. </view>
  172. </view>
  173. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  174. <template v-if="ansItem.type == 1">
  175. <view class="pad_8 titBox">
  176. <view class="leftLetters">
  177. <view class="btnType">
  178. <text>单选</text>
  179. </view>
  180. </view>
  181. <view class="titles">
  182. <rich-text :nodes="ansItem.content"></rich-text>
  183. </view>
  184. <view v-if="!bank.ques[ansIndex]">
  185. <view
  186. v-for="(option, childIndex) in ansItem.optionsList"
  187. :key="childIndex"
  188. class="lisSty"
  189. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  190. >
  191. <view class="activeTI">{{ ast[childIndex] }}</view>
  192. <view class="flex_auto">
  193. <rich-text class="textChild" :nodes="option.content"></rich-text>
  194. </view>
  195. </view>
  196. </view>
  197. <view v-if="bank.ques[ansIndex]">
  198. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty">
  199. <text
  200. :class="{
  201. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  202. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  203. }"
  204. class="activeTI"
  205. >
  206. {{ ast[childIndex] }}
  207. </text>
  208. <view class="flex_auto">
  209. <rich-text :nodes="option.content"></rich-text>
  210. </view>
  211. </view>
  212. </view>
  213. </view>
  214. <view v-if="bank.ques[ansIndex]">
  215. <view class="pad_8 answer">
  216. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  217. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  218. </view>
  219. <view class="pad_8 answerInfos">
  220. <view class="answerTitle">答案解析</view>
  221. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  222. </view>
  223. </view>
  224. </template>
  225. <template v-if="ansItem.type == 2">
  226. <view class="pad_8 titBox">
  227. <view class="leftLetters">
  228. <view class="btnType">
  229. <text>多选</text>
  230. </view>
  231. </view>
  232. <view class="titles">
  233. <rich-text :nodes="ansItem.content"></rich-text>
  234. </view>
  235. <view v-if="!bank.ques[ansIndex]">
  236. <view
  237. v-for="(option, childindex) in ansItem.optionsList"
  238. :key="childindex"
  239. class="lisSty"
  240. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  241. >
  242. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  243. <view class="flex_auto">
  244. <rich-text :nodes="option.content"></rich-text>
  245. </view>
  246. </view>
  247. </view>
  248. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(ansItem.optionsList)}" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  249. <view v-if="bank.ques && bank.ques[ansIndex]">
  250. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  251. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  252. {{ ast[childindex] }}
  253. </text>
  254. <view class="flex_auto">
  255. <rich-text :nodes="option.content"></rich-text>
  256. </view>
  257. </view>
  258. </view>
  259. </view>
  260. <view v-if="bank.ques[ansIndex]">
  261. <view class="pad_8 answer">
  262. <view>
  263. 正确答案:
  264. <text :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  265. </view>
  266. <view>
  267. 我的答案:
  268. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  269. </view>
  270. </view>
  271. <view class="pad_8 answerInfos">
  272. <view class="answerTitle">答案解析</view>
  273. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  274. </view>
  275. </view>
  276. </template>
  277. <template v-if="ansItem.type == 3">
  278. <view class="pad_8 titBox">
  279. <view class="leftLetters">
  280. <view class="btnType">
  281. <text>判断</text>
  282. </view>
  283. </view>
  284. <view class="titles">
  285. <rich-text :nodes="ansItem.content"></rich-text>
  286. </view>
  287. <view v-if="!bank.ques[ansIndex]">
  288. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  289. <view class="activeTI">{{ ast[childindex] }}</view>
  290. <view class="flex_auto">
  291. {{ option }}
  292. </view>
  293. </view>
  294. </view>
  295. <view v-if="bank.ques[ansIndex]">
  296. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  297. <text
  298. :class="{
  299. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  300. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  301. }"
  302. class="activeTI"
  303. >
  304. {{ ast[childindex] }}
  305. </text>
  306. <view class="flex_auto">
  307. {{ option }}
  308. </view>
  309. </view>
  310. </view>
  311. </view>
  312. <view v-if="bank.ques[ansIndex]">
  313. <view class="pad_8 answer">
  314. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  315. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  316. </view>
  317. <view class="pad_8 answerInfos">
  318. <view class="answerTitle">答案解析</view>
  319. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  320. </view>
  321. </view>
  322. </template>
  323. <!-- 简答题 -->
  324. <template v-if="ansItem.type == 5">
  325. <view class="pad_8 titBox_title">
  326. <view class="leftLetters">
  327. <view class="btnType">
  328. <text>简答</text>
  329. </view>
  330. </view>
  331. <view class="titles">
  332. <rich-text :nodes="ansItem.content"></rich-text>
  333. </view>
  334. </view>
  335. <view class="pad_8 titBox_title">
  336. <view class="ans">
  337. <view class="ans_input" v-if="!bank.ques[ansIndex] || (!bank.ques[ansIndex].text && !bank.ques[ansIndex].imageList.length)">
  338. <view class="top flex">
  339. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  340. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  341. <view class="submit" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  342. </view>
  343. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  344. <view class="imgs">
  345. <view class="img" :key="imgIndex" v-for="(img, imgIndex) in ansItem.ansText.imageList">
  346. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  347. <image :src="$method.splitImgHost(img, true)"></image>
  348. </view>
  349. </view>
  350. </view>
  351. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  352. <view class="answerTitle">我的答案</view>
  353. {{ bank.ques[ansIndex].text }}
  354. <view class="imgs">
  355. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques, true)"></image>
  356. </view>
  357. </view>
  358. </view>
  359. </view>
  360. <view v-if="bank.ques[ansIndex]">
  361. <view class="pad_8 answerInfos">
  362. <view class="answerTitle">答案解析</view>
  363. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  364. </view>
  365. </view>
  366. </template>
  367. </view>
  368. </template>
  369. <view class="footer_btn">
  370. <view class="collect">
  371. <view v-if="collectList[bankIndex]">
  372. <image src="/static/icon/collected.png" mode=""></image>
  373. <view>取消收藏</view>
  374. </view>
  375. </view>
  376. <view class="flex_center" @click="openFooterTab">
  377. <view class="up-icon">
  378. <image src="/static/up.png"></image>
  379. </view>
  380. 答题卡
  381. </view>
  382. <view class="collect show" @click="pdsubmit">
  383. <view>
  384. <image src="/static/jj.png" mode=""></image>
  385. <view>交卷</view>
  386. </view>
  387. </view>
  388. </view>
  389. </view>
  390. </swiper-item>
  391. </swiper>
  392. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  393. <view class="popupView">
  394. <view class="popupTops">
  395. <view class="topIcon"></view>
  396. 点击编号即可跳转至对应题目
  397. </view>
  398. <view class="popupContent">
  399. <scroll-view scroll-y="true" style="height: 506rpx;">
  400. <view class="boxSty">
  401. <view
  402. v-for="(item, index) in questionList"
  403. :key="index"
  404. @click="changeIndex(index)"
  405. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  406. class="liListSty"
  407. >
  408. {{ index + 1 }}
  409. </view>
  410. </view>
  411. </scroll-view>
  412. </view>
  413. </view>
  414. </u-popup>
  415. <view class="dialog" v-if="showDialog">
  416. <view class="text">左右滑动切换上下题</view>
  417. <view class="btn" @click="hideDialog">我知道了</view>
  418. </view>
  419. <view class="dialog-arrow" v-if="showArrow">
  420. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  421. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  422. <view class="btn" @click="showArrow = false">我知道了</view>
  423. </view>
  424. <view class="dialog_wrap" v-if="testOver">
  425. <view class="bg"></view>
  426. <view class="dialog">
  427. <view class="title">温馨提示</view>
  428. <view class="content">
  429. <view>您已完成所有题目,</view>
  430. <view>快去交卷吧!</view>
  431. </view>
  432. <view class="btns">
  433. <view class="btn" @click="noSubmit()">暂不交卷</view>
  434. <view class="btn active" @click="submitNow()">立即交卷</view>
  435. </view>
  436. </view>
  437. </view>
  438. <view class="dialog_wrap" v-if="isLastCount">
  439. <view class="bg"></view>
  440. <view class="dialog">
  441. <view class="title">温馨提示</view>
  442. <view class="content">
  443. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  444. </view>
  445. <view class="btns">
  446. <view class="btn" @click="noLeave()">暂不离开</view>
  447. <view class="btn active" @click="leaveNow()">继续离开</view>
  448. </view>
  449. </view>
  450. </view>
  451. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  452. <view class="popboxs">
  453. <view class="classTops">温馨提示</view>
  454. <view class="textStys">
  455. {{
  456. cgType === 7
  457. ? '您还未交卷,确定结束做题吗?'
  458. : cgType === 8
  459. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  460. : cgType === 6
  461. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  462. : cgType == 9
  463. ? `您已完成所有题目,快去交卷吧!`
  464. : ''
  465. }}
  466. </view>
  467. <view class="classFootsty" v-if="cgType === 6">
  468. <view class="btnsty btns1" @click="submit">立即交卷</view>
  469. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  470. </view>
  471. <view class="classFootsty" v-if="cgType === 7">
  472. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  473. <view class="btnsty btns2" @click="backPages">结束做题</view>
  474. </view>
  475. <view class="classFootsty" v-if="cgType === 8">
  476. <view class="btnsty btns1" @click="leaveNow()">下次继续</view>
  477. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  478. </view>
  479. <view class="classFootsty" v-if="cgType === 9">
  480. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  481. <view class="btnsty btns2" @click="submit">立即交卷</view>
  482. </view>
  483. </view>
  484. </u-popup>
  485. <u-mask :show="photoPopup" >
  486. <!-- 播放前拍照start -->
  487. <view v-if="photoPopup" :mask-close-able="false" style="bottom: 0;position: fixed;width: 100%;z-index: 999;">
  488. <view class="photoBox">
  489. <view class="photoTop">
  490. <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
  491. <view class="centersq">请正视手机屏幕</view>
  492. <view class="sqzz"></view>
  493. </view>
  494. <view class="photoCenter">
  495. <view style="width: 100%; height: 979rpx;position: fixed;" v-if="photoPopup">
  496. <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%;" ></camera>
  497. </view>
  498. <view class="custom"><image src="/static/zhezhao.png" mode=""></image></view>
  499. </view>
  500. <view class="btnResult" @click="takePhoto">拍照</view>
  501. </view>
  502. </view>
  503. </u-mask>
  504. </view>
  505. </template>
  506. <script>
  507. export default {
  508. data() {
  509. return {
  510. photoPopup:false,
  511. showpopups: false,
  512. id: '',
  513. current: 0,
  514. questionList: [],
  515. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  516. judge: ['错误', '正确'],
  517. ans: [],
  518. ques: [],
  519. show: false,
  520. showDialog: false,
  521. bankList: [],
  522. collectList: [],
  523. goodsId: '',
  524. recordId: '',
  525. isSubmit: false,
  526. lastTime: 0, //剩余考试时长
  527. allTimes: 0, //总考试时长
  528. timer: null,
  529. wrongList: [],
  530. bankType: 0, //试卷类型
  531. needBack: false, //是否是考试
  532. testOver: false,
  533. isLastCount: false, //是否有未答题目
  534. lastCount: 0, //剩余没有回答的题目数
  535. chapterId: 0,
  536. moduleId: 0,
  537. showArrow:false, //退出提示
  538. isFromVideo:'',
  539. gradeId:'',
  540. courseId:0,
  541. cgType: 0 ,//对应设计稿弹窗编码,
  542. avatarUrl:'',
  543. ossAvatarUrl: '',
  544. goodsDetail:{},
  545. isTakePhoto:false,
  546. needPhoto:false //是否需要拍照
  547. };
  548. },
  549. async onLoad(option) {
  550. this.id = option.id;
  551. this.goodsId = option.goodsid;
  552. this.chapterId = option.chapterId;
  553. this.courseId = option.courseId;
  554. this.moduleId = option.moduleId;
  555. this.isFromVideo = option.isFromVideo||'';
  556. this.gradeId = option.gradeId || '';
  557. let isBack = option.isback;
  558. let showDialog = uni.getStorageSync('showDialog');
  559. if(showDialog) {
  560. this.showDialog = false;
  561. } else {
  562. this.showDialog = true;
  563. uni.setStorageSync('showDialog','1');
  564. }
  565. //考试时候用手势或者返回键 被迫返回做题
  566. if (isBack) {
  567. console.log(getApp());
  568. let app = getApp();
  569. let globalData = app.globalData;
  570. for (var k in globalData.bankData) {
  571. this[k] = globalData.bankData[k];
  572. }
  573. this.showArrow = true;
  574. //需要拍没拍过直接弹出摄像头
  575. if(this.needPhoto && !this.isTakePhoto) {
  576. this.photoPopup = true;
  577. } else { //不需要拍照
  578. if(this.lastTime) {
  579. this.timer = setInterval(() => {
  580. if (this.lastTime <= 0) {
  581. clearInterval(this.timer);
  582. uni.showToast({
  583. icon:'none',
  584. mask:true,
  585. title:'考试时间已到,系统将自动交卷',
  586. duration:10000
  587. })
  588. this.submit();
  589. return;
  590. }
  591. this.lastTime--;
  592. }, 1000);
  593. }
  594. }
  595. } else {
  596. await this.getGoodsDetail()
  597. this.goodsQuestionList();
  598. this.bankExam();
  599. }
  600. },
  601. onUnload() {
  602. if (this.isSubmit) {
  603. clearInterval(this.timer)
  604. return;
  605. }
  606. if(this.needPhoto && !this.isTakePhoto) {
  607. return;
  608. }
  609. //考试试卷 阻止ios手势返回,自动跳回答题页
  610. if (this.needBack) {
  611. let app = getApp();
  612. app.globalData.bankData = this.$data;
  613. clearInterval(this.timer);
  614. uni.navigateTo({
  615. url: '/pages2/class/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  616. });
  617. } else {
  618. //点击返回按钮确认允许退出,交卷
  619. clearInterval(this.timer)
  620. this.examRecordEdit();
  621. }
  622. },
  623. methods: {
  624. getGoodsDetail() {
  625. return new Promise((resolve) => {
  626. let self = this
  627. this.$api.goodsDetail(this.goodsId).then(res => {
  628. self.goodsDetail = res.data.data;
  629. if (self.goodsDetail.goodsPhotoExamConfig) {
  630. let goodsPhotoExamConfig = JSON.parse(self.goodsDetail.goodsPhotoExamConfig);
  631. if (goodsPhotoExamConfig.photograph > 0) {
  632. self.needPhoto = true;
  633. }
  634. }
  635. resolve()
  636. });
  637. })
  638. },
  639. postStudyRecord() {
  640. let self = this
  641. let data = {
  642. photo: self.ossAvatarUrl,
  643. recordId: self.recordId
  644. };
  645. console.log(data,"拍照提交")
  646. this.$api.studyExamPhotoRecord(data).then(res => {
  647. console.log(res,"拍照提交结果")
  648. if(res.data.code!=200){
  649. uni.showToast({
  650. icon:'none',
  651. mask:true,
  652. title:res.data.msg,
  653. duration:10000
  654. })
  655. return
  656. }
  657. self.ossAvatarUrl = ''
  658. self.isTakePhoto = true;
  659. //拍照
  660. if(this.lastTime) {
  661. this.timer = setInterval(() => {
  662. if (this.lastTime <= 0) {
  663. clearInterval(this.timer);
  664. uni.showToast({
  665. icon:'none',
  666. mask:true,
  667. title:'考试时间已到,系统将自动交卷',
  668. duration:10000
  669. })
  670. this.submit();
  671. return;
  672. }
  673. this.lastTime--;
  674. }, 1000);
  675. }
  676. });
  677. },
  678. uploadFile(options, int) {
  679. var self = this;
  680. return new Promise((resolve, reject) => {
  681. var data = {
  682. imageStatus: int,
  683. gradeId:this.gradeId
  684. };
  685. self.$api.aliyunpolicy(data).then(res => {
  686. if (res.data.code != 200) {
  687. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  688. return;
  689. }
  690. var ossToken = res.data.data.resultContent;
  691. if (ossToken.host == null || ossToken.host == undefined) {
  692. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  693. return;
  694. }
  695. uni.uploadFile({
  696. url: ossToken.host,
  697. name: 'file',
  698. filePath: options,
  699. fileType: 'image',
  700. header: {
  701. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  702. },
  703. formData: {
  704. key: ossToken.dir,
  705. OSSAccessKeyId: ossToken.accessid,
  706. policy: ossToken.policy,
  707. Signature: ossToken.signature,
  708. callback: ossToken.callback,
  709. success_action_status: 200
  710. },
  711. success: result => {
  712. if (result.statusCode === 200) {
  713. self.ossAvatarUrl = ossToken.dir;
  714. resolve();
  715. } else {
  716. uni.showToast({
  717. title: '上传失败',
  718. icon: 'none'
  719. });
  720. return;
  721. }
  722. },
  723. fail: error => {
  724. uni.showToast({
  725. title: '上传接口报错' + error,
  726. icon: 'none'
  727. });
  728. return;
  729. }
  730. });
  731. });
  732. });
  733. },
  734. imageInfos() {
  735. var self = this;
  736. return new Promise((resolve, reject) => {
  737. uni.getImageInfo({
  738. src: self.avatarUrl,
  739. success: async res => {
  740. let canvasWidth = res.width; //图片原始长宽
  741. let canvasHeight = res.height;
  742. if (canvasWidth > 2000 || canvasHeight > 2000) {
  743. uni.compressImage({
  744. src: self.avatarUrl,
  745. quality: 75,
  746. width: '35%',
  747. height: '35%',
  748. success: async rest => {
  749. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  750. resolve(waitUpload);
  751. }
  752. });
  753. } else if(canvasWidth > 1000 || canvasHeight > 1000){
  754. uni.compressImage({
  755. src: self.avatarUrl,
  756. quality: 75,
  757. width: '50%',
  758. height: '50%',
  759. success: async rest => {
  760. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  761. resolve(waitUpload);
  762. }
  763. });
  764. } else {
  765. console.log('无需压缩');
  766. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  767. resolve();
  768. }
  769. }
  770. });
  771. });
  772. },
  773. async submitPhoto() {
  774. const waitYS = await this.imageInfos();
  775. this.postStudyRecord(); //提交记录
  776. },
  777. //确认拍照
  778. takePhoto() {
  779. var self = this;
  780. const ctx = uni.createCameraContext();
  781. ctx.takePhoto({
  782. quality: 'high',
  783. success: res => {
  784. console.log(res.tempImagePath);
  785. self.avatarUrl = res.tempImagePath;
  786. self.submitPhoto();
  787. self.photoPopup = false;
  788. },
  789. fail: err => {
  790. console.log(err);
  791. }
  792. });
  793. },
  794. /**
  795. * 是否有上传图片
  796. */
  797. hasImgs(bank) {
  798. return bank.ansText.imageList.length == 0;
  799. },
  800. /**
  801. * 获取试卷类型2考试,1练习
  802. */
  803. bankExam() {
  804. this.$api.bankExam(this.id).then(res => {
  805. this.bankType = res.data.data.doType;
  806. if (this.bankType == 2) {
  807. this.needBack = true;
  808. }
  809. });
  810. },
  811. /**
  812. * 点击后退按钮
  813. */
  814. clickLeft() {
  815. //需要拍照没有拍直接返回
  816. if(this.needPhoto && !this.isTakePhoto) {
  817. this.isSubmit = true;
  818. uni.navigateBack({
  819. delta:1
  820. })
  821. return;
  822. }
  823. if (this.bankType == 1) {
  824. let ansCount = this.questionOverNum(); //已答题数
  825. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  826. //所有题目答完
  827. if (this.lastCount == 0) {
  828. // this.testOver = true;
  829. this.cgType = 7;
  830. //未答完
  831. } else {
  832. this.cgType = 8;
  833. // this.isLastCount = true;
  834. }
  835. this.showpopups = true;
  836. } else if (this.bankType == 2) {
  837. let ansCount = this.questionOverNum(); //已答题数
  838. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  839. //所有题目答完
  840. if (this.lastCount == 0) {
  841. this.testOver = true;
  842. //未答完
  843. } else {
  844. this.isLastCount = true;
  845. }
  846. }
  847. },
  848. /**
  849. * 返回上一页
  850. */
  851. backPages() {
  852. this.needBack = false;
  853. uni.navigateBack({
  854. delta: 1
  855. });
  856. },
  857. /**
  858. * 获取已经回答的题目数
  859. * hasSpecail (是否包含简答和案例)
  860. */
  861. questionOverNum(hasSpecail) {
  862. let count = 0;
  863. this.questionList.forEach(item => {
  864. if (item.type == 1 || item.type == 2 || item.type == 3) {
  865. if (item.ques) {
  866. count++;
  867. }
  868. } else if (item.type == 4) {
  869. //案例题
  870. if(hasSpecail) {
  871. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  872. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  873. if (item.ques[indexs]) {
  874. return true;
  875. } else {
  876. return false;
  877. }
  878. } else if (jsonItem.type == 5) {
  879. console.log(jsonItem, 111);
  880. if (item.ques[indexs] && (item.ques[indexs].text.length || item.ques[indexs].imageList.length)) {
  881. return true;
  882. } else {
  883. return false;
  884. }
  885. }
  886. });
  887. if (isOver) {
  888. count++;
  889. console.log(item, 444);
  890. }
  891. }
  892. } else if (item.type == 5) {
  893. //简答题
  894. if(hasSpecail) {
  895. if (item.ques && (item.ques.text.length || item.ques.imageList.length)) {
  896. count++;
  897. }
  898. }
  899. }
  900. });
  901. return count;
  902. },
  903. /**
  904. * 是否做完所有题目
  905. */
  906. isDoOver() {
  907. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  908. if(this.questionList.length == questionOverNum) { //全部做完弹窗
  909. this.cgType = 9;
  910. this.showpopups = true;
  911. }
  912. },
  913. /**
  914. * 暂不交卷
  915. */
  916. noSubmit() {
  917. //设为允许退出页面
  918. this.needBack = false;
  919. uni.navigateBack({
  920. delta: 1
  921. });
  922. },
  923. /**
  924. * 不离开
  925. */
  926. noLeave() {
  927. this.isLastCount = false;
  928. },
  929. /**
  930. * 立即离开并交卷
  931. */
  932. leaveNow() {
  933. this.isSubmit = true;
  934. uni.navigateBack({
  935. delta: 1
  936. });
  937. //需要拍照没有拍,返回不扣次数
  938. if(this.needPhoto && !this.isTakePhoto) {
  939. return;
  940. }
  941. let score = 0; //计算总分
  942. let reportStatus = 0;
  943. let number = 0;
  944. let doQuestionIds = []; //做过的题目id
  945. let doQuestionNum = 0; //做过的题目数量
  946. let passScore = 0;
  947. let allScore = 0; //总分
  948. this.questionList.forEach((item, index) => {
  949. passScore = item.passScore
  950. if (item.type == 1) {
  951. if (item.ques == item.ans) {
  952. item.scoreResult = item.score;
  953. score += item.score;
  954. number++;
  955. } else {
  956. item.scoreResult = 0;
  957. }
  958. if (item.ques) {
  959. doQuestionNum++;
  960. doQuestionIds.push(item.questionId)
  961. }
  962. allScore += item.score;
  963. } else if (item.type == 2) {
  964. let isRight =
  965. item.ques &&
  966. item.ques.every((quesItem, quesIndex) => {
  967. return item.ques[quesIndex] == item.ans[quesIndex];
  968. });
  969. if (isRight) { //全对
  970. item.scoreResult = item.score;
  971. score += item.score;
  972. number++;
  973. } else {
  974. let checkboxScore = item.score; //获取单题总分数
  975. item.ques && item.ques.forEach((ques,quesIndex) => {
  976. //选错一个全扣
  977. if(item.ques) {
  978. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  979. checkboxScore = 0;
  980. }
  981. } else {
  982. checkboxScore = 0;
  983. }
  984. })
  985. //没选错
  986. if(checkboxScore) {
  987. item.ans.forEach((ans,quesIndex) => {
  988. //漏选扣一部分
  989. if(item.ques) {
  990. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  991. checkboxScore = item.partScore;
  992. }
  993. } else {
  994. checkboxScore = 0;
  995. }
  996. })
  997. }
  998. if(checkboxScore <= 0) {
  999. item.scoreResult = 0;
  1000. } else {
  1001. item.scoreResult = checkboxScore;
  1002. }
  1003. score += checkboxScore;
  1004. }
  1005. if (item.ques && item.ques.length) {
  1006. doQuestionNum++;
  1007. doQuestionIds.push(item.questionId)
  1008. }
  1009. allScore += item.score;
  1010. } else if (item.type == 3) {
  1011. if (item.ques == item.ans) {
  1012. item.scoreResult = item.score;
  1013. score += item.score;
  1014. number++;
  1015. } else {
  1016. item.scoreResult = 0;
  1017. }
  1018. if (item.ques) {
  1019. doQuestionNum++;
  1020. doQuestionIds.push(item.questionId)
  1021. }
  1022. allScore += item.score;
  1023. } else {
  1024. allScore += item.score;
  1025. }
  1026. });
  1027. if(score >= passScore) {
  1028. reportStatus = 1
  1029. } else {
  1030. reportStatus = 0
  1031. }
  1032. this.$api
  1033. .bankRecordEdit({
  1034. chapterId:this.chapterId || 0,
  1035. moduleId:this.moduleId || 0,
  1036. examId: this.id,
  1037. goodsId: this.goodsId,
  1038. recordId:this.recordId,
  1039. courseId:this.courseId,
  1040. reportStatus:reportStatus,
  1041. rightQuestionNum: number,
  1042. doQuestionNum:doQuestionNum,
  1043. status: 1,
  1044. doQuestionIds:doQuestionIds.join(','),
  1045. gradeId:this.gradeId,
  1046. performance: score,
  1047. totalScore: allScore,
  1048. // examTime: parseInt(this.allTimes),
  1049. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1050. // historyExamJson: JSON.stringify(this.questionList)
  1051. })
  1052. .then(res => {});
  1053. },
  1054. /**
  1055. * 立即交卷
  1056. */
  1057. submitNow() {
  1058. this.showpopups = false;
  1059. this.needBack = false;
  1060. this.submit();
  1061. },
  1062. /**
  1063. * 离开页面统计回答正确题数
  1064. */
  1065. examRecordEdit() {
  1066. if (!this.isSubmit) {
  1067. let number = 0;
  1068. let score = 0;
  1069. let doQuestionNum = 0;
  1070. let reportStatus = 0;
  1071. this.questionList.forEach((item, index) => {
  1072. if (item.type == 1) {
  1073. if (item.ques == item.ans) {
  1074. score += item.score;
  1075. number++;
  1076. }
  1077. if (item.ques) {
  1078. doQuestionNum++;
  1079. }
  1080. } else if (item.type == 2) {
  1081. let isRight =
  1082. item.ques &&
  1083. item.ques.every((quesItem, quesIndex) => {
  1084. return item.ques[quesIndex] == item.ans[quesIndex];
  1085. });
  1086. if (isRight) {
  1087. score += item.score;
  1088. number++;
  1089. } else {
  1090. let checkboxScore = item.score; //获取单题总分数
  1091. item.ques.forEach((ques,quesIndex) => {
  1092. //选错一个全扣
  1093. if(item.ques) {
  1094. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1095. checkboxScore = 0;
  1096. }
  1097. } else {
  1098. checkboxScore = 0;
  1099. }
  1100. })
  1101. //没选错
  1102. if(checkboxScore) {
  1103. item.ans.forEach((ans,quesIndex) => {
  1104. //漏选扣一部分
  1105. if(item.ques) {
  1106. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1107. checkboxScore = item.partScore;
  1108. }
  1109. } else {
  1110. checkboxScore = 0;
  1111. }
  1112. })
  1113. }
  1114. if(checkboxScore <= 0) {
  1115. item.scoreResult = 0;
  1116. } else {
  1117. item.scoreResult = checkboxScore;
  1118. score += checkboxScore;
  1119. // number++;
  1120. }
  1121. }
  1122. if (item.ques && item.ques.length) {
  1123. doQuestionNum++;
  1124. }
  1125. } else if (item.type == 3) {
  1126. if (item.ques == item.ans) {
  1127. score += item.score;
  1128. number++;
  1129. }
  1130. if (item.ques) {
  1131. doQuestionNum++;
  1132. }
  1133. } else if (item == 4) {
  1134. if (item.ques.length) {
  1135. doQuestionNum++;
  1136. }
  1137. } else if (item.type == 5) {
  1138. if (item.ques) {
  1139. doQuestionNum++;
  1140. }
  1141. }
  1142. });
  1143. if(score >= 60) {
  1144. reportStatus = 1
  1145. }
  1146. this.$api
  1147. .bankRecordEdit({
  1148. chapterId:this.chapterId || 0,
  1149. moduleId:this.moduleId || 0,
  1150. gradeId:this.gradeId,
  1151. examId: this.id,
  1152. courseId:this.courseId,
  1153. goodsId: this.goodsId,
  1154. recordId:this.recordId,
  1155. performance:score,
  1156. reportStatus:reportStatus,
  1157. status: 1,
  1158. // historyExamJson: JSON.stringify(this.questionList)
  1159. })
  1160. .then(res => {});
  1161. }
  1162. },
  1163. /**
  1164. * @param {Object} second倒计时过滤器
  1165. */
  1166. countdown(second) {
  1167. if (second) {
  1168. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1169. let m = parseInt((second / 60) % 60); // 计算分数
  1170. let s = parseInt(second % 60); // 计算当前秒数
  1171. if (h < 10) h = '0' + h;
  1172. if (m < 10) m = '0' + m;
  1173. if (s < 10) s = '0' + s;
  1174. return h + ':' + m + ':' + s;
  1175. } else {
  1176. return '';
  1177. }
  1178. },
  1179. /**
  1180. * 请求题目列表
  1181. */
  1182. goodsQuestionList() {
  1183. this.$api
  1184. .goodsQuestionList({
  1185. examId: this.id
  1186. })
  1187. .then(async res => {
  1188. if (!res.data.data.length) {
  1189. this.hideDialog();
  1190. uni.showModal({
  1191. showCancel: false,
  1192. content: '该试卷暂无题目',
  1193. success: function(k) {
  1194. if (k.confirm) {
  1195. uni.navigateBack();
  1196. }
  1197. }
  1198. });
  1199. return;
  1200. }
  1201. this.allTimes = res.data.data[0].answerTime * 60;
  1202. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1203. res.data.data.forEach((item, index) => {
  1204. if (typeof item.jsonStr == 'string') {
  1205. item.jsonStr = JSON.parse(item.jsonStr);
  1206. if (item.type == 2) {
  1207. //多选
  1208. item.jsonStr.forEach(str => {
  1209. str.optionsId = '' + str.optionsId;
  1210. });
  1211. let arr = item.answerQuestion.split(',');
  1212. arr.forEach((a, i) => {
  1213. arr[i] = '' + a;
  1214. });
  1215. item.ans = arr;
  1216. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1217. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1218. return;
  1219. } else if (item.type == 5) {
  1220. //简答题
  1221. item.ansText = {
  1222. text: '',
  1223. imageList: []
  1224. };
  1225. item.ques = {
  1226. text: '',
  1227. imageList: []
  1228. }
  1229. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1230. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1231. } else if (item.type == 4) {
  1232. //案例题
  1233. console.log(item.jsonStr);
  1234. item.ques = [];
  1235. item.current = 0;
  1236. let ansArr = [];
  1237. item.jsonStr.forEach((json, index) => {
  1238. if (json.type == 1) {
  1239. ansArr[index] = json.answerQuestion;
  1240. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1241. } else if (json.type == 2) {
  1242. json.optionsList.forEach(str => {
  1243. str.optionsId = '' + str.optionsId;
  1244. });
  1245. let arr = json.answerQuestion.split(',');
  1246. arr.forEach((a, i) => {
  1247. arr[i] = '' + a;
  1248. });
  1249. ansArr[index] = arr;
  1250. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1251. } else if (json.type == 3) {
  1252. ansArr[index] = json.answerQuestion;
  1253. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1254. } else if (json.type == 5) {
  1255. ansArr[index] = {
  1256. text: '',
  1257. imageList: []
  1258. };
  1259. json.ansText = {
  1260. text: '',
  1261. imageList: []
  1262. };
  1263. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1264. }
  1265. });
  1266. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1267. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1268. item.ans = ansArr;
  1269. return;
  1270. }
  1271. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1272. item.ans = item.answerQuestion;
  1273. }
  1274. });
  1275. this.questionList = res.data.data;
  1276. this.lastCount = this.questionList.length;
  1277. await this.examRecord();
  1278. });
  1279. },
  1280. /**
  1281. * 记录总题数,获取recordId
  1282. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1283. */
  1284. examRecord(hasSpecial) {
  1285. return new Promise(resolve => {
  1286. let self = this
  1287. let questionList = 0;
  1288. if(!hasSpecial) {
  1289. this.questionList.forEach((item, index) => {
  1290. if(item.type == 1 || item.type == 2 || item.type == 3) {
  1291. questionList++;
  1292. }
  1293. })
  1294. } else {
  1295. questionList = this.questionList.length;
  1296. }
  1297. this.$api
  1298. .bankRecord({
  1299. chapterExamId: this.chapterId || 0,
  1300. moduleExamId: this.moduleId || 0,
  1301. examId: this.id,
  1302. goodsId: this.goodsId,
  1303. gradeId:this.gradeId,
  1304. totalQuestionNum: questionList
  1305. })
  1306. .then(res => {
  1307. this.recordId = res.data.data;
  1308. if(self.needPhoto){
  1309. self.photoPopup = true; //拍照
  1310. } else {
  1311. if(this.lastTime) {
  1312. this.timer = setInterval(() => {
  1313. if (this.lastTime <= 0) {
  1314. clearInterval(this.timer);
  1315. uni.showToast({
  1316. icon:'none',
  1317. mask:true,
  1318. title:'考试时间已到,系统将自动交卷',
  1319. duration:10000
  1320. })
  1321. this.submit();
  1322. return;
  1323. }
  1324. this.lastTime--;
  1325. }, 1000);
  1326. }
  1327. resolve()
  1328. }
  1329. });
  1330. })
  1331. },
  1332. /**
  1333. * @param {Object} e单选点击
  1334. */
  1335. radioSelect(optionsId, bindex) {
  1336. if (this.questionList[bindex].ques) return;
  1337. this.$set(this.questionList[bindex], 'ques', optionsId);
  1338. this.isDoOver()
  1339. },
  1340. /**
  1341. * @param {Object} e案例单选点击
  1342. */
  1343. radioSelectChild(optionsId, ansIndex, bindex) {
  1344. if (this.questionList[bindex].ques[ansIndex]) return;
  1345. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1346. this.isDoOver()
  1347. },
  1348. /**
  1349. * @param {Object} 多选点击
  1350. */
  1351. checkboxSelect(optionsId, bindex, index) {
  1352. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  1353. },
  1354. /**
  1355. * @param {Object} 案例多选点击
  1356. */
  1357. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1358. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  1359. },
  1360. isCheckboxChecked(arr) {
  1361. return arr.some(item => {
  1362. if (item.checked) {
  1363. return true;
  1364. }
  1365. });
  1366. },
  1367. /**
  1368. * @param {Object} 多选确认
  1369. */
  1370. checkboxSubmit(bindex) {
  1371. if (this.questionList[bindex].ques) return;
  1372. let arr = [];
  1373. this.questionList[bindex].jsonStr.forEach(item => {
  1374. if (item.checked) {
  1375. arr.push(item.optionsId);
  1376. }
  1377. });
  1378. if(!arr.length) {
  1379. uni.showToast({
  1380. title:'请选择答案',
  1381. icon:'none'
  1382. })
  1383. return;
  1384. }
  1385. this.$set(this.questionList[bindex], 'ques', arr);
  1386. this.isDoOver()
  1387. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  1388. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1389. });
  1390. },
  1391. /**
  1392. * @param {Object} 案例多选确认
  1393. */
  1394. checkboxSubmitChild(bindex, ansIndex) {
  1395. if (this.questionList[bindex].ques[ansIndex]) return;
  1396. let arr = [];
  1397. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1398. if (item.checked) {
  1399. arr.push(item.optionsId);
  1400. }
  1401. });
  1402. if(!arr.length) {
  1403. uni.showToast({
  1404. title:'请选择答案',
  1405. icon:'none'
  1406. })
  1407. return;
  1408. }
  1409. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1410. this.isDoOver()
  1411. },
  1412. /**
  1413. * @param {Object} index
  1414. * @param {Object} bindex
  1415. * 判断题
  1416. */
  1417. judgeSelect(index, bindex) {
  1418. if (this.questionList[bindex].ques) return;
  1419. this.$set(this.questionList[bindex], 'ques', index + '');
  1420. this.isDoOver()
  1421. },
  1422. /**
  1423. * @param {Object} ansindex
  1424. * @param {Object} childindex
  1425. * @param {Object} bindex
  1426. * 案例判断题
  1427. */
  1428. judgeSelectChild(ansindex, childindex, bindex) {
  1429. if (this.questionList[bindex].ques[ansindex]) return;
  1430. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1431. this.isDoOver()
  1432. },
  1433. openFooterTab() {
  1434. this.show = true;
  1435. },
  1436. hideDialog() {
  1437. this.showDialog = false;
  1438. },
  1439. changeIndex(index) {
  1440. this.current = index;
  1441. },
  1442. swiperChange(e) {
  1443. this.current = e.detail.current;
  1444. },
  1445. pdsubmit() {
  1446. let ansCount = this.questionOverNum(true); //已答题数
  1447. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1448. //没有答完
  1449. if (this.lastCount !== 0) {
  1450. this.cgType = 6;
  1451. this.showpopups = true;
  1452. return;
  1453. }
  1454. if(this.bankType == 2) {
  1455. if(this.lastTime > 0) {
  1456. let lastTime = this.countdown(this.lastTime)
  1457. uni.showModal({
  1458. title:'提示',
  1459. content:`时间还剩余${lastTime},确定交卷吗?`,
  1460. confirmText:'交卷',
  1461. cancelText:'继续答题',
  1462. success:(res) => {
  1463. if(res.confirm) { //确定
  1464. this.submit();
  1465. } else { //取消
  1466. }
  1467. }
  1468. })
  1469. return;
  1470. }
  1471. }
  1472. this.submit();
  1473. },
  1474. /**
  1475. * 交卷
  1476. */
  1477. submit() {
  1478. let score = 0; //计算总分
  1479. let reportStatus = 0;
  1480. let number = 0; //做对的题目数量
  1481. let doQuestionNum = 0; //做过的题目数量
  1482. let allScore = 0; //总分
  1483. let passScore = 0;
  1484. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1485. let doQuestionIds = []; //做过的题目id
  1486. let rightQuestionIds = []; //做对的题目id
  1487. this.questionList.forEach((item, index) => {
  1488. passScore = item.passScore
  1489. if (item.type == 1) {
  1490. //正确
  1491. if (item.ques == item.ans) {
  1492. item.scoreResult = item.score;
  1493. score += item.score;
  1494. number++;
  1495. rightQuestionIds.push(item.questionId)
  1496. } else { //错误
  1497. item.scoreResult = 0;
  1498. doWrongQuestionIds.push(item.questionId)
  1499. }
  1500. allScore += item.score;
  1501. if (item.ques) {
  1502. doQuestionNum++;
  1503. doQuestionIds.push(item.questionId)
  1504. }
  1505. } else if (item.type == 2) {
  1506. let isRight =
  1507. item.ans &&
  1508. item.ans.every((quesItem, quesIndex) => {
  1509. if(item.ques) {
  1510. return item.ques[quesIndex] == item.ans[quesIndex];
  1511. } else {
  1512. return false;
  1513. }
  1514. });
  1515. if (isRight) {
  1516. score += item.score;
  1517. number++;
  1518. item.scoreResult = item.score;
  1519. rightQuestionIds.push(item.questionId)
  1520. } else {
  1521. let checkboxScore = item.score; //获取单题总分数
  1522. item.ques && item.ques.forEach((ques,quesIndex) => {
  1523. //选错一个全扣
  1524. if(item.ques) {
  1525. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1526. checkboxScore = 0;
  1527. }
  1528. } else {
  1529. checkboxScore = 0;
  1530. }
  1531. })
  1532. console.log(checkboxScore)
  1533. //没选错
  1534. if(checkboxScore) {
  1535. item.ans.forEach((ans,quesIndex) => {
  1536. //漏选扣一部分
  1537. if(item.ques) {
  1538. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1539. checkboxScore = item.partScore;
  1540. }
  1541. } else {
  1542. checkboxScore = 0;
  1543. }
  1544. })
  1545. }
  1546. if(checkboxScore <= 0) { //0分
  1547. item.scoreResult = 0;
  1548. doWrongQuestionIds.push(item.questionId)
  1549. } else { //部分分
  1550. // number++;
  1551. doWrongQuestionIds.push(item.questionId)
  1552. item.scoreResult = checkboxScore;
  1553. score += checkboxScore;
  1554. // rightQuestionIds.push(item.questionId)
  1555. }
  1556. }
  1557. allScore += item.score;
  1558. if (item.ques && item.ques.length) {
  1559. doQuestionNum++;
  1560. doQuestionIds.push(item.questionId)
  1561. }
  1562. } else if (item.type == 3) {
  1563. if (item.ques == item.ans) {
  1564. item.scoreResult = item.score;
  1565. score += item.score;
  1566. number++;
  1567. rightQuestionIds.push(item.questionId)
  1568. } else {
  1569. item.scoreResult = 0;
  1570. doWrongQuestionIds.push(item.questionId)
  1571. }
  1572. allScore += item.score;
  1573. if (item.ques) {
  1574. doQuestionNum++;
  1575. doQuestionIds.push(item.questionId)
  1576. }
  1577. } else if (item.type == 4) {
  1578. allScore += item.score;
  1579. if (item.ques && item.ques.length) {
  1580. doQuestionNum++;
  1581. doQuestionIds.push(item.questionId)
  1582. }
  1583. } else if (item.type == 5) {
  1584. allScore += item.score;
  1585. if (item.ques && (item.ques.imageList || item.ques.text)) {
  1586. doQuestionNum++;
  1587. doQuestionIds.push(item.questionId)
  1588. }
  1589. }
  1590. });
  1591. //大于分及格
  1592. if(score >= passScore) {
  1593. reportStatus = 1
  1594. } else {
  1595. reportStatus = 0
  1596. }
  1597. //交卷
  1598. this.$api
  1599. .bankRecordEdit({
  1600. moduleId:this.moduleId || 0,
  1601. chapterId:this.chapterId || 0,
  1602. gradeId:this.gradeId,
  1603. examId: this.id,
  1604. goodsId: this.goodsId,
  1605. reportStatus:reportStatus,
  1606. recordId: this.recordId,
  1607. courseId:this.courseId,
  1608. rightQuestionNum: number,
  1609. status: 1,
  1610. doQuestionIds:doQuestionIds.join(','),
  1611. // rightQuestionIds:rightQuestionIds.join(','),
  1612. // doQuestionNum: doQuestionNum,
  1613. performance: score,
  1614. totalScore: allScore,
  1615. // examTime: parseInt(this.allTimes),
  1616. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1617. // historyExamJson: JSON.stringify(this.questionList)
  1618. })
  1619. .then(res => {
  1620. this.isSubmit = true;
  1621. if (res.data.code == 200) {
  1622. uni.showToast({
  1623. title: '交卷成功',
  1624. duration: 1000,
  1625. mask:true,
  1626. icon: 'none'
  1627. });
  1628. setTimeout(() => {
  1629. uni.redirectTo({
  1630. url: '/pages2/class/question_report?rightQuestionNum='+number+'&doWrongQuestionNum='+doWrongQuestionIds.length+'&score='+score+'&totalScore='+allScore+'&reportStatus='+reportStatus
  1631. });
  1632. }, 1000);
  1633. }
  1634. });
  1635. },
  1636. /**
  1637. * @param {Object} imgIndex
  1638. * @param {Object} bankIndex
  1639. * 删除简答图片
  1640. */
  1641. deleteImg(imgIndex, bankIndex) {
  1642. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1643. },
  1644. /**
  1645. * @param {Object} imgIndex
  1646. * @param {Object} bankIndex
  1647. * @param {Object} ansIndex
  1648. * 删除案例题简答图片
  1649. */
  1650. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1651. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1652. },
  1653. /**
  1654. * @param {Object} bankindex
  1655. * 选择上传图片
  1656. */
  1657. chooseImg(bankindex) {
  1658. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1659. uni.showToast({
  1660. icon:'none',
  1661. title:'最多选择4张'
  1662. })
  1663. return;
  1664. }
  1665. uni.chooseImage({
  1666. count: 1, //默认9
  1667. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1668. sourceType: ['album', 'camera'], //从相册选择
  1669. success: res => {
  1670. let self = this;
  1671. // console.log(JSON.stringify(res.tempFilePaths));
  1672. let img = res.tempFilePaths[0];
  1673. uni.getImageInfo({
  1674. src: img,
  1675. success: async res => {
  1676. let canvasWidth = res.width; //图片原始长宽
  1677. let canvasHeight = res.height;
  1678. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1679. uni.compressImage({
  1680. src: img,
  1681. quality: 75,
  1682. width: '50%',
  1683. height: '50%',
  1684. success: async rest => {
  1685. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1686. this.questionList[bankindex].ansText.imageList.push(dir);
  1687. }
  1688. });
  1689. } else {
  1690. const dir = await self.uploadFile(img, 0);
  1691. this.questionList[bankindex].ansText.imageList.push(dir);
  1692. }
  1693. }
  1694. });
  1695. }
  1696. });
  1697. },
  1698. /**
  1699. * @param {Object} bankindex
  1700. * @param {Object} ansindex
  1701. * 案例题选择上传图片
  1702. */
  1703. chooseImgChild(bankindex, ansindex) {
  1704. uni.chooseImage({
  1705. count: 1, //默认9
  1706. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1707. sourceType: ['album', 'camera'], //从相册选择
  1708. success: res => {
  1709. let self = this;
  1710. // console.log(JSON.stringify(res.tempFilePaths));
  1711. let img = res.tempFilePaths[0];
  1712. uni.getImageInfo({
  1713. src: img,
  1714. success: async res => {
  1715. let canvasWidth = res.width; //图片原始长宽
  1716. let canvasHeight = res.height;
  1717. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1718. uni.compressImage({
  1719. src: img,
  1720. quality: 75,
  1721. width: '50%',
  1722. height: '50%',
  1723. success: async rest => {
  1724. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1725. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1726. }
  1727. });
  1728. } else {
  1729. const dir = await self.uploadFile(img, 0);
  1730. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1731. }
  1732. }
  1733. });
  1734. }
  1735. });
  1736. },
  1737. uploadFile(options, int) {
  1738. var self = this;
  1739. return new Promise((resolve, reject) => {
  1740. var data = {
  1741. imageStatus: int
  1742. };
  1743. self.$api.aliyunpolicy(data).then(res => {
  1744. console.log(res.data, 6);
  1745. if (res.data.code != 200) {
  1746. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1747. return;
  1748. }
  1749. var ossToken = res.data.data.resultContent;
  1750. if (ossToken.host == null || ossToken.host == undefined) {
  1751. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1752. return;
  1753. }
  1754. uni.uploadFile({
  1755. url: ossToken.host,
  1756. name: 'file',
  1757. filePath: options,
  1758. fileType: 'image',
  1759. header: {
  1760. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1761. },
  1762. formData: {
  1763. key: ossToken.dir,
  1764. OSSAccessKeyId: ossToken.accessid,
  1765. policy: ossToken.policy,
  1766. Signature: ossToken.signature,
  1767. callback: ossToken.callback,
  1768. success_action_status: 200
  1769. },
  1770. success: result => {
  1771. if (result.statusCode === 200) {
  1772. self.ossAvatarUrl = ossToken.dir;
  1773. resolve(ossToken.dir);
  1774. } else {
  1775. uni.showToast({
  1776. title: '上传失败',
  1777. icon: 'none'
  1778. });
  1779. return;
  1780. }
  1781. },
  1782. fail: error => {
  1783. uni.showToast({
  1784. title: '上传接口报错' + error,
  1785. icon: 'none'
  1786. });
  1787. return;
  1788. }
  1789. });
  1790. });
  1791. });
  1792. },
  1793. /**
  1794. * @param {Object} type
  1795. * @param {Object} bankindex
  1796. * 简答题答案确认
  1797. */
  1798. submitAns(bankindex) {
  1799. console.log(this.questionList[bankindex]);
  1800. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1801. uni.showToast({
  1802. title: '请输入内容或上传图片',
  1803. duration: 2000,
  1804. icon: 'none'
  1805. });
  1806. return;
  1807. }
  1808. this.$set(this.questionList[bankindex], 'ques', {
  1809. imageList: this.questionList[bankindex].ansText.imageList,
  1810. text: this.questionList[bankindex].ansText.text
  1811. });
  1812. this.isDoOver()
  1813. },
  1814. /**
  1815. * @param {Object} bankindex
  1816. * @param {Object} ansindex
  1817. * 案例题简答答案确认
  1818. */
  1819. submitAnsChild(bankindex, ansindex) {
  1820. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1821. uni.showToast({
  1822. title: '请输入内容或上传图片',
  1823. duration: 2000,
  1824. icon: 'none'
  1825. });
  1826. return;
  1827. }
  1828. this.$set(this.questionList[bankindex].ques, ansindex, {
  1829. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1830. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text
  1831. });
  1832. this.isDoOver()
  1833. },
  1834. isRight(item, index) {
  1835. //单选
  1836. if (this.questionList[index].ques) {
  1837. if (item.type == 1) {
  1838. return this.questionList[index].ques == this.questionList[index].ans;
  1839. //多选
  1840. } else if (item.type == 2) {
  1841. //每一项都相等
  1842. return this.questionList[index].ans.every((item, i) => {
  1843. return item == this.questionList[index].ques[i];
  1844. });
  1845. //判断
  1846. } else if (item.type == 3) {
  1847. return this.questionList[index].ques == this.questionList[index].ans;
  1848. // } else if (item.type == 5) {
  1849. // if(this.questionList[index].ques.text){
  1850. // return true
  1851. // }else{
  1852. // return false
  1853. // }
  1854. } else {
  1855. return false;
  1856. }
  1857. } else {
  1858. return false;
  1859. }
  1860. },
  1861. right(bankIndex, ansIndex, option) {
  1862. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1863. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1864. return true;
  1865. } else {
  1866. return false;
  1867. }
  1868. } else {
  1869. return false;
  1870. }
  1871. },
  1872. wrong(bankIndex, ansIndex, option) {
  1873. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1874. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1875. return true;
  1876. } else {
  1877. return false;
  1878. }
  1879. } else {
  1880. return false;
  1881. }
  1882. },
  1883. isWrong(item, index) {
  1884. if (this.questionList[index].ques) {
  1885. //单选
  1886. if (item.type == 1) {
  1887. return this.questionList[index].ques != this.questionList[index].ans;
  1888. //多选
  1889. } else if (item.type == 2) {
  1890. //每一项都相等
  1891. return this.questionList[index].ans.some((item, i) => {
  1892. return item != this.questionList[index].ques[i];
  1893. });
  1894. //判断
  1895. } else if (item.type == 3) {
  1896. return this.questionList[index].ques != this.questionList[index].ans;
  1897. } else {
  1898. return false;
  1899. }
  1900. } else {
  1901. return false;
  1902. }
  1903. },
  1904. tabSelect(index, bankindex) {
  1905. this.$set(this.questionList[bankindex], 'current', index);
  1906. }
  1907. }
  1908. };
  1909. </script>
  1910. <style lang="scss" scoped>
  1911. .photoBox {
  1912. background-color: #FFFFFF;
  1913. border-radius: 32px 32px 0px 0px;
  1914. .photoTop {
  1915. height: 74upx;
  1916. display: flex;
  1917. align-items: center;
  1918. justify-content: space-between;
  1919. padding: 0upx 38upx;
  1920. .sqzz {
  1921. width: 28upx;
  1922. height: 28upx;
  1923. display: flex;
  1924. align-items: center;
  1925. justify-content: center;
  1926. }
  1927. .centersq {
  1928. color: #333;
  1929. font-size: 30upx;
  1930. font-weight: 500;
  1931. }
  1932. }
  1933. .photoCenter {
  1934. width: 750upx;
  1935. height: 979upx;
  1936. position: relative;
  1937. .custom {
  1938. width: 750upx;
  1939. height: 979upx;
  1940. position: absolute;
  1941. z-index: 1000;
  1942. top: 0;
  1943. left: 0;
  1944. image {
  1945. width: 100%;
  1946. height: 100%;
  1947. }
  1948. }
  1949. }
  1950. .btnResult {
  1951. height: 100rpx;
  1952. width: 100%;
  1953. background-color: #07c160;
  1954. text-align: center;
  1955. line-height: 100upx;
  1956. color: #fff;
  1957. font-size: 32upx;
  1958. font-weight: bold;
  1959. }
  1960. }
  1961. .navbar {
  1962. position: relative;
  1963. z-index: 20000;
  1964. }
  1965. .questionBank {
  1966. width:100%;
  1967. height:100vh;
  1968. display: flex;
  1969. flex-direction: column;
  1970. }
  1971. .swiper {
  1972. width: 100%;
  1973. flex:1;
  1974. }
  1975. .lisSty {
  1976. margin-bottom: 16rpx;
  1977. display: flex;
  1978. .flex_auto {
  1979. flex: 1;
  1980. }
  1981. }
  1982. .activeTI {
  1983. vertical-align: middle;
  1984. display: inline-block;
  1985. border: 1rpx solid #eee;
  1986. border-radius: 50rpx;
  1987. height: 48rpx;
  1988. line-height: 46rpx;
  1989. text-align: center;
  1990. width: 48rpx;
  1991. margin-right: 15rpx;
  1992. color: #666;
  1993. font-size: 30rpx;
  1994. &.right {
  1995. color: #fff;
  1996. background: #36C75A;
  1997. }
  1998. &.wrong {
  1999. color: #fff;
  2000. background: #FF3B30;
  2001. }
  2002. &.checked {
  2003. color: #fff;
  2004. background: #007AFF;
  2005. }
  2006. }
  2007. .submit_checkbox {
  2008. position:fixed;
  2009. left:0;
  2010. right:0;
  2011. bottom:120rpx;
  2012. margin: 20rpx auto;
  2013. width: 526rpx;
  2014. height: 80rpx;
  2015. background: rgba(0, 122, 255, 1);
  2016. color: #fff;
  2017. text-align: center;
  2018. line-height: 80rpx;
  2019. font-size: 30rpx;
  2020. border-radius: 40rpx;
  2021. &.disabled {
  2022. opacity: 0.6;
  2023. }
  2024. }
  2025. .titles {
  2026. overflow: hidden;
  2027. margin-bottom: 24rpx;
  2028. }
  2029. .titBox {
  2030. padding: 41rpx 25rpx 24rpx 25rpx;
  2031. }
  2032. .titBox_title {
  2033. padding: 21rpx;
  2034. }
  2035. .tabs {
  2036. margin: 10rpx;
  2037. display: flex;
  2038. .tab {
  2039. margin: 0 4rpx;
  2040. padding:10rpx 13rpx;
  2041. text-align: center;
  2042. color: #007aff;
  2043. font-size: 28rpx;
  2044. border-radius: 16rpx;
  2045. background:#fff;
  2046. &.current {
  2047. color: #fff;
  2048. background: #007aff;
  2049. }
  2050. }
  2051. }
  2052. .ans {
  2053. margin: 8rpx 8rpx 8rpx;
  2054. .ans_input {
  2055. border-radius: 16rpx;
  2056. background: #fff;
  2057. .top {
  2058. border-bottom: 1rpx solid #eeeeee;
  2059. padding: 16rpx;
  2060. display: flex;
  2061. align-items: center;
  2062. .icon {
  2063. margin-right: 20rpx;
  2064. width: 40rpx;
  2065. height: 38rpx;
  2066. }
  2067. .progress {
  2068. flex: 1;
  2069. }
  2070. .submit {
  2071. width: 168rpx;
  2072. height: 48rpx;
  2073. line-height: 48rpx;
  2074. text-align: center;
  2075. color: #fff;
  2076. font-size: 30rpx;
  2077. background: #007aff;
  2078. border-radius: 24rpx;
  2079. &.disabled {
  2080. opacity: 0.6;
  2081. }
  2082. }
  2083. }
  2084. .textarea {
  2085. textarea {
  2086. width: 100%;
  2087. height: 287rpx;
  2088. padding: 10rpx;
  2089. }
  2090. }
  2091. .imgs {
  2092. overflow: hidden;
  2093. display: flex;
  2094. width: 100%;
  2095. .img {
  2096. width: 104rpx;
  2097. height: 104rpx;
  2098. border-radius: 8rpx;
  2099. position: relative;
  2100. margin: 20rpx;
  2101. text {
  2102. position: absolute;
  2103. right: -15rpx;
  2104. top: -15rpx;
  2105. width: 30rpx;
  2106. height: 30rpx;
  2107. text-align: center;
  2108. line-height: 30rpx;
  2109. color: #fff;
  2110. background: #FF3B30;
  2111. border-radius: 50%;
  2112. }
  2113. image {
  2114. width: 100%;
  2115. height: 100%;
  2116. }
  2117. }
  2118. }
  2119. }
  2120. .ans_submit {
  2121. padding: 16rpx;
  2122. border-radius: 16rpx;
  2123. background: #fff;
  2124. .imgs {
  2125. overflow: hidden;
  2126. display: flex;
  2127. width: 100%;
  2128. .img {
  2129. width: 104rpx;
  2130. height: 104rpx;
  2131. border-radius: 8rpx;
  2132. position: relative;
  2133. margin: 20rpx;
  2134. image {
  2135. width: 100%;
  2136. height: 100%;
  2137. }
  2138. }
  2139. }
  2140. }
  2141. }
  2142. .leftLetters {
  2143. display: flex;
  2144. align-items: center;
  2145. width: 220rpx;
  2146. .btnType {
  2147. padding: 5rpx 10rpx;
  2148. border: 1rpx solid #007aff;
  2149. border-radius: 10rpx;
  2150. background-color: rgba(0, 122, 255, 0.1);
  2151. font-size: 28rpx;
  2152. color: #007aff;
  2153. margin-right: 15rpx;
  2154. }
  2155. }
  2156. .firstLetter {
  2157. display: flex;
  2158. justify-content: space-between;
  2159. align-items: center;
  2160. margin-bottom: 30rpx;
  2161. }
  2162. .popupView {
  2163. height: 100%;
  2164. padding-bottom: 100rpx;
  2165. .popupTops {
  2166. height: 77rpx;
  2167. border-bottom: 1rpx solid #eee;
  2168. text-align: center;
  2169. line-height: 77rpx;
  2170. font-size: 24rpx;
  2171. color: #999;
  2172. position: relative;
  2173. .topIcon {
  2174. position: absolute;
  2175. top: 10rpx;
  2176. left: 50%;
  2177. transform: translateX(-50%);
  2178. width: 80rpx;
  2179. height: 8rpx;
  2180. background-color: #999;
  2181. border-radius: 4rpx;
  2182. }
  2183. }
  2184. .popupContent {
  2185. }
  2186. }
  2187. .pageContent {
  2188. position: relative;
  2189. background-color: #eaeef1;
  2190. height: 100%;
  2191. padding-top: 8rpx;
  2192. padding-bottom: 100rpx;
  2193. overflow-y: scroll;
  2194. }
  2195. .pad_8 {
  2196. background-color: #fff;
  2197. margin: 0rpx 8rpx 8rpx;
  2198. border-radius: 16rpx;
  2199. &.no-margin {
  2200. margin-top:-16rpx;
  2201. border-radius: 0 0 16rpx 16rpx;
  2202. }
  2203. }
  2204. .answer {
  2205. height: 80rpx;
  2206. line-height: 80rpx;
  2207. padding: 0rpx 24rpx;
  2208. display: flex;
  2209. align-items: center;
  2210. justify-content: space-between;
  2211. color: #666;
  2212. font-size: 30rpx;
  2213. }
  2214. .footer_btn {
  2215. background-color: #fff;
  2216. z-index: 10078;
  2217. position: fixed;
  2218. bottom: 0rpx;
  2219. display: flex;
  2220. align-items: center;
  2221. justify-content: space-between;
  2222. width: 100%;
  2223. height: 98rpx;
  2224. padding: 0rpx 38rpx;
  2225. border-top: 1rpx solid #eee;
  2226. .flex_center {
  2227. flex:1;
  2228. display: flex;
  2229. justify-content: center;
  2230. align-items: center;
  2231. flex-direction: column;
  2232. margin:0 200rpx;
  2233. font-size: 24rpx;
  2234. color: #999999;
  2235. .up-icon {
  2236. margin-bottom:18rpx;
  2237. width:100%;
  2238. display: flex;
  2239. justify-content: center;
  2240. image {
  2241. width:58rpx;
  2242. height:21rpx;
  2243. }
  2244. }
  2245. }
  2246. .collect {
  2247. visibility: hidden;
  2248. width:100rpx;
  2249. &.show {
  2250. visibility: visible;
  2251. }
  2252. >view {
  2253. display: flex;
  2254. flex-direction: column;
  2255. align-items: center;
  2256. justify-content: center;
  2257. image {
  2258. width:32rpx;
  2259. height:32rpx;
  2260. margin-bottom:6rpx;
  2261. }
  2262. view {
  2263. font-size: 24rpx;
  2264. color: #999999;
  2265. }
  2266. }
  2267. }
  2268. }
  2269. .boxSty {
  2270. padding: 44rpx 41rpx 0rpx;
  2271. }
  2272. .liListSty {
  2273. border: 1rpx solid #eeeeee;
  2274. width: 88rpx;
  2275. height: 88rpx;
  2276. border-radius: 32rpx;
  2277. text-align: center;
  2278. line-height: 88rpx;
  2279. color: #333;
  2280. font-size: 32rpx;
  2281. float: left;
  2282. margin: 20rpx 23rpx;
  2283. &.isRight {
  2284. border: 1rpx solid #eeeeee;
  2285. color: #fff;
  2286. background: #36C75A;
  2287. }
  2288. &.isWrong {
  2289. border: 1rpx solid #eeeeee;
  2290. color: #fff;
  2291. background: #FF3B30;
  2292. }
  2293. }
  2294. .answerInfos {
  2295. padding: 25rpx 25rpx 25rpx 23rpx;
  2296. }
  2297. .answerTitle {
  2298. margin-bottom: 28rpx;
  2299. color: #666;
  2300. font-size: 30rpx;
  2301. }
  2302. .answerContent {
  2303. font-size: 30rpx;
  2304. color: #666;
  2305. }
  2306. .textChild {
  2307. display: inline-block;
  2308. vertical-align: middle;
  2309. }
  2310. .dialog {
  2311. position: fixed;
  2312. left: 0;
  2313. top: 0;
  2314. width: 100%;
  2315. height: 100%;
  2316. background-color: rgba(0, 0, 0, 0.8);
  2317. display: flex;
  2318. flex-direction: column;
  2319. align-items: center;
  2320. justify-content: center;
  2321. z-index: 20000;
  2322. .text {
  2323. font-size: 32rpx;
  2324. color: #ffffff;
  2325. text-align: center;
  2326. }
  2327. .btn {
  2328. width: 242rpx;
  2329. height: 82rpx;
  2330. border: 2rpx solid #ffffff;
  2331. border-radius: 16rpx;
  2332. text-align: center;
  2333. line-height: 82rpx;
  2334. margin: 41rpx auto;
  2335. color: #fff;
  2336. font-size: 32rpx;
  2337. }
  2338. }
  2339. .dialog-arrow {
  2340. padding-top:124rpx;
  2341. position: fixed;
  2342. left: 0;
  2343. top: 0;
  2344. width: 100%;
  2345. height: 100%;
  2346. background-color: rgba(0, 0, 0, 0.8);
  2347. z-index: 20000;
  2348. .pointer {
  2349. margin-left:87rpx;
  2350. display: block;
  2351. width:95rpx;
  2352. height:98rpx;
  2353. }
  2354. .text {
  2355. padding-left:177rpx;
  2356. font-size: 32rpx;
  2357. color: #ffffff;
  2358. }
  2359. .btn {
  2360. width: 242rpx;
  2361. height: 82rpx;
  2362. border: 2rpx solid #ffffff;
  2363. border-radius: 16rpx;
  2364. text-align: center;
  2365. line-height: 82rpx;
  2366. margin: 500rpx auto 0;
  2367. color: #fff;
  2368. font-size: 32rpx;
  2369. }
  2370. }
  2371. .dialog_wrap {
  2372. position: fixed;
  2373. left: 0;
  2374. top: 0;
  2375. width: 100%;
  2376. height: 100%;
  2377. z-index: 9999999999;
  2378. .bg {
  2379. background: rgba(0, 0, 0, 0.3);
  2380. position: absolute;
  2381. left: 0;
  2382. top: 0;
  2383. width: 100%;
  2384. height: 100%;
  2385. }
  2386. .dialog {
  2387. position: absolute;
  2388. left: 50%;
  2389. top: 50%;
  2390. transform: translate3D(-50%, -50%, 0);
  2391. width: 640rpx;
  2392. height: 439rpx;
  2393. background: #ffffff;
  2394. border-radius: 24rpx;
  2395. .title {
  2396. font-size: 30rpx;
  2397. font-weight: bold;
  2398. color: #333333;
  2399. line-height: 48rpx;
  2400. text-align: center;
  2401. margin-top: 40rpx;
  2402. }
  2403. .content {
  2404. margin: 35rpx 35rpx 0;
  2405. font-size: 30rpx;
  2406. color: #666666;
  2407. line-height: 48rpx;
  2408. }
  2409. .btns {
  2410. margin-top: 35rpx;
  2411. display: flex;
  2412. align-items: center;
  2413. justify-content: center;
  2414. .btn {
  2415. width: 200rpx;
  2416. height: 80rpx;
  2417. line-height: 80rpx;
  2418. text-align: center;
  2419. background: #f5f5f5;
  2420. border-radius: 40rpx;
  2421. font-size: 30rpx;
  2422. color: rgba(0, 122, 255, 1);
  2423. background: #f5f5f5;
  2424. margin: 0 20rpx;
  2425. &.active {
  2426. color: #f5f5f5;
  2427. background: rgba(0, 122, 255, 1);
  2428. }
  2429. }
  2430. }
  2431. }
  2432. }
  2433. .popboxs {
  2434. width: 100%;
  2435. height: 100%;
  2436. display: flex;
  2437. flex-direction: column;
  2438. align-items: center;
  2439. }
  2440. .classTops {
  2441. flex-shrink: 0;
  2442. padding: 39rpx 0rpx 4rpx;
  2443. font-weight: bold;
  2444. color: #333;
  2445. font-size: 30rpx;
  2446. }
  2447. .textStys {
  2448. width: 100%;
  2449. flex: 1;
  2450. padding: 36rpx;
  2451. }
  2452. .classFootsty {
  2453. flex-shrink: 0;
  2454. display: flex;
  2455. align-items: center;
  2456. justify-content: center;
  2457. padding: 10rpx 0rpx 40rpx;
  2458. .btnsty {
  2459. width: 200rpx;
  2460. height: 80rpx;
  2461. border-radius: 40rpx;
  2462. font-weight: bold;
  2463. font-size: 30rpx;
  2464. text-align: center;
  2465. line-height: 80rpx;
  2466. }
  2467. .btns1 {
  2468. background-color: #f5f5f5;
  2469. color: #007aff;
  2470. }
  2471. .btns2 {
  2472. margin-left: 40rpx;
  2473. background-color: #007aff;
  2474. color: #ffffff;
  2475. }
  2476. }
  2477. </style>