questionBank.vue 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072
  1. <template>
  2. <view id="questionBank">
  3. <uni-nav-bar @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 v-if="bank.ques">
  44. <view class="pad_8 answer">
  45. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  46. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  47. </view>
  48. <view class="pad_8 answerInfos">
  49. <view class="answerTitle">答案解析</view>
  50. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  51. </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" @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 v-if="bank.ques">
  79. <view class="pad_8 answer">
  80. <view>
  81. 正确答案:
  82. <text v-for="ansItem in bank.ans">{{ ast[ansItem - 1] }}</text>
  83. </view>
  84. <view>
  85. 我的答案:
  86. <text v-for="quesItem in bank.ques">{{ ast[quesItem - 1] }}</text>
  87. </view>
  88. </view>
  89. <view class="pad_8 answerInfos">
  90. <view class="answerTitle">答案解析</view>
  91. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  92. </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. {{ item }}
  102. </view>
  103. </view>
  104. <view v-if="bank.ques">
  105. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  106. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  107. {{ ast[index] }}
  108. </text>
  109. {{ item }}
  110. </view>
  111. </view>
  112. <view v-if="bank.ques">
  113. <view class="pad_8 answer">
  114. <view>正确答案:{{ ast[bank.ans] }}</view>
  115. <view>我的答案:{{ ast[bank.ques] }}</view>
  116. </view>
  117. <view class="pad_8 answerInfos">
  118. <view class="answerTitle">答案解析</view>
  119. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. <!-- 简答题 -->
  125. <template v-if="bank.type == 5">
  126. <view class="pad_8 titBox">
  127. <view class="ans">
  128. <view class="ans_input" v-if="!bank.ques">
  129. <view class="top flex">
  130. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/camera.png" mode=""></image>
  131. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  132. <view class="submit" :class="{disabled:!bank.ansText.text && hasImgs(bank)}" @click="submitAns(bankIndex)">确认答案</view>
  133. </view>
  134. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  135. <view class="imgs">
  136. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList">
  137. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  138. <image :src="$method.splitImgHost(img, true)"></image>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="ans_submit answerInfos" v-if="bank.ques">
  143. <view class="answerTitle">我的答案:</view>
  144. {{ bank.ques.text }}
  145. <view class="imgs"><image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques, true)"></image></view>
  146. </view>
  147. </view>
  148. <view v-if="bank.ques">
  149. <view class="pad_8 answerInfos">
  150. <view class="answerTitle">答案解析:</view>
  151. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <!-- 案例题 -->
  157. <template v-if="bank.type == 4">
  158. <view class="pad_8 titBox">
  159. <view class="tabs">
  160. <view
  161. class="tab"
  162. :class="{ current: tabIndex == bank.current }"
  163. :key="tabIndex"
  164. v-for="(tab, tabIndex) in bank.jsonStr"
  165. @click="tabSelect(tabIndex, bankIndex)"
  166. >
  167. 问题{{ tabIndex }}
  168. </view>
  169. </view>
  170. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  171. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  172. <template v-if="ansItem.type == 1">
  173. <view v-if="!bank.ques[ansIndex]">
  174. <view
  175. v-for="(option, childIndex) in ansItem.optionsList"
  176. :key="childIndex"
  177. class="lisSty"
  178. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  179. >
  180. <view class="activeTI">{{ ast[childIndex] }}</view>
  181. <rich-text class="textChild" :nodes="option.content"></rich-text>
  182. </view>
  183. </view>
  184. <view v-if="bank.ques[ansIndex]">
  185. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  186. <text
  187. :class="{
  188. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  189. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  190. }"
  191. class="activeTI"
  192. >
  193. {{ ast[childIndex] }}
  194. </text>
  195. <rich-text :nodes="option.content"></rich-text>
  196. </view>
  197. </view>
  198. <view v-if="bank.ques[ansIndex]">
  199. <view class="pad_8 answer">
  200. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  201. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  202. </view>
  203. <view class="pad_8 answerInfos">
  204. <view class="answerTitle">答案解析</view>
  205. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  206. </view>
  207. </view>
  208. </template>
  209. <template v-if="ansItem.type == 2">
  210. <view v-if="!bank.ques[ansIndex]">
  211. <view
  212. v-for="(option, childindex) in ansItem.optionsList"
  213. :key="childindex"
  214. class="lisSty"
  215. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  216. >
  217. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  218. <rich-text :nodes="option.content"></rich-text>
  219. </view>
  220. </view>
  221. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  222. <view v-if="bank.ques && bank.ques[ansIndex]">
  223. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  224. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  225. {{ ast[childindex] }}
  226. </text>
  227. <rich-text :nodes="option.content"></rich-text>
  228. </view>
  229. </view>
  230. <view v-if="bank.ques[ansIndex]">
  231. <view class="pad_8 answer">
  232. <view>
  233. 正确答案:
  234. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  235. </view>
  236. <view>
  237. 我的答案:
  238. <text v-for="quesItem in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  239. </view>
  240. </view>
  241. <view class="pad_8 answerInfos">
  242. <view class="answerTitle">答案解析</view>
  243. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  244. </view>
  245. </view>
  246. </template>
  247. <template v-if="ansItem.type == 3">
  248. <view v-if="!bank.ques[ansIndex]">
  249. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  250. <view class="activeTI">{{ ast[childindex] }}</view>
  251. {{ option }}
  252. </view>
  253. </view>
  254. <view v-if="bank.ques[ansIndex]">
  255. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  256. <text
  257. :class="{
  258. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  259. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  260. }"
  261. class="activeTI"
  262. >
  263. {{ ast[childindex] }}
  264. </text>
  265. {{ option }}
  266. </view>
  267. </view>
  268. <view v-if="bank.ques[ansIndex]">
  269. <view class="pad_8 answer">
  270. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  271. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  272. </view>
  273. <view class="pad_8 answerInfos">
  274. <view class="answerTitle">答案解析</view>
  275. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  276. </view>
  277. </view>
  278. </template>
  279. <!-- 简答题 -->
  280. <template v-if="ansItem.type == 5">
  281. <view class="ans">
  282. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  283. <view class="top flex">
  284. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  285. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  286. <view class="submit" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  287. </view>
  288. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  289. <view class="imgs">
  290. <view class="img" v-for="(img, imgIndex) in ansItem.ansText.imageList">
  291. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  292. <image :src="$method.splitImgHost(img, true)"></image>
  293. </view>
  294. </view>
  295. </view>
  296. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  297. <view class="answerTitle">答案我的</view>
  298. {{ bank.ques[ansIndex].text }}
  299. <view class="imgs">
  300. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques, true)"></image>
  301. </view>
  302. </view>
  303. </view>
  304. <view v-if="bank.ques[ansIndex]">
  305. <view class="pad_8 answerInfos">
  306. <view class="answerTitle">答案解析</view>
  307. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  308. </view>
  309. </view>
  310. </template>
  311. </view>
  312. </view>
  313. </template>
  314. <view class="footer_btn">
  315. <view class="collect">
  316. <view v-if="collectList[bankIndex]">
  317. <image src="/static/icon/collected.png" mode=""></image>
  318. <view>取消收藏</view>
  319. </view>
  320. </view>
  321. <view class="flex_center" @click="openFooterTab">
  322. <view class="up-icon">
  323. <image src="/static/up.png"></image>
  324. </view>
  325. 答题卡
  326. </view>
  327. <view class="collect show" @click="pdsubmit">
  328. <view>
  329. <image src="/static/jj.png" mode=""></image>
  330. <view>交卷</view>
  331. </view>
  332. </view>
  333. </view>
  334. </view>
  335. </swiper-item>
  336. </swiper>
  337. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  338. <view class="popupView">
  339. <view class="popupTops">
  340. <view class="topIcon"></view>
  341. 点击编号即可跳转至对应题目
  342. </view>
  343. <view class="popupContent">
  344. <scroll-view scroll-y="true" style="height: 506rpx;">
  345. <view class="boxSty">
  346. <view
  347. v-for="(item, index) in questionList"
  348. :key="index"
  349. @click="changeIndex(index)"
  350. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  351. class="liListSty"
  352. >
  353. {{ index + 1 }}
  354. </view>
  355. </view>
  356. </scroll-view>
  357. </view>
  358. </view>
  359. </u-popup>
  360. <view class="dialog" v-if="showDialog">
  361. <view class="text">左右滑动切换上下题</view>
  362. <view class="btn" @click="hideDialog">我知道了</view>
  363. </view>
  364. <view class="dialog_wrap" v-if="testOver">
  365. <view class="bg"></view>
  366. <view class="dialog">
  367. <view class="title">温馨提示</view>
  368. <view class="content">
  369. <view>您已完成所有题目,</view>
  370. <view>快去交卷吧!</view>
  371. </view>
  372. <view class="btns">
  373. <view class="btn" @click="noSubmit()">暂不交卷</view>
  374. <view class="btn active" @click="submitNow()">立即交卷</view>
  375. </view>
  376. </view>
  377. </view>
  378. <view class="dialog_wrap" v-if="isLastCount">
  379. <view class="bg"></view>
  380. <view class="dialog">
  381. <view class="title">温馨提示</view>
  382. <view class="content">
  383. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  384. </view>
  385. <view class="btns">
  386. <view class="btn" @click="noLeave()">暂不离开</view>
  387. <view class="btn active" @click="leaveNow()">继续离开</view>
  388. </view>
  389. </view>
  390. </view>
  391. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  392. <view class="popboxs">
  393. <view class="classTops">温馨提示</view>
  394. <view class="textStys">
  395. {{
  396. cgType === 7
  397. ? '您还未交卷,确定结束做题吗?'
  398. : cgType === 8
  399. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  400. : cgType === 6
  401. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  402. : ''
  403. }}
  404. </view>
  405. <view class="classFootsty" v-if="cgType === 6">
  406. <view class="btnsty btns1" @click="submit">立即交卷</view>
  407. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  408. </view>
  409. <view class="classFootsty" v-if="cgType === 7">
  410. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  411. <view class="btnsty btns2" @click="backPages">结束做题</view>
  412. </view>
  413. <view class="classFootsty" v-if="cgType === 8">
  414. <view class="btnsty btns1" @click="leaveNow()">下次继续</view>
  415. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  416. </view>
  417. </view>
  418. </u-popup>
  419. </view>
  420. </template>
  421. <script>
  422. export default {
  423. data() {
  424. return {
  425. showpopups: false,
  426. id: '',
  427. current: 0,
  428. questionList: [],
  429. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  430. judge: ['错误', '正确'],
  431. ans: [],
  432. ques: [],
  433. show: false,
  434. showDialog: true,
  435. bankList: [],
  436. collectList: [],
  437. goodsId: '',
  438. recordId: '',
  439. isSubmit: false,
  440. lastTime: 0, //剩余考试时长
  441. allTimes: 0, //总考试时长
  442. timer: null,
  443. wrongList: [],
  444. bankType: 0, //试卷类型
  445. needBack: false, //是否是考试
  446. testOver: false,
  447. isLastCount: false, //是否有未答题目
  448. lastCount: 0, //剩余没有回答的题目数
  449. chapterId: 0,
  450. moduleId: 0,
  451. isFromVideo:'',
  452. gradeId:'',
  453. courseId:0,
  454. cgType: 0 //对应设计稿弹窗编码
  455. };
  456. },
  457. onLoad(option) {
  458. this.id = option.id;
  459. this.goodsId = option.goodsid;
  460. this.chapterId = option.chapterId;
  461. this.courseId = option.courseId;
  462. this.moduleId = option.moduleId;
  463. this.isFromVideo = option.isFromVideo||'';
  464. this.gradeId = option.gradeId || '';
  465. let isBack = option.isback;
  466. if (isBack) {
  467. console.log(getApp());
  468. let app = getApp();
  469. let globalData = app.globalData;
  470. for (var k in globalData.bankData) {
  471. this[k] = globalData.bankData[k];
  472. }
  473. } else {
  474. this.goodsQuestionList();
  475. this.bankExam();
  476. }
  477. },
  478. onUnload() {
  479. if (this.isSubmit) {
  480. clearInterval(this.timer)
  481. return;
  482. }
  483. //考试试卷 阻止ios手势返回,自动跳回答题页
  484. if (this.needBack) {
  485. let app = getApp();
  486. app.globalData.bankData = this.$data;
  487. uni.navigateTo({
  488. url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  489. });
  490. } else {
  491. //点击返回按钮确认允许退出,交卷
  492. clearInterval(this.timer)
  493. this.examRecordEdit();
  494. }
  495. },
  496. methods: {
  497. /**
  498. * 是否有上传图片
  499. */
  500. hasImgs(bank) {
  501. return bank.ansText.imageList.length == 0;
  502. },
  503. /**
  504. * 获取试卷类型2考试,1练习
  505. */
  506. bankExam() {
  507. this.$api.bankExam(this.id).then(res => {
  508. this.bankType = res.data.data.doType;
  509. if (this.bankType == 2) {
  510. this.needBack = true;
  511. }
  512. });
  513. },
  514. /**
  515. * 点击后退按钮
  516. */
  517. clickLeft() {
  518. if (this.bankType == 1) {
  519. let ansCount = this.questionOverNum(); //已答题数
  520. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  521. //所有题目答完
  522. if (this.lastCount == 0) {
  523. // this.testOver = true;
  524. this.cgType = 7;
  525. //未答完
  526. } else {
  527. this.cgType = 8;
  528. // this.isLastCount = true;
  529. }
  530. this.showpopups = true;
  531. } else if (this.bankType == 2) {
  532. let ansCount = this.questionOverNum(); //已答题数
  533. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  534. //所有题目答完
  535. if (this.lastCount == 0) {
  536. this.testOver = true;
  537. //未答完
  538. } else {
  539. this.isLastCount = true;
  540. }
  541. }
  542. },
  543. /**
  544. * 返回上一页
  545. */
  546. backPages() {
  547. this.needBack = false;
  548. uni.navigateBack({
  549. delta: 1
  550. });
  551. },
  552. /**
  553. * 获取已经回答的题目数
  554. * hasSpecail (是否包含简答和案例)
  555. */
  556. questionOverNum(hasSpecail) {
  557. let count = 0;
  558. this.questionList.forEach(item => {
  559. if (item.type == 1 || item.type == 2 || item.type == 3) {
  560. if (item.ques) {
  561. count++;
  562. }
  563. } else if (item.type == 4) {
  564. //案例题
  565. if(hasSpecail) {
  566. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  567. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  568. if (item.ques[indexs]) {
  569. return true;
  570. } else {
  571. return false;
  572. }
  573. } else if (jsonItem.type == 5) {
  574. console.log(jsonItem, 111);
  575. if (item.ques[indexs].text.length || item.ques[indexs].imageList.length) {
  576. return true;
  577. } else {
  578. return false;
  579. }
  580. }
  581. });
  582. if (isOver) {
  583. count++;
  584. console.log(item, 444);
  585. }
  586. }
  587. } else if (item.type == 5) {
  588. //简答题
  589. if(hasSpecail) {
  590. if (item.ansText.text.length || item.ansText.imageList.length) {
  591. count++;
  592. }
  593. }
  594. }
  595. });
  596. return count;
  597. },
  598. /**
  599. * 暂不交卷
  600. */
  601. noSubmit() {
  602. //设为允许退出页面
  603. this.needBack = false;
  604. uni.navigateBack({
  605. delta: 1
  606. });
  607. },
  608. /**
  609. * 不离开
  610. */
  611. noLeave() {
  612. this.isLastCount = false;
  613. },
  614. /**
  615. * 立即离开并交卷
  616. */
  617. leaveNow() {
  618. this.isSubmit = true;
  619. uni.navigateBack({
  620. delta: 1
  621. });
  622. let score = 0; //计算总分
  623. let reportStatus = 0;
  624. let number = 0;
  625. let passScore = 0;
  626. let allScore = 0; //总分
  627. this.questionList.forEach((item, index) => {
  628. passScore = item.passScore
  629. if (item.type == 1) {
  630. if (item.ques == item.ans) {
  631. item.scoreResult = item.score;
  632. score += item.score;
  633. number++;
  634. } else {
  635. item.scoreResult = 0;
  636. }
  637. allScore += item.score;
  638. } else if (item.type == 2) {
  639. let isRight =
  640. item.ques &&
  641. item.ques.every((quesItem, quesIndex) => {
  642. return item.ques[quesIndex] == item.ans[quesIndex];
  643. });
  644. if (isRight) { //全对
  645. item.scoreResult = item.score;
  646. score += item.score;
  647. number++;
  648. } else {
  649. let checkboxScore = item.score; //获取单题总分数
  650. item.ques.forEach((ques,quesIndex) => {
  651. //选错一个全扣
  652. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  653. checkboxScore = 0;
  654. }
  655. })
  656. //没选错
  657. if(checkboxScore) {
  658. item.ans.forEach((ans,quesIndex) => {
  659. //选错一个全扣
  660. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  661. checkboxScore -= item.partScore;
  662. }
  663. })
  664. }
  665. if(checkboxScore <= 0) {
  666. item.scoreResult = 0;
  667. } else {
  668. item.scoreResult = checkboxScore;
  669. }
  670. score += checkboxScore;
  671. }
  672. allScore += item.score;
  673. } else if (item.type == 3) {
  674. if (item.ques == item.ans) {
  675. item.scoreResult = item.score;
  676. score += item.score;
  677. number++;
  678. } else {
  679. item.scoreResult = 0;
  680. }
  681. allScore += item.score;
  682. }
  683. });
  684. if(score >= passScore) {
  685. reportStatus = 1
  686. } else {
  687. reportStatus = 0
  688. }
  689. this.$api
  690. .bankRecordEdit({
  691. chapterId:this.chapterId,
  692. moduleId:this.moduleId,
  693. examId: this.id,
  694. goodsId: this.goodsId,
  695. recordId:this.recordId,
  696. courseId:this.courseId,
  697. reportStatus:reportStatus,
  698. rightQuestionNum: number,
  699. status: 1,
  700. gradeId:this.gradeId,
  701. performance: score,
  702. totalScore: allScore,
  703. // examTime: parseInt(this.allTimes),
  704. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  705. // historyExamJson: JSON.stringify(this.questionList)
  706. })
  707. .then(res => {});
  708. },
  709. /**
  710. * 立即交卷
  711. */
  712. submitNow() {
  713. this.showpopups = false;
  714. this.needBack = false;
  715. this.submit();
  716. },
  717. /**
  718. * 离开页面统计回答正确题数
  719. */
  720. examRecordEdit() {
  721. if (!this.isSubmit) {
  722. let number = 0;
  723. let score = 0;
  724. let doQuestionNum = 0;
  725. let reportStatus = 0;
  726. this.questionList.forEach((item, index) => {
  727. if (item.type == 1) {
  728. if (item.ques == item.ans) {
  729. score += item.score;
  730. number++;
  731. }
  732. if (item.ques) {
  733. doQuestionNum++;
  734. }
  735. } else if (item.type == 2) {
  736. let isRight =
  737. item.ques &&
  738. item.ques.every((quesItem, quesIndex) => {
  739. return item.ques[quesIndex] == item.ans[quesIndex];
  740. });
  741. if (isRight) {
  742. score += item.score;
  743. number++;
  744. } else {
  745. let checkboxScore = item.score; //获取单题总分数
  746. item.ques.forEach((ques,quesIndex) => {
  747. //选错一个全扣
  748. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  749. checkboxScore = 0;
  750. }
  751. })
  752. //没选错
  753. if(checkboxScore) {
  754. item.ans.forEach((ans,quesIndex) => {
  755. //选错一个全扣
  756. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  757. checkboxScore -= item.partScore;
  758. }
  759. })
  760. }
  761. if(checkboxScore <= 0) {
  762. item.scoreResult = 0;
  763. } else {
  764. item.scoreResult = checkboxScore;
  765. score += checkboxScore;
  766. number++;
  767. }
  768. }
  769. if (item.ques && item.ques.length) {
  770. doQuestionNum++;
  771. }
  772. } else if (item.type == 3) {
  773. if (item.ques == item.ans) {
  774. score += item.score;
  775. number++;
  776. }
  777. if (item.ques) {
  778. doQuestionNum++;
  779. }
  780. } else if (item == 4) {
  781. if (item.ques.length) {
  782. doQuestionNum++;
  783. }
  784. } else if (item.type == 5) {
  785. if (item.ques) {
  786. doQuestionNum++;
  787. }
  788. }
  789. });
  790. if(score >= 60) {
  791. reportStatus = 1
  792. }
  793. this.$api
  794. .bankRecordEdit({
  795. chapterId:this.chapterId,
  796. moduleId:this.moduleId,
  797. gradeId:this.gradeId,
  798. examId: this.id,
  799. courseId:this.courseId,
  800. goodsId: this.goodsId,
  801. recordId:this.recordId,
  802. performance:score,
  803. reportStatus:reportStatus,
  804. status: 1,
  805. // historyExamJson: JSON.stringify(this.questionList)
  806. })
  807. .then(res => {});
  808. }
  809. },
  810. /**
  811. * @param {Object} second倒计时过滤器
  812. */
  813. countdown(second) {
  814. if (second) {
  815. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  816. let m = parseInt((second / 60) % 60); // 计算分数
  817. let s = parseInt(second % 60); // 计算当前秒数
  818. if (h < 10) h = '0' + h;
  819. if (m < 10) m = '0' + m;
  820. if (s < 10) s = '0' + s;
  821. return h + ':' + m + ':' + s;
  822. } else {
  823. return '';
  824. }
  825. },
  826. /**
  827. * 请求题目列表
  828. */
  829. goodsQuestionList() {
  830. this.$api
  831. .goodsQuestionList({
  832. examId: this.id
  833. })
  834. .then(res => {
  835. if (!res.data.data.length) {
  836. this.hideDialog();
  837. uni.showModal({
  838. showCancel: false,
  839. content: '该试卷暂无题目',
  840. success: function(k) {
  841. if (k.confirm) {
  842. uni.navigateBack();
  843. }
  844. }
  845. });
  846. return;
  847. }
  848. this.allTimes = res.data.data[0].answerTime * 60;
  849. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  850. //考试时间到了自动交卷
  851. if (this.lastTime) {
  852. this.timer = setInterval(() => {
  853. if (this.lastTime <= 0) {
  854. clearInterval(this.timer);
  855. uni.showModal({
  856. title: '提示',
  857. content: '考试时间到,自动交卷',
  858. confirmText: '确定',
  859. showCancel: false,
  860. success: res => {
  861. this.submit();
  862. }
  863. });
  864. return;
  865. }
  866. this.lastTime--;
  867. }, 1000);
  868. } else {
  869. }
  870. res.data.data.forEach((item, index) => {
  871. if (typeof item.jsonStr == 'string') {
  872. item.jsonStr = JSON.parse(item.jsonStr);
  873. if (item.type == 2) {
  874. //多选
  875. item.jsonStr.forEach(str => {
  876. str.optionsId = '' + str.optionsId;
  877. });
  878. let arr = item.answerQuestion.split(',');
  879. arr.forEach((a, i) => {
  880. arr[i] = '' + a;
  881. });
  882. item.ans = arr;
  883. return;
  884. } else if (item.type == 5) {
  885. //简答题
  886. item.ansText = {
  887. text: '',
  888. imageList: []
  889. };
  890. } else if (item.type == 4) {
  891. //案例题
  892. console.log(item.jsonStr);
  893. item.ques = [];
  894. item.current = 0;
  895. let ansArr = [];
  896. item.jsonStr.forEach((json, index) => {
  897. if (json.type == 1) {
  898. ansArr[index] = json.answerQuestion;
  899. } else if (json.type == 2) {
  900. json.optionsList.forEach(str => {
  901. str.optionsId = '' + str.optionsId;
  902. });
  903. let arr = json.answerQuestion.split(',');
  904. arr.forEach((a, i) => {
  905. arr[i] = '' + a;
  906. });
  907. ansArr[index] = arr;
  908. } else if (json.type == 3) {
  909. ansArr[index] = json.answerQuestion;
  910. } else if (json.type == 5) {
  911. ansArr[index] = {
  912. text: '',
  913. imageList: []
  914. };
  915. json.ansText = {
  916. text: '',
  917. imageList: []
  918. };
  919. }
  920. });
  921. item.ans = ansArr;
  922. return;
  923. }
  924. item.ans = item.answerQuestion;
  925. }
  926. });
  927. this.questionList = res.data.data;
  928. this.lastCount = this.questionList.length;
  929. this.examRecord();
  930. });
  931. },
  932. /**
  933. * 记录总题数
  934. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  935. */
  936. examRecord(hasSpecial) {
  937. let questionList = 0;
  938. if(!hasSpecial) {
  939. this.questionList.forEach((item, index) => {
  940. if(item.type == 1 || item.type == 2 || item.type == 3) {
  941. questionList++;
  942. }
  943. })
  944. } else {
  945. questionList = this.questionList.length;
  946. }
  947. this.$api
  948. .bankRecord({
  949. chapterExamId: this.chapterId || 0,
  950. moduleExamId: this.moduleId || 0,
  951. examId: this.id,
  952. goodsId: this.goodsId,
  953. gradeId:this.gradeId,
  954. totalQuestionNum: questionList
  955. })
  956. .then(res => {
  957. this.recordId = res.data.data;
  958. });
  959. },
  960. /**
  961. * @param {Object} e单选点击
  962. */
  963. radioSelect(optionsId, bindex) {
  964. if (this.questionList[bindex].ques) return;
  965. this.$set(this.questionList[bindex], 'ques', optionsId);
  966. },
  967. /**
  968. * @param {Object} e案例单选点击
  969. */
  970. radioSelectChild(optionsId, ansIndex, bindex) {
  971. if (this.questionList[bindex].ques[ansIndex]) return;
  972. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  973. },
  974. /**
  975. * @param {Object} 多选点击
  976. */
  977. checkboxSelect(optionsId, bindex, index) {
  978. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  979. },
  980. /**
  981. * @param {Object} 案例多选点击
  982. */
  983. checkboxSelectChild(bindex, ansIndex, childIndex) {
  984. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  985. },
  986. /**
  987. * @param {Object} 多选确认
  988. */
  989. checkboxSubmit(bindex) {
  990. if (this.questionList[bindex].ques) return;
  991. let arr = [];
  992. this.questionList[bindex].jsonStr.forEach(item => {
  993. if (item.checked) {
  994. arr.push(item.optionsId);
  995. }
  996. });
  997. this.$set(this.questionList[bindex], 'ques', arr);
  998. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  999. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1000. });
  1001. },
  1002. /**
  1003. * @param {Object} 案例多选确认
  1004. */
  1005. checkboxSubmitChild(bindex, ansIndex) {
  1006. if (this.questionList[bindex].ques[ansIndex]) return;
  1007. let arr = [];
  1008. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1009. if (item.checked) {
  1010. arr.push(item.optionsId);
  1011. }
  1012. });
  1013. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1014. },
  1015. /**
  1016. * @param {Object} index
  1017. * @param {Object} bindex
  1018. * 判断题
  1019. */
  1020. judgeSelect(index, bindex) {
  1021. if (this.questionList[bindex].ques) return;
  1022. this.$set(this.questionList[bindex], 'ques', index + '');
  1023. },
  1024. /**
  1025. * @param {Object} ansindex
  1026. * @param {Object} childindex
  1027. * @param {Object} bindex
  1028. * 案例判断题
  1029. */
  1030. judgeSelectChild(ansindex, childindex, bindex) {
  1031. if (this.questionList[bindex].ques[ansindex]) return;
  1032. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1033. },
  1034. openFooterTab() {
  1035. this.show = true;
  1036. },
  1037. hideDialog() {
  1038. this.showDialog = false;
  1039. },
  1040. changeIndex(index) {
  1041. this.current = index;
  1042. },
  1043. swiperChange(e) {
  1044. this.current = e.detail.current;
  1045. },
  1046. pdsubmit() {
  1047. if (this.bankType == 1) {
  1048. let ansCount = this.questionOverNum(); //已答题数
  1049. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1050. //没有答完
  1051. if (this.lastCount !== 0) {
  1052. this.cgType = 6;
  1053. this.showpopups = true;
  1054. return;
  1055. }
  1056. }
  1057. this.submit();
  1058. },
  1059. /**
  1060. * 交卷
  1061. */
  1062. submit() {
  1063. let score = 0; //计算总分
  1064. let reportStatus = 0;
  1065. let number = 0; //做对的题目数量
  1066. let doQuestionNum = 0; //做过的题目数量
  1067. let allScore = 0; //总分
  1068. let passScore = 0;
  1069. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1070. let doQuestionIds = []; //做过的题目id
  1071. let rightQuestionIds = []; //做对的题目id
  1072. this.questionList.forEach((item, index) => {
  1073. passScore = item.passScore
  1074. if (item.type == 1) {
  1075. //正确
  1076. if (item.ques == item.ans) {
  1077. item.scoreResult = item.score;
  1078. score += item.score;
  1079. number++;
  1080. rightQuestionIds.push(item.questionId)
  1081. } else { //错误
  1082. item.scoreResult = 0;
  1083. doWrongQuestionIds.push(item.questionId)
  1084. }
  1085. allScore += item.score;
  1086. if (item.ques) {
  1087. doQuestionNum++;
  1088. doQuestionIds.push(item.questionId)
  1089. }
  1090. } else if (item.type == 2) {
  1091. let isRight =
  1092. item.ans &&
  1093. item.ans.every((quesItem, quesIndex) => {
  1094. return item.ques[quesIndex] == item.ans[quesIndex];
  1095. });
  1096. if (isRight) {
  1097. score += item.score;
  1098. number++;
  1099. item.scoreResult = item.score;
  1100. rightQuestionIds.push(item.questionId)
  1101. } else {
  1102. let checkboxScore = item.score; //获取单题总分数
  1103. item.ques.forEach((ques,quesIndex) => {
  1104. //选错一个全扣
  1105. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1106. checkboxScore = 0;
  1107. }
  1108. })
  1109. console.log(checkboxScore)
  1110. //没选错
  1111. if(checkboxScore) {
  1112. item.ans.forEach((ans,quesIndex) => {
  1113. //漏选扣一部分
  1114. console.log(item.ques.indexOf(item.ans[quesIndex]))
  1115. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1116. checkboxScore -= item.partScore;
  1117. }
  1118. })
  1119. }
  1120. if(checkboxScore <= 0) { //0分
  1121. item.scoreResult = 0;
  1122. doWrongQuestionIds.push(item.questionId)
  1123. } else { //部分分
  1124. number++;
  1125. item.scoreResult = checkboxScore;
  1126. score += checkboxScore;
  1127. rightQuestionIds.push(item.questionId)
  1128. }
  1129. }
  1130. allScore += item.score;
  1131. if (item.ques && item.ques.length) {
  1132. doQuestionNum++;
  1133. doQuestionIds.push(item.questionId)
  1134. }
  1135. } else if (item.type == 3) {
  1136. if (item.ques == item.ans) {
  1137. item.scoreResult = item.score;
  1138. score += item.score;
  1139. number++;
  1140. rightQuestionIds.push(item.questionId)
  1141. } else {
  1142. item.scoreResult = 0;
  1143. doWrongQuestionIds.push(item.questionId)
  1144. }
  1145. allScore += item.score;
  1146. if (item.ques) {
  1147. doQuestionNum++;
  1148. doQuestionIds.push(item.questionId)
  1149. }
  1150. } else if (item.type == 4) {
  1151. if (item.ques && item.ques.length) {
  1152. doQuestionNum++;
  1153. }
  1154. } else if (item.type == 5) {
  1155. if (item.ques) {
  1156. doQuestionNum++;
  1157. }
  1158. }
  1159. });
  1160. //大于分及格
  1161. if(score >= passScore) {
  1162. reportStatus = 1
  1163. } else {
  1164. reportStatus = 0
  1165. }
  1166. //交卷
  1167. this.$api
  1168. .bankRecordEdit({
  1169. moduleId:this.moduleId,
  1170. chapterId:this.chapterId,
  1171. gradeId:this.gradeId,
  1172. examId: this.id,
  1173. goodsId: this.goodsId,
  1174. reportStatus:reportStatus,
  1175. recordId: this.recordId,
  1176. courseId:this.courseId,
  1177. // rightQuestionNum: number,
  1178. status: 1,
  1179. // doQuestionIds:doQuestionIds.join(','),
  1180. // rightQuestionIds:rightQuestionIds.join(','),
  1181. // doQuestionNum: doQuestionNum,
  1182. performance: score,
  1183. totalScore: allScore,
  1184. // examTime: parseInt(this.allTimes),
  1185. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1186. // historyExamJson: JSON.stringify(this.questionList)
  1187. })
  1188. .then(res => {
  1189. this.isSubmit = true;
  1190. if (res.data.code == 200) {
  1191. uni.showToast({
  1192. title: '交卷成功',
  1193. duration: 1000,
  1194. icon: 'none'
  1195. });
  1196. setTimeout(() => {
  1197. uni.redirectTo({
  1198. url: '/pages2/class/question_report?rightQuestionNum='+number+'&doWrongQuestionNum='+doWrongQuestionIds.length+'&score='+score+'&totalScore='+allScore+'&reportStatus='+reportStatus
  1199. });
  1200. }, 1000);
  1201. }
  1202. });
  1203. },
  1204. /**
  1205. * @param {Object} imgIndex
  1206. * @param {Object} bankIndex
  1207. * 删除简答图片
  1208. */
  1209. deleteImg(imgIndex, bankIndex) {
  1210. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1211. },
  1212. /**
  1213. * @param {Object} imgIndex
  1214. * @param {Object} bankIndex
  1215. * @param {Object} ansIndex
  1216. * 删除案例题简答图片
  1217. */
  1218. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1219. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1220. },
  1221. /**
  1222. * @param {Object} bankindex
  1223. * 选择上传图片
  1224. */
  1225. chooseImg(bankindex) {
  1226. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1227. uni.showToast({
  1228. icon:'none',
  1229. title:'最多选择4张'
  1230. })
  1231. return;
  1232. }
  1233. uni.chooseImage({
  1234. count: 1, //默认9
  1235. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1236. sourceType: ['album', 'camera'], //从相册选择
  1237. success: res => {
  1238. let self = this;
  1239. // console.log(JSON.stringify(res.tempFilePaths));
  1240. let img = res.tempFilePaths[0];
  1241. uni.getImageInfo({
  1242. src: img,
  1243. success: async res => {
  1244. let canvasWidth = res.width; //图片原始长宽
  1245. let canvasHeight = res.height;
  1246. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1247. uni.compressImage({
  1248. src: img,
  1249. quality: 75,
  1250. width: '50%',
  1251. height: '50%',
  1252. success: async rest => {
  1253. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1254. this.questionList[bankindex].ansText.imageList.push(dir);
  1255. }
  1256. });
  1257. } else {
  1258. const dir = await self.uploadFile(img, 0);
  1259. this.questionList[bankindex].ansText.imageList.push(dir);
  1260. }
  1261. }
  1262. });
  1263. }
  1264. });
  1265. },
  1266. /**
  1267. * @param {Object} bankindex
  1268. * @param {Object} ansindex
  1269. * 案例题选择上传图片
  1270. */
  1271. chooseImgChild(bankindex, ansindex) {
  1272. uni.chooseImage({
  1273. count: 1, //默认9
  1274. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1275. sourceType: ['album', 'camera'], //从相册选择
  1276. success: res => {
  1277. let self = this;
  1278. // console.log(JSON.stringify(res.tempFilePaths));
  1279. let img = res.tempFilePaths[0];
  1280. uni.getImageInfo({
  1281. src: img,
  1282. success: async res => {
  1283. let canvasWidth = res.width; //图片原始长宽
  1284. let canvasHeight = res.height;
  1285. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1286. uni.compressImage({
  1287. src: img,
  1288. quality: 75,
  1289. width: '50%',
  1290. height: '50%',
  1291. success: async rest => {
  1292. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1293. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1294. }
  1295. });
  1296. } else {
  1297. const dir = await self.uploadFile(img, 0);
  1298. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1299. }
  1300. }
  1301. });
  1302. }
  1303. });
  1304. },
  1305. uploadFile(options, int) {
  1306. var self = this;
  1307. return new Promise((resolve, reject) => {
  1308. var data = {
  1309. imageStatus: int
  1310. };
  1311. self.$api.aliyunpolicy(data).then(res => {
  1312. console.log(res.data, 6);
  1313. if (res.data.code != 200) {
  1314. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1315. return;
  1316. }
  1317. var ossToken = res.data.data.resultContent;
  1318. if (ossToken.host == null || ossToken.host == undefined) {
  1319. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1320. return;
  1321. }
  1322. uni.uploadFile({
  1323. url: ossToken.host,
  1324. name: 'file',
  1325. filePath: options,
  1326. fileType: 'image',
  1327. header: {
  1328. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1329. },
  1330. formData: {
  1331. key: ossToken.dir,
  1332. OSSAccessKeyId: ossToken.accessid,
  1333. policy: ossToken.policy,
  1334. Signature: ossToken.signature,
  1335. callback: ossToken.callback,
  1336. success_action_status: 200
  1337. },
  1338. success: result => {
  1339. if (result.statusCode === 200) {
  1340. resolve(ossToken.dir);
  1341. } else {
  1342. uni.showToast({
  1343. title: '上传失败',
  1344. icon: 'none'
  1345. });
  1346. return;
  1347. }
  1348. },
  1349. fail: error => {
  1350. uni.showToast({
  1351. title: '上传接口报错' + error,
  1352. icon: 'none'
  1353. });
  1354. return;
  1355. }
  1356. });
  1357. });
  1358. });
  1359. },
  1360. /**
  1361. * @param {Object} type
  1362. * @param {Object} bankindex
  1363. * 简答题答案确认
  1364. */
  1365. submitAns(bankindex) {
  1366. console.log(this.questionList[bankindex]);
  1367. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1368. uni.showToast({
  1369. title: '请输入内容或上传图片',
  1370. duration: 2000,
  1371. icon: 'none'
  1372. });
  1373. return;
  1374. }
  1375. this.$set(this.questionList[bankindex], 'ques', {
  1376. imageList: this.questionList[bankindex].ansText.imageList,
  1377. text: this.questionList[bankindex].ansText.text
  1378. });
  1379. },
  1380. /**
  1381. * @param {Object} bankindex
  1382. * @param {Object} ansindex
  1383. * 案例题简答答案确认
  1384. */
  1385. submitAnsChild(bankindex, ansindex) {
  1386. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1387. uni.showToast({
  1388. title: '请输入内容或上传图片',
  1389. duration: 2000,
  1390. icon: 'none'
  1391. });
  1392. return;
  1393. }
  1394. this.$set(this.questionList[bankindex].ques, ansindex, {
  1395. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1396. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text
  1397. });
  1398. },
  1399. isRight(item, index) {
  1400. //单选
  1401. if (this.questionList[index].ques) {
  1402. if (item.type == 1) {
  1403. return this.questionList[index].ques == this.questionList[index].ans;
  1404. //多选
  1405. } else if (item.type == 2) {
  1406. //每一项都相等
  1407. return this.questionList[index].ques.every((item, i) => {
  1408. return item == this.questionList[index].ans[i];
  1409. });
  1410. //判断
  1411. } else if (item.type == 3) {
  1412. return this.questionList[index].ques == this.questionList[index].ans;
  1413. // } else if (item.type == 5) {
  1414. // if(this.questionList[index].ques.text){
  1415. // return true
  1416. // }else{
  1417. // return false
  1418. // }
  1419. } else {
  1420. return false;
  1421. }
  1422. } else {
  1423. return false;
  1424. }
  1425. },
  1426. right(bankIndex, ansIndex, option) {
  1427. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1428. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1429. return true;
  1430. } else {
  1431. return false;
  1432. }
  1433. } else {
  1434. return false;
  1435. }
  1436. },
  1437. wrong(bankIndex, ansIndex, option) {
  1438. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1439. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1440. return true;
  1441. } else {
  1442. return false;
  1443. }
  1444. } else {
  1445. return false;
  1446. }
  1447. },
  1448. isWrong(item, index) {
  1449. if (this.questionList[index].ques) {
  1450. //单选
  1451. if (item.type == 1) {
  1452. return this.questionList[index].ques != this.questionList[index].ans;
  1453. //多选
  1454. } else if (item.type == 2) {
  1455. //每一项都相等
  1456. return this.questionList[index].ques.some((item, index) => {
  1457. return item != this.questionList[index].ans;
  1458. });
  1459. //判断
  1460. } else if (item.type == 3) {
  1461. return this.questionList[index].ques != this.questionList[index].ans;
  1462. } else {
  1463. return false;
  1464. }
  1465. } else {
  1466. return false;
  1467. }
  1468. },
  1469. tabSelect(index, bankindex) {
  1470. this.$set(this.questionList[bankindex], 'current', index);
  1471. }
  1472. }
  1473. };
  1474. </script>
  1475. <style lang="scss" scoped>
  1476. .swiper {
  1477. width: 100%;
  1478. height: calc(100vh - 65px);
  1479. }
  1480. .lisSty {
  1481. margin-bottom: 16rpx;
  1482. display: flex;
  1483. .flex_auto {
  1484. flex: 1;
  1485. }
  1486. }
  1487. .activeTI {
  1488. vertical-align: middle;
  1489. display: inline-block;
  1490. border: 1rpx solid #eee;
  1491. border-radius: 50rpx;
  1492. height: 48rpx;
  1493. line-height: 46rpx;
  1494. text-align: center;
  1495. width: 48rpx;
  1496. margin-right: 15rpx;
  1497. color: #666;
  1498. font-size: 30rpx;
  1499. &.right {
  1500. color: #fff;
  1501. background: green;
  1502. }
  1503. &.wrong {
  1504. color: #fff;
  1505. background: red;
  1506. }
  1507. &.checked {
  1508. color: #fff;
  1509. background: blue;
  1510. }
  1511. }
  1512. .submit_checkbox {
  1513. margin: 20rpx auto;
  1514. width: 526rpx;
  1515. height: 80rpx;
  1516. background: rgba(0, 122, 255, 1);
  1517. color: #fff;
  1518. text-align: center;
  1519. line-height: 80rpx;
  1520. font-size: 30rpx;
  1521. border-radius: 40rpx;
  1522. }
  1523. .titles {
  1524. overflow: hidden;
  1525. margin-bottom: 24rpx;
  1526. }
  1527. .titBox {
  1528. padding: 41rpx 25rpx 24rpx 25rpx;
  1529. }
  1530. .tabs {
  1531. margin: 10rpx;
  1532. display: flex;
  1533. .tab {
  1534. margin: 0 10rpx;
  1535. width: 96rpx;
  1536. height: 48rpx;
  1537. line-height: 48rpx;
  1538. text-align: center;
  1539. color: #007aff;
  1540. font-size: 28rpx;
  1541. border-radius: 16rpx;
  1542. &.current {
  1543. color: #fff;
  1544. background: #007aff;
  1545. }
  1546. }
  1547. }
  1548. .ans {
  1549. margin: 8rpx 8rpx 8rpx;
  1550. .ans_input {
  1551. border-radius: 16rpx;
  1552. background: #fff;
  1553. .top {
  1554. border-bottom: 1rpx solid #eeeeee;
  1555. padding: 16rpx;
  1556. display: flex;
  1557. align-items: center;
  1558. .icon {
  1559. margin-right: 20rpx;
  1560. width: 40rpx;
  1561. height: 38rpx;
  1562. }
  1563. .progress {
  1564. flex: 1;
  1565. }
  1566. .submit {
  1567. width: 168rpx;
  1568. height: 48rpx;
  1569. line-height: 48rpx;
  1570. text-align: center;
  1571. color: #fff;
  1572. font-size: 30rpx;
  1573. background: #007aff;
  1574. border-radius: 24rpx;
  1575. &.disabled {
  1576. opacity: 0.6;
  1577. }
  1578. }
  1579. }
  1580. .textarea {
  1581. textarea {
  1582. width: 100%;
  1583. height: 287rpx;
  1584. padding: 10rpx;
  1585. }
  1586. }
  1587. .imgs {
  1588. overflow: hidden;
  1589. display: flex;
  1590. width: 100%;
  1591. .img {
  1592. width: 104rpx;
  1593. height: 104rpx;
  1594. border-radius: 8rpx;
  1595. position: relative;
  1596. margin: 20rpx;
  1597. text {
  1598. position: absolute;
  1599. right: -15rpx;
  1600. top: -15rpx;
  1601. width: 30rpx;
  1602. height: 30rpx;
  1603. text-align: center;
  1604. line-height: 30rpx;
  1605. color: #fff;
  1606. background: red;
  1607. border-radius: 50%;
  1608. }
  1609. image {
  1610. width: 100%;
  1611. height: 100%;
  1612. }
  1613. }
  1614. }
  1615. }
  1616. .ans_submit {
  1617. padding: 16rpx;
  1618. border-radius: 16rpx;
  1619. background: #fff;
  1620. .imgs {
  1621. overflow: hidden;
  1622. display: flex;
  1623. width: 100%;
  1624. .img {
  1625. width: 104rpx;
  1626. height: 104rpx;
  1627. border-radius: 8rpx;
  1628. position: relative;
  1629. margin: 20rpx;
  1630. image {
  1631. width: 100%;
  1632. height: 100%;
  1633. }
  1634. }
  1635. }
  1636. }
  1637. }
  1638. .firstLetter {
  1639. display: flex;
  1640. justify-content: space-between;
  1641. align-items: center;
  1642. margin-bottom: 30rpx;
  1643. .leftLetters {
  1644. display: flex;
  1645. align-items: center;
  1646. width: 220rpx;
  1647. .btnType {
  1648. padding: 5rpx 10rpx;
  1649. border: 1rpx solid #007aff;
  1650. border-radius: 10rpx;
  1651. background-color: rgba(0, 122, 255, 0.1);
  1652. font-size: 28rpx;
  1653. color: #007aff;
  1654. margin-right: 15rpx;
  1655. }
  1656. }
  1657. }
  1658. .popupView {
  1659. height: 100%;
  1660. padding-bottom: 100rpx;
  1661. .popupTops {
  1662. height: 77rpx;
  1663. border-bottom: 1rpx solid #eee;
  1664. text-align: center;
  1665. line-height: 77rpx;
  1666. font-size: 24rpx;
  1667. color: #999;
  1668. position: relative;
  1669. .topIcon {
  1670. position: absolute;
  1671. top: 10rpx;
  1672. left: 50%;
  1673. transform: translateX(-50%);
  1674. width: 80rpx;
  1675. height: 8rpx;
  1676. background-color: #999;
  1677. border-radius: 4rpx;
  1678. }
  1679. }
  1680. .popupContent {
  1681. }
  1682. }
  1683. .pageContent {
  1684. position: relative;
  1685. background-color: #eaeef1;
  1686. height: 100%;
  1687. padding-top: 8rpx;
  1688. padding-bottom: 100rpx;
  1689. overflow-y: scroll;
  1690. }
  1691. .pad_8 {
  1692. background-color: #fff;
  1693. margin: 0rpx 8rpx 8rpx;
  1694. border-radius: 16rpx;
  1695. &.no-margin {
  1696. margin-top:-16rpx;
  1697. border-radius: 0 0 16rpx 16rpx;
  1698. }
  1699. }
  1700. .answer {
  1701. height: 80rpx;
  1702. line-height: 80rpx;
  1703. padding: 0rpx 24rpx;
  1704. display: flex;
  1705. align-items: center;
  1706. justify-content: space-between;
  1707. color: #666;
  1708. font-size: 30rpx;
  1709. }
  1710. .footer_btn {
  1711. background-color: #fff;
  1712. z-index: 10078;
  1713. position: fixed;
  1714. bottom: 0rpx;
  1715. display: flex;
  1716. align-items: center;
  1717. justify-content: space-between;
  1718. width: 100%;
  1719. height: 98rpx;
  1720. padding: 0rpx 38rpx;
  1721. border-top: 1rpx solid #eee;
  1722. .flex_center {
  1723. flex:1;
  1724. display: flex;
  1725. justify-content: center;
  1726. align-items: center;
  1727. flex-direction: column;
  1728. margin:0 200rpx;
  1729. font-size: 24rpx;
  1730. color: #999999;
  1731. .up-icon {
  1732. margin-bottom:18rpx;
  1733. width:100%;
  1734. display: flex;
  1735. justify-content: center;
  1736. image {
  1737. width:58rpx;
  1738. height:21rpx;
  1739. }
  1740. }
  1741. }
  1742. .collect {
  1743. visibility: hidden;
  1744. width:100rpx;
  1745. &.show {
  1746. visibility: visible;
  1747. }
  1748. >view {
  1749. display: flex;
  1750. flex-direction: column;
  1751. align-items: center;
  1752. justify-content: center;
  1753. image {
  1754. width:32rpx;
  1755. height:32rpx;
  1756. margin-bottom:6rpx;
  1757. }
  1758. view {
  1759. font-size: 24rpx;
  1760. color: #999999;
  1761. }
  1762. }
  1763. }
  1764. }
  1765. .boxSty {
  1766. padding: 44rpx 41rpx 0rpx;
  1767. }
  1768. .liListSty {
  1769. border: 1rpx solid #eeeeee;
  1770. width: 88rpx;
  1771. height: 88rpx;
  1772. border-radius: 32rpx;
  1773. text-align: center;
  1774. line-height: 88rpx;
  1775. color: #333;
  1776. font-size: 32rpx;
  1777. float: left;
  1778. margin: 20rpx 23rpx;
  1779. &.isRight {
  1780. border: 1rpx solid #eeeeee;
  1781. color: #fff;
  1782. background: green;
  1783. }
  1784. &.isWrong {
  1785. border: 1rpx solid #eeeeee;
  1786. color: #fff;
  1787. background: red;
  1788. }
  1789. }
  1790. .answerInfos {
  1791. padding: 25rpx 25rpx 25rpx 23rpx;
  1792. }
  1793. .answerTitle {
  1794. margin-bottom: 28rpx;
  1795. color: #666;
  1796. font-size: 30rpx;
  1797. }
  1798. .answerContent {
  1799. font-size: 30rpx;
  1800. color: #666;
  1801. }
  1802. .textChild {
  1803. display: inline-block;
  1804. vertical-align: middle;
  1805. }
  1806. .dialog {
  1807. position: fixed;
  1808. left: 0;
  1809. top: 0;
  1810. width: 100%;
  1811. height: 100%;
  1812. background-color: rgba(0, 0, 0, 0.8);
  1813. display: flex;
  1814. flex-direction: column;
  1815. align-items: center;
  1816. justify-content: center;
  1817. z-index: 20000;
  1818. .text {
  1819. font-size: 32rpx;
  1820. color: #ffffff;
  1821. text-align: center;
  1822. }
  1823. .btn {
  1824. width: 242rpx;
  1825. height: 82rpx;
  1826. border: 2rpx solid #ffffff;
  1827. border-radius: 16rpx;
  1828. text-align: center;
  1829. line-height: 82rpx;
  1830. margin: 41rpx auto;
  1831. color: #fff;
  1832. font-size: 32rpx;
  1833. }
  1834. }
  1835. .dialog_wrap {
  1836. position: fixed;
  1837. left: 0;
  1838. top: 0;
  1839. width: 100%;
  1840. height: 100%;
  1841. z-index: 9999999999;
  1842. .bg {
  1843. background: rgba(0, 0, 0, 0.3);
  1844. position: absolute;
  1845. left: 0;
  1846. top: 0;
  1847. width: 100%;
  1848. height: 100%;
  1849. }
  1850. .dialog {
  1851. position: absolute;
  1852. left: 50%;
  1853. top: 50%;
  1854. transform: translate3D(-50%, -50%, 0);
  1855. width: 640rpx;
  1856. height: 439rpx;
  1857. background: #ffffff;
  1858. border-radius: 24rpx;
  1859. .title {
  1860. font-size: 30rpx;
  1861. font-weight: bold;
  1862. color: #333333;
  1863. line-height: 48rpx;
  1864. text-align: center;
  1865. margin-top: 40rpx;
  1866. }
  1867. .content {
  1868. margin: 35rpx 35rpx 0;
  1869. font-size: 30rpx;
  1870. color: #666666;
  1871. line-height: 48rpx;
  1872. }
  1873. .btns {
  1874. margin-top: 35rpx;
  1875. display: flex;
  1876. align-items: center;
  1877. justify-content: center;
  1878. .btn {
  1879. width: 200rpx;
  1880. height: 80rpx;
  1881. line-height: 80rpx;
  1882. text-align: center;
  1883. background: #f5f5f5;
  1884. border-radius: 40rpx;
  1885. font-size: 30rpx;
  1886. color: rgba(0, 122, 255, 1);
  1887. background: #f5f5f5;
  1888. margin: 0 20rpx;
  1889. &.active {
  1890. color: #f5f5f5;
  1891. background: rgba(0, 122, 255, 1);
  1892. }
  1893. }
  1894. }
  1895. }
  1896. }
  1897. .popboxs {
  1898. width: 100%;
  1899. height: 100%;
  1900. display: flex;
  1901. flex-direction: column;
  1902. align-items: center;
  1903. }
  1904. .classTops {
  1905. flex-shrink: 0;
  1906. padding: 39rpx 0rpx 4rpx;
  1907. font-weight: bold;
  1908. color: #333;
  1909. font-size: 30rpx;
  1910. }
  1911. .textStys {
  1912. width: 100%;
  1913. flex: 1;
  1914. padding: 36rpx;
  1915. }
  1916. .classFootsty {
  1917. flex-shrink: 0;
  1918. display: flex;
  1919. align-items: center;
  1920. justify-content: center;
  1921. padding: 10rpx 0rpx 40rpx;
  1922. .btnsty {
  1923. width: 200rpx;
  1924. height: 80rpx;
  1925. border-radius: 40rpx;
  1926. font-weight: bold;
  1927. font-size: 30rpx;
  1928. text-align: center;
  1929. line-height: 80rpx;
  1930. }
  1931. .btns1 {
  1932. background-color: #f5f5f5;
  1933. color: #007aff;
  1934. }
  1935. .btns2 {
  1936. margin-left: 40rpx;
  1937. background-color: #007aff;
  1938. color: #ffffff;
  1939. }
  1940. }
  1941. </style>