questionBank.vue 68 KB

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