questionBankExplain.vue 52 KB

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