questionBank.vue 65 KB

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