questionBank.vue 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar
  4. @clickLeft="clickLeft"
  5. left-icon="back"
  6. ref="navbar"
  7. :statusBar="true"
  8. :title="examData.examName"
  9. ></uni-nav-bar>
  10. <swiper class="swiper" :current="current" @change="swiperChange">
  11. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  12. <view class="pageContent">
  13. <view class="pad_8 titBox">
  14. <view class="firstLetter">
  15. <view class="leftLetters">
  16. <view class="btnType">
  17. <text v-if="bank.type == 1">单选</text>
  18. <text v-if="bank.type == 2">多选</text>
  19. <text v-if="bank.type == 3">判断</text>
  20. <text v-if="bank.type == 4">案例</text>
  21. <text v-if="bank.type == 5">简答</text>
  22. </view>
  23. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  24. </view>
  25. <view style="color: #666; font-size: 28rpx">{{
  26. countdown(lastTime)
  27. }}</view>
  28. </view>
  29. <view class="titles" @click="showPhoto(bank.content)"
  30. ><rich-text :nodes="bank.content"></rich-text
  31. ></view>
  32. </view>
  33. <template v-if="bank.type == 1">
  34. <view class="pad_8 titBox no-margin">
  35. <view v-if="!bank.ques">
  36. <view
  37. v-for="(item, index) in bank.jsonStr"
  38. :key="index"
  39. class="lisSty"
  40. @click="radioSelect(item.optionsId, bankIndex)"
  41. >
  42. <view class="activeTI">{{ ast[index] }}</view>
  43. <view class="flex_auto"
  44. >{{ item.content }}
  45. <view v-if="item.imgUrl">
  46. <image
  47. style="width: 600rpx"
  48. mode="widthFix"
  49. :src="$method.splitImgHost(item.imgUrl)"
  50. ></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="bank.ques">
  56. <view
  57. v-for="(item, index) in bank.jsonStr"
  58. :key="index"
  59. class="lisSty"
  60. @click="radioSelect(item.optionsId, bankIndex)"
  61. >
  62. <text
  63. :class="{
  64. right:
  65. bankType == 1 &&
  66. (item.optionsId == bank.ques ||
  67. item.optionsId == bank.ans),
  68. wrong:
  69. bankType == 1 &&
  70. item.optionsId == bank.ques &&
  71. bank.ques != bank.ans,
  72. user_choose: bankType == 2 && item.optionsId == bank.ques,
  73. }"
  74. class="activeTI"
  75. >
  76. {{ ast[index] }}
  77. </text>
  78. <view class="flex_auto">
  79. {{ item.content }}
  80. <view v-if="item.imgUrl">
  81. <image
  82. style="width: 600rpx"
  83. mode="widthFix"
  84. :src="$method.splitImgHost(item.imgUrl)"
  85. ></image>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view v-if="bankType == 1 && bank.ques">
  92. <view class="pad_8 answer">
  93. <view>题目答案:{{ ast[bank.ans - 1] }} </view>
  94. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  95. </view>
  96. <view class="pad_8 answerInfos">
  97. <view class="answerTitle">答案解析</view>
  98. <view class="answerContent"
  99. ><rich-text :nodes="bank.analysisContent"></rich-text
  100. ></view>
  101. </view>
  102. </view>
  103. </template>
  104. <template v-if="bank.type == 2">
  105. <view class="pad_8 titBox no-margin">
  106. <view v-if="!bank.ques">
  107. <view
  108. v-for="(item, index) in bank.jsonStr"
  109. :key="index"
  110. class="lisSty"
  111. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  112. >
  113. <view :class="{ checked: item.checked }" class="activeTI">{{
  114. ast[index]
  115. }}</view>
  116. <view class="flex_auto">
  117. {{ item.content }}
  118. <view v-if="item.imgUrl">
  119. <image
  120. style="width: 600rpx"
  121. mode="widthFix"
  122. :src="$method.splitImgHost(item.imgUrl)"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. <view v-if="bank.ques">
  129. <view
  130. v-for="(item, index) in bank.jsonStr"
  131. :key="index"
  132. class="lisSty"
  133. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  134. >
  135. <text
  136. :class="{
  137. right:
  138. bankType == 1 &&
  139. (bank.ques.indexOf(item.optionsId) != -1 ||
  140. bank.ans.indexOf(item.optionsId) != -1),
  141. wrong:
  142. bankType == 1 &&
  143. bank.ques.indexOf(item.optionsId) != -1 &&
  144. bank.ans.indexOf(item.optionsId) == -1,
  145. user_choose: bankType == 2 && item.checked,
  146. }"
  147. class="activeTI"
  148. >
  149. {{ ast[index] }}
  150. </text>
  151. <view class="flex_auto">
  152. {{ item.content }}
  153. <view v-if="item.imgUrl">
  154. <image
  155. style="width: 600rpx"
  156. mode="widthFix"
  157. :src="$method.splitImgHost(item.imgUrl)"
  158. ></image>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view
  164. v-if="bankType == 2 || (bankType == 1 && !bank.ques)"
  165. class="submit_checkbox"
  166. :class="{ disabled: !isCheckboxChecked(bank.jsonStr) }"
  167. @click="checkboxSubmit(bankIndex)"
  168. >确认答案</view
  169. >
  170. </view>
  171. <view v-if="bankType == 1 && bank.ques">
  172. <view class="pad_8 answer">
  173. <view>
  174. 题目答案:
  175. <text
  176. v-for="(ansItem, ansIndex) in bank.ans"
  177. :key="ansIndex"
  178. >{{ ast[ansItem - 1] }}</text
  179. >
  180. </view>
  181. <view>
  182. 我的答案:
  183. <text
  184. v-for="(quesItem, quesIndex) in bank.ques"
  185. :key="quesIndex"
  186. >{{ ast[quesItem - 1] }}</text
  187. >
  188. </view>
  189. </view>
  190. <view class="pad_8 answerInfos">
  191. <view class="answerTitle">答案解析</view>
  192. <view class="answerContent"
  193. ><rich-text :nodes="bank.analysisContent"></rich-text
  194. ></view>
  195. </view>
  196. </view>
  197. </template>
  198. <template v-if="bank.type == 3">
  199. <view class="pad_8 titBox no-margin">
  200. <view v-if="!bank.ques">
  201. <view
  202. v-for="(item, index) in judge"
  203. :key="index"
  204. class="lisSty"
  205. @click="judgeSelect(index, bankIndex)"
  206. >
  207. <view class="activeTI">{{ ast[index] }}</view>
  208. <view class="flex_auto">
  209. {{ item }}
  210. <view v-if="item.imgUrl">
  211. <image
  212. style="width: 600rpx"
  213. mode="widthFix"
  214. :src="$method.splitImgHost(item.imgUrl)"
  215. ></image>
  216. </view>
  217. </view>
  218. </view>
  219. </view>
  220. <view v-if="bank.ques">
  221. <view
  222. v-for="(item, index) in judge"
  223. :key="index"
  224. class="lisSty"
  225. @click="judgeSelect(index, bankIndex)"
  226. >
  227. <!-- right: bankType == 1 && (index == bank.ques || index == bank.ans),
  228. wrong: bankType == 1 && (index == bank.ques && bank.ques != bank.ans),
  229. user_choose: bankType == 2 && (index == bank.ques), -->
  230. <text
  231. :class="{
  232. right:
  233. bankType == 1 &&
  234. (index == (bank.ques == 1 ? 0 : 1) ||
  235. index != bank.ans),
  236. wrong:
  237. bankType == 1 &&
  238. index == (bank.ques == 1 ? 0 : 1) &&
  239. bank.ques != bank.ans,
  240. user_choose:
  241. bankType == 2 && index == (bank.ques == 1 ? 0 : 1),
  242. }"
  243. class="activeTI"
  244. >
  245. {{ ast[index] }}
  246. </text>
  247. <view class="flex_auto">
  248. {{ item }}
  249. <view v-if="item.imgUrl">
  250. <image
  251. style="width: 600rpx"
  252. mode="widthFix"
  253. :src="$method.splitImgHost(item.imgUrl)"
  254. ></image>
  255. </view>
  256. </view>
  257. </view>
  258. </view>
  259. </view>
  260. <view v-if="bankType == 1 && bank.ques">
  261. <view class="pad_8 answer">
  262. <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
  263. <view>我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
  264. </view>
  265. <view class="pad_8 answerInfos">
  266. <view class="answerTitle">答案解析</view>
  267. <view class="answerContent"
  268. ><rich-text :nodes="bank.analysisContent"></rich-text
  269. ></view>
  270. </view>
  271. </view>
  272. </template>
  273. <!-- 简答题 -->
  274. <template v-if="bank.type == 5">
  275. <view class="pad_8 titBox">
  276. <view class="ans">
  277. <view
  278. class="ans_input"
  279. v-if="
  280. bankType == 2 ||
  281. (bankType == 1 &&
  282. (!bank.ques ||
  283. (!bank.ques.imageList.length && !bank.ques.text)))
  284. "
  285. >
  286. <view class="top flex">
  287. <image
  288. :data-index="bankIndex"
  289. class="icon"
  290. @click="chooseImg(bankIndex)"
  291. src="/static/camera.png"
  292. mode=""
  293. ></image>
  294. <view class="progress"
  295. >{{ bank.ansText.imageList.length || "0" }}/4</view
  296. >
  297. <view
  298. class="submit"
  299. :class="{ disabled: !bank.ansText.text && hasImgs(bank) }"
  300. @click="submitAns(bankIndex)"
  301. >确认答案</view
  302. >
  303. </view>
  304. <view class="textarea">
  305. <textarea
  306. v-model="bank.ansText.text"
  307. placeholder="在此输入答案"
  308. ></textarea>
  309. </view>
  310. <view class="imgs">
  311. <view
  312. class="img"
  313. v-for="(img, imgIndex) in bank.ansText.imageList"
  314. :key="imgIndex"
  315. >
  316. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  317. <image :src="$method.splitImgHost(img, true)"></image>
  318. </view>
  319. </view>
  320. </view>
  321. <view
  322. class="ans_submit answerInfos"
  323. v-if="
  324. bankType == 1 &&
  325. bank.ques &&
  326. (bank.ques.imageList.length || bank.ques.text)
  327. "
  328. >
  329. <view class="answerTitle">我的答案:</view>
  330. {{ bank.ques.text }}
  331. <view class="imgs"
  332. ><image
  333. class="img"
  334. :key="quesIndex"
  335. v-for="(ques, quesIndex) in bank.ques.imageList"
  336. :src="$method.splitImgHost(ques, true)"
  337. ></image
  338. ></view>
  339. </view>
  340. </view>
  341. </view>
  342. <view
  343. v-if="
  344. bankType == 1 &&
  345. bank.ques &&
  346. (bank.ques.imageList.length || bank.ques.text)
  347. "
  348. >
  349. <view class="pad_8 answerInfos">
  350. <view class="answerTitle">答案解析:</view>
  351. <view class="answerContent"
  352. ><rich-text :nodes="bank.analysisContent"></rich-text
  353. ></view>
  354. </view>
  355. </view>
  356. </template>
  357. <!-- 案例题 -->
  358. <template v-if="bank.type == 4">
  359. <view class="tabs">
  360. <view
  361. class="tab"
  362. :class="{ current: tabIndex == bank.current }"
  363. :key="tabIndex"
  364. v-for="(tab, tabIndex) in bank.jsonStr"
  365. @click="tabSelect(tabIndex, bankIndex)"
  366. >
  367. 问题{{ tabIndex + 1 }}
  368. </view>
  369. </view>
  370. <view
  371. v-for="(ansItem, ansIndex) in bank.jsonStr"
  372. v-if="bank.current == ansIndex"
  373. :key="ansIndex"
  374. >
  375. <template v-if="ansItem.type == 1">
  376. <view class="pad_8 titBox">
  377. <view class="leftLetters">
  378. <view class="btnType">
  379. <text>单选</text>
  380. </view>
  381. </view>
  382. <view class="titles"
  383. ><rich-text :nodes="ansItem.content"></rich-text
  384. ></view>
  385. <view v-if="!bank.ques[ansIndex]">
  386. <view
  387. v-for="(option, childIndex) in ansItem.optionsList"
  388. :key="childIndex"
  389. class="lisSty"
  390. @click="
  391. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  392. "
  393. >
  394. <view class="activeTI">{{ ast[childIndex] }}</view>
  395. <view class="flex_auto">
  396. <rich-text
  397. class="textChild"
  398. :nodes="option.content"
  399. ></rich-text>
  400. <view v-if="option.imgUrl">
  401. <image
  402. style="width: 600rpx"
  403. mode="widthFix"
  404. :src="$method.splitImgHost(option.imgUrl)"
  405. ></image>
  406. </view>
  407. </view>
  408. </view>
  409. </view>
  410. <view v-if="bank.ques[ansIndex]">
  411. <view
  412. v-for="(option, childIndex) in ansItem.optionsList"
  413. :key="childIndex"
  414. class="lisSty"
  415. @click="
  416. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  417. "
  418. >
  419. <text
  420. :class="{
  421. right:
  422. bankType == 1 &&
  423. (option.optionsId == bank.ques[ansIndex] ||
  424. option.optionsId == bank.ans[ansIndex]),
  425. wrong:
  426. bankType == 1 &&
  427. option.optionsId == bank.ques[ansIndex] &&
  428. bank.ques[ansIndex] != bank.ans[ansIndex],
  429. user_choose:
  430. bankType == 2 &&
  431. option.optionsId == bank.ques[ansIndex],
  432. }"
  433. class="activeTI"
  434. >
  435. {{ ast[childIndex] }}
  436. </text>
  437. <view class="flex_auto">
  438. <rich-text :nodes="option.content"></rich-text>
  439. <view v-if="option.imgUrl">
  440. <image
  441. style="width: 600rpx"
  442. mode="widthFix"
  443. :src="$method.splitImgHost(option.imgUrl)"
  444. ></image>
  445. </view>
  446. </view>
  447. </view>
  448. </view>
  449. </view>
  450. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  451. <view class="pad_8 answer">
  452. <view>题目答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  453. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  454. </view>
  455. <view class="pad_8 answerInfos">
  456. <view class="answerTitle">答案解析</view>
  457. <view class="answerContent"
  458. ><rich-text :nodes="option.analysisContent"></rich-text
  459. ></view>
  460. </view>
  461. </view>
  462. </template>
  463. <template v-if="ansItem.type == 2">
  464. <view class="pad_8 titBox">
  465. <view class="leftLetters">
  466. <view class="btnType">
  467. <text>多选</text>
  468. </view>
  469. </view>
  470. <view class="titles"
  471. ><rich-text :nodes="ansItem.content"></rich-text
  472. ></view>
  473. <view v-if="!bank.ques[ansIndex]">
  474. <view
  475. v-for="(option, childindex) in ansItem.optionsList"
  476. :key="childindex"
  477. class="lisSty"
  478. @click="
  479. checkboxSelectChild(bankIndex, ansIndex, childindex)
  480. "
  481. >
  482. <view
  483. :class="{ checked: option.checked }"
  484. class="activeTI"
  485. >{{ ast[childindex] }}</view
  486. >
  487. <view class="flex_auto">
  488. <rich-text :nodes="option.content"></rich-text>
  489. <view v-if="option.imgUrl">
  490. <image
  491. style="width: 600rpx"
  492. mode="widthFix"
  493. :src="$method.splitImgHost(option.imgUrl)"
  494. ></image>
  495. </view>
  496. </view>
  497. </view>
  498. </view>
  499. <view
  500. v-if="
  501. bankType == 2 || (bankType == 1 && !bank.ques[ansIndex])
  502. "
  503. class="submit_checkbox"
  504. :class="{
  505. disabled: !isCheckboxChecked(ansItem.optionsList),
  506. }"
  507. @click="checkboxSubmitChild(bankIndex, ansIndex)"
  508. >确认答案</view
  509. >
  510. <view v-if="bank.ques && bank.ques[ansIndex]">
  511. <view
  512. v-for="(option, childindex) in ansItem.optionsList"
  513. :key="childindex"
  514. class="lisSty"
  515. @click="
  516. checkboxSelectChild(bankIndex, ansIndex, childindex)
  517. "
  518. >
  519. <text
  520. :class="{
  521. right:
  522. bankType == 1 && right(bankIndex, ansIndex, option),
  523. wrong:
  524. bankType == 1 && wrong(bankIndex, ansIndex, option),
  525. user_choose: bankType == 2 && option.checked,
  526. }"
  527. class="activeTI"
  528. >
  529. {{ ast[childindex] }}
  530. </text>
  531. <view class="flex_auto">
  532. <rich-text :nodes="option.content"></rich-text>
  533. <view v-if="option.imgUrl">
  534. <image
  535. style="width: 600rpx"
  536. mode="widthFix"
  537. :src="$method.splitImgHost(option.imgUrl)"
  538. ></image>
  539. </view>
  540. </view>
  541. </view>
  542. </view>
  543. </view>
  544. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  545. <view class="pad_8 answer">
  546. <view>
  547. 题目答案:
  548. <text
  549. :key="ansItemIndex1"
  550. v-for="(ansItem1, ansItemIndex1) in bank.ans[ansIndex]"
  551. >{{ ast[ansItem1 - 1] }}</text
  552. >
  553. </view>
  554. <view>
  555. 我的答案:
  556. <text
  557. :key="quesItemIndex"
  558. v-for="(quesItem, quesItemIndex) in bank.ques[ansIndex]"
  559. >{{ ast[quesItem - 1] }}</text
  560. >
  561. </view>
  562. </view>
  563. <view class="pad_8 answerInfos">
  564. <view class="answerTitle">答案解析</view>
  565. <view class="answerContent"
  566. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  567. ></view>
  568. </view>
  569. </view>
  570. </template>
  571. <template v-if="ansItem.type == 3">
  572. <view class="pad_8 titBox">
  573. <view class="leftLetters">
  574. <view class="btnType">
  575. <text>判断</text>
  576. </view>
  577. </view>
  578. <view class="titles"
  579. ><rich-text :nodes="ansItem.content"></rich-text
  580. ></view>
  581. <view v-if="!bank.ques[ansIndex]">
  582. <view
  583. v-for="(option, childindex) in judge"
  584. :key="childindex"
  585. class="lisSty"
  586. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  587. >
  588. <view class="activeTI">{{ ast[childindex] }}</view>
  589. <view class="flex_auto">
  590. {{ option }}
  591. <view v-if="option.imgUrl">
  592. <image
  593. style="width: 600rpx"
  594. mode="widthFix"
  595. :src="$method.splitImgHost(option.imgUrl)"
  596. ></image>
  597. </view>
  598. </view>
  599. </view>
  600. </view>
  601. <view v-if="bank.ques[ansIndex]">
  602. <view
  603. v-for="(option, childindex) in judge"
  604. :key="childindex"
  605. class="lisSty"
  606. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  607. >
  608. <text
  609. :class="{
  610. right:
  611. bankType == 1 &&
  612. (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
  613. childindex != bank.ans[ansIndex]),
  614. wrong:
  615. bankType == 1 &&
  616. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
  617. bank.ques[ansIndex] != bank.ans[ansIndex],
  618. user_choose:
  619. bankType == 2 &&
  620. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1),
  621. }"
  622. class="activeTI"
  623. >
  624. {{ ast[childindex] }}
  625. </text>
  626. <view class="flex_auto">
  627. {{ option }}
  628. <view v-if="option.imgUrl">
  629. <image
  630. style="width: 600rpx"
  631. mode="widthFix"
  632. :src="$method.splitImgHost(option.imgUrl)"
  633. ></image>
  634. </view>
  635. </view>
  636. </view>
  637. </view>
  638. </view>
  639. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  640. <view class="pad_8 answer">
  641. <view
  642. >题目答案:{{
  643. ast[bank.ans[ansIndex] == 1 ? 0 : 1]
  644. }}</view
  645. >
  646. <view
  647. >我的答案:{{
  648. ast[bank.ques[ansIndex] == 1 ? 0 : 1]
  649. }}</view
  650. >
  651. </view>
  652. <view class="pad_8 answerInfos">
  653. <view class="answerTitle">答案解析</view>
  654. <view class="answerContent"
  655. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  656. ></view>
  657. </view>
  658. </view>
  659. </template>
  660. <!-- 简答题 -->
  661. <template v-if="ansItem.type == 5">
  662. <view class="pad_8 titBox_title">
  663. <view class="leftLetters">
  664. <view class="btnType">
  665. <text>简答</text>
  666. </view>
  667. </view>
  668. <view><rich-text :nodes="ansItem.content"></rich-text></view>
  669. </view>
  670. <view class="pad_8 titBox_title">
  671. <view class="ans">
  672. <view
  673. class="ans_input"
  674. v-if="
  675. bankType == 2 ||
  676. (bankType == 1 &&
  677. (!bank.ques[ansIndex] ||
  678. (!bank.ques[ansIndex].text &&
  679. !bank.ques[ansIndex].imageList.length)))
  680. "
  681. >
  682. <view class="top flex">
  683. <image
  684. class="icon"
  685. @click="chooseImgChild(bankIndex, ansIndex)"
  686. src="/static/camera.png"
  687. mode=""
  688. ></image>
  689. <view class="progress"
  690. >{{ ansItem.ansText.imageList.length || "0" }}/4</view
  691. >
  692. <view
  693. class="submit"
  694. :class="{
  695. disabled: !ansItem.ansText.text && hasImgs(ansItem),
  696. }"
  697. @click="submitAnsChild(bankIndex, ansIndex)"
  698. >确认答案</view
  699. >
  700. </view>
  701. <view class="textarea">
  702. <textarea
  703. v-model="ansItem.ansText.text"
  704. placeholder="在此输入答案"
  705. ></textarea>
  706. </view>
  707. <view class="imgs">
  708. <view
  709. class="img"
  710. v-for="(img, imgIndex) in ansItem.ansText.imageList"
  711. :key="imgIndex"
  712. >
  713. <text
  714. @click="
  715. deleteImgChild(imgIndex, bankIndex, ansIndex)
  716. "
  717. >x</text
  718. >
  719. <image :src="$method.splitImgHost(img, true)"></image>
  720. </view>
  721. </view>
  722. </view>
  723. <view
  724. class="ans_submit answerInfos"
  725. v-if="
  726. bankType == 1 &&
  727. bank.ques[ansIndex] &&
  728. (bank.ques[ansIndex].imageList.length ||
  729. bank.ques[ansIndex].text)
  730. "
  731. >
  732. <view class="answerTitle">我的答案</view>
  733. {{ bank.ques[ansIndex].text || "" }}
  734. <view class="imgs">
  735. <image
  736. class="img"
  737. v-for="(ques, quesIndex) in bank.ques[ansIndex]
  738. .imageList"
  739. :key="quesIndex"
  740. :src="$method.splitImgHost(ques, true)"
  741. ></image>
  742. </view>
  743. </view>
  744. </view>
  745. </view>
  746. <view
  747. v-if="
  748. bankType == 1 &&
  749. (bank.ques[ansIndex].imageList.length ||
  750. bank.ques[ansIndex].text)
  751. "
  752. >
  753. <view class="pad_8 answerInfos">
  754. <view class="answerTitle">答案解析</view>
  755. <view class="answerContent"
  756. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  757. ></view>
  758. </view>
  759. </view>
  760. </template>
  761. </view>
  762. </template>
  763. <view class="footer_btn">
  764. <view
  765. class="collect"
  766. :class="{ show: goodsId && !isFromVideo ? true : false }"
  767. @click="collect(collectList[bankIndex], bankIndex)"
  768. >
  769. <view v-if="collectList[bankIndex]">
  770. <image src="/static/icon/collected.png" mode=""></image>
  771. <view>取消收藏</view>
  772. </view>
  773. <view v-if="!collectList[bankIndex]">
  774. <image src="/static/icon/collect.png" mode=""></image>
  775. <view>收藏</view>
  776. </view>
  777. </view>
  778. <view class="flex_center" @click="openFooterTab">
  779. <view class="up-icon">
  780. <image src="/static/up.png"></image>
  781. </view>
  782. 答题卡
  783. </view>
  784. <view class="collect show" @click="pdsubmit">
  785. <view>
  786. <image src="/static/jj.png" mode=""></image>
  787. <view>交卷</view>
  788. </view>
  789. </view>
  790. </view>
  791. </view>
  792. </swiper-item>
  793. </swiper>
  794. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  795. <view class="popupView">
  796. <view class="popupTops">
  797. <view class="topIcon"></view>
  798. 点击编号即可跳转至对应题目
  799. </view>
  800. <view class="popupContent">
  801. <scroll-view scroll-y="true" style="height: 506rpx">
  802. <view class="boxSty">
  803. <view
  804. v-for="(item, index) in questionList"
  805. :key="index"
  806. @click="changeIndex(index)"
  807. :class="{
  808. isRight: bankType == 1 && isRight(item, index),
  809. isWrong: bankType == 1 && isWrong(item, index),
  810. isPart: bankType == 1 && isPart(item, index),
  811. isOver: bankType == 1 && isOver(item, index),
  812. check_ans: bankType == 2 && isCheck(item, index),
  813. }"
  814. class="liListSty"
  815. >
  816. {{ index + 1 }}
  817. </view>
  818. </view>
  819. </scroll-view>
  820. </view>
  821. </view>
  822. </u-popup>
  823. <view class="dialog" v-if="showDialog">
  824. <image class="pointer" src="/static/pointer.png" mode=""></image>
  825. <view class="text">左右滑动切换上下题</view>
  826. <view class="btn" @click="showDialog = false">我知道了</view>
  827. </view>
  828. <view class="dialog-arrow" v-if="showArrow">
  829. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  830. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  831. <view class="btn" @click="showArrow = false">我知道了</view>
  832. </view>
  833. <view class="dialog_wrap" v-if="testOver">
  834. <view class="bg"></view>
  835. <view class="dialog">
  836. <view class="title">温馨提示</view>
  837. <view class="content">
  838. <view>您已完成所有题目,</view>
  839. <view>快去交卷吧!</view>
  840. </view>
  841. <view class="btns">
  842. <view class="btn" @click="noSubmit()">暂不交卷</view>
  843. <view class="btn active" @click="submitNow()">立即交卷</view>
  844. </view>
  845. </view>
  846. </view>
  847. <view class="dialog_wrap" v-if="isLastCount">
  848. <view class="bg"></view>
  849. <view class="dialog">
  850. <view class="title">温馨提示</view>
  851. <view class="content">
  852. <view
  853. >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
  854. >
  855. </view>
  856. <view class="btns">
  857. <view class="btn" @click="noLeave()">暂不离开</view>
  858. <view class="btn active" @click="leaveNow()">继续离开</view>
  859. </view>
  860. </view>
  861. </view>
  862. <u-popup
  863. v-model="showpopups"
  864. mode="center"
  865. border-radius="24"
  866. height="439rpx"
  867. width="640rpx"
  868. :mask-close-able="false"
  869. >
  870. <view class="popboxs">
  871. <view class="classTops">温馨提示</view>
  872. <view class="textStys">
  873. {{
  874. cgType === 7
  875. ? "您还未交卷,确定结束做题吗?"
  876. : cgType === 8
  877. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  878. : cgType === 6
  879. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  880. : cgType == 9
  881. ? `您已完成所有题目,快去交卷吧!`
  882. : ""
  883. }}
  884. </view>
  885. <view class="classFootsty" v-if="cgType === 6">
  886. <view class="btnsty btns1" @click="submit">立即交卷</view>
  887. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  888. </view>
  889. <view class="classFootsty" v-if="cgType === 7">
  890. <view class="btnsty btns1" @click="backPages">下次继续</view>
  891. <view class="btnsty btns2" @click="submit">结束做题</view>
  892. </view>
  893. <view class="classFootsty" v-if="cgType === 8">
  894. <view class="btnsty btns1" @click="backPages()">下次继续</view>
  895. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  896. </view>
  897. <view class="classFootsty" v-if="cgType === 9">
  898. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  899. <view class="btnsty btns2" @click="submit">立即交卷</view>
  900. </view>
  901. </view>
  902. </u-popup>
  903. </view>
  904. </template>
  905. <script>
  906. export default {
  907. data() {
  908. return {
  909. showpopups: false,
  910. id: "",
  911. current: 0,
  912. questionList: [],
  913. ast: ["A", "B", "C", "D", "E", "F", "G"],
  914. judge: ["正确", "错误"],
  915. ans: [],
  916. ques: [],
  917. show: false,
  918. showDialog: false,
  919. bankList: [],
  920. collectList: [],
  921. goodsId: "",
  922. recordId: "",
  923. isSubmit: false,
  924. lastTime: 0, //剩余考试时长
  925. allTimes: 0, //总考试时长
  926. timer: null,
  927. wrongList: [],
  928. bankType: 0, //试卷类型
  929. needBack: false, //是否是考试
  930. testOver: false,
  931. isLastCount: false, //是否有未答题目
  932. lastCount: 0, //剩余没有回答的题目数
  933. chapterId: 0,
  934. moduleId: 0,
  935. showArrow: false, //退出提示
  936. isFromVideo: "",
  937. gradeId: "",
  938. examData: {},
  939. orderGoodsId: "",
  940. cgType: 0, //对应设计稿弹窗编码
  941. // courseId: '',
  942. entryType: "", // 进入做题页面的入口类型,daily-每日一练进来,random-随机练习, 其他的-题库做题进入
  943. bankNum: 5, // 随机练习的题目数量
  944. simulateExamId: undefined,
  945. };
  946. },
  947. async onLoad(option) {
  948. this.entryType = option.entryType || "";
  949. this.bankNum = option.bankNum;
  950. // this.courseId = option.courseId || ''
  951. this.orderGoodsId = option.orderGoodsId || 0;
  952. this.current = +option.current || 0;
  953. this.id = option.id;
  954. this.goodsId = option.goodsid;
  955. this.chapterId = option.chapterId || 0;
  956. this.moduleId = option.moduleId || 0;
  957. this.isFromVideo = option.isFromVideo || "";
  958. this.gradeId = option.gradeId || "";
  959. let isBack = option.isback;
  960. let showDialog = uni.getStorageSync("showDialog");
  961. if (showDialog) {
  962. this.showDialog = false;
  963. } else {
  964. this.showDialog = true;
  965. uni.setStorageSync("showDialog", "1");
  966. }
  967. //考试被迫返回
  968. if (isBack) {
  969. let app = getApp();
  970. let globalData = app.globalData;
  971. for (var k in globalData.bankData) {
  972. this[k] = globalData.bankData[k];
  973. }
  974. this.showArrow = true;
  975. this.timer = setInterval(() => {
  976. if (this.lastTime <= 0) {
  977. clearInterval(this.timer);
  978. uni.showToast({
  979. icon: "none",
  980. mask: true,
  981. title: "考试时间已到,系统将自动交卷",
  982. duration: 10000,
  983. });
  984. this.submit();
  985. return;
  986. }
  987. this.lastTime--;
  988. }, 1000);
  989. } else {
  990. if (this.entryType == "random") {
  991. this.bankType = 1; // 随机练习全部都是练习类型
  992. this.randomQuestionList();
  993. } else {
  994. //进入页面
  995. await this.bankExam();
  996. // 请求题目列表
  997. this.goodsQuestionList();
  998. }
  999. }
  1000. },
  1001. onUnload() {
  1002. if (this.isSubmit) {
  1003. clearInterval(this.timer);
  1004. return;
  1005. }
  1006. //考试试卷 阻止ios手势返回,自动跳回答题页
  1007. if (this.needBack) {
  1008. let app = getApp();
  1009. app.globalData.bankData = this.$data;
  1010. clearInterval(this.timer);
  1011. uni.navigateTo({
  1012. url:
  1013. "/pages2/bank/questionBank?id=" +
  1014. this.id +
  1015. "&goodsid=" +
  1016. this.goodsId +
  1017. "&isback=true&orderGoodsId=" +
  1018. this.orderGoodsId,
  1019. });
  1020. } else {
  1021. //点击返回按钮确认允许退出,记录答题记录
  1022. clearInterval(this.timer);
  1023. this.examRecordEdit();
  1024. }
  1025. },
  1026. methods: {
  1027. /**
  1028. * 是否有上传图片
  1029. */
  1030. hasImgs(bank) {
  1031. return bank.ansText.imageList.length == 0;
  1032. },
  1033. /**
  1034. * 获取试卷类型2考试,1练习
  1035. * bank/exam + data
  1036. */
  1037. bankExam() {
  1038. return new Promise((resolve) => {
  1039. this.$api.bankExam(this.id).then((res) => {
  1040. if (this.entryType == "daily") {
  1041. // 每日一练类型都是为练习
  1042. this.bankType = 1;
  1043. } else {
  1044. this.bankType = res.data.data.doType;
  1045. }
  1046. this.examData = res.data.data;
  1047. if (this.bankType == 2) {
  1048. this.needBack = true;
  1049. }
  1050. resolve();
  1051. });
  1052. });
  1053. },
  1054. /**
  1055. * 点击后退按钮
  1056. */
  1057. clickLeft() {
  1058. if (this.bankType == 1) {
  1059. let ansCount = this.questionOverNum(true); //已答题数
  1060. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1061. //所有题目答完
  1062. if (this.lastCount == 0) {
  1063. // this.testOver = true;
  1064. this.cgType = 7;
  1065. //未答完
  1066. } else {
  1067. this.cgType = 8;
  1068. // this.isLastCount = true;
  1069. }
  1070. this.showpopups = true;
  1071. } else if (this.bankType == 2) {
  1072. let ansCount = this.questionOverNum(true); //已答题数
  1073. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1074. //所有题目答完
  1075. if (this.lastCount == 0) {
  1076. this.testOver = true;
  1077. //未答完
  1078. } else {
  1079. this.isLastCount = true;
  1080. }
  1081. }
  1082. },
  1083. /**
  1084. * 返回上一页
  1085. */
  1086. backPages() {
  1087. this.needBack = false;
  1088. uni.navigateBack({
  1089. delta: 1,
  1090. });
  1091. },
  1092. /**
  1093. * 获取已经回答的题目数
  1094. * hasSpecail (是否包含简答和案例)
  1095. */
  1096. questionOverNum(hasSpecail) {
  1097. let count = 0;
  1098. this.questionList.forEach((item) => {
  1099. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1100. if (item.ques) {
  1101. count++;
  1102. }
  1103. } else if (item.type == 4) {
  1104. //案例题
  1105. if (hasSpecail) {
  1106. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1107. if (
  1108. jsonItem.type == 1 ||
  1109. jsonItem.type == 2 ||
  1110. jsonItem.type == 3
  1111. ) {
  1112. if (item.ques[indexs]) {
  1113. return true;
  1114. } else {
  1115. return false;
  1116. }
  1117. } else if (jsonItem.type == 5) {
  1118. if (
  1119. item.ques[indexs] &&
  1120. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  1121. ) {
  1122. console.log("chil");
  1123. return true;
  1124. } else {
  1125. return false;
  1126. }
  1127. }
  1128. });
  1129. if (isOver) {
  1130. count++;
  1131. }
  1132. }
  1133. } else if (item.type == 5) {
  1134. //简答题
  1135. if (hasSpecail) {
  1136. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  1137. console.log(5, item);
  1138. count++;
  1139. }
  1140. }
  1141. }
  1142. });
  1143. return count;
  1144. },
  1145. /**
  1146. * 是否做完所有题目
  1147. */
  1148. isDoOver() {
  1149. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1150. if (this.questionList.length == questionOverNum) {
  1151. //全部做完弹窗
  1152. this.cgType = 9;
  1153. this.showpopups = true;
  1154. }
  1155. },
  1156. /**
  1157. * 暂不交卷
  1158. */
  1159. noSubmit() {
  1160. //设为允许退出页面
  1161. this.needBack = false;
  1162. uni.navigateBack({
  1163. delta: 1,
  1164. });
  1165. },
  1166. /**
  1167. * 不离开
  1168. */
  1169. noLeave() {
  1170. this.isLastCount = false;
  1171. },
  1172. /**
  1173. * 立即离开并交卷
  1174. */
  1175. leaveNow() {
  1176. this.needBack = false;
  1177. this.isSubmit = true;
  1178. uni.navigateBack({
  1179. delta: 1,
  1180. });
  1181. let score = 0; //计算总分
  1182. let reportStatus = 0;
  1183. let number = 0; //做对的题目数量
  1184. let doQuestionNum = 0; //做过的题目数量
  1185. let allScore = 0; //总分
  1186. let passScore = 0;
  1187. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1188. let doQuestionIds = []; //做过的题目id
  1189. let lessQuestionNum = 0;
  1190. let rightQuestionIds = []; //做对的题目id
  1191. this.questionList.forEach((item, index) => {
  1192. // passScore = item.passScore
  1193. if (item.type == 1) {
  1194. //正确
  1195. if (item.ques == item.ans) {
  1196. item.scoreResult = item.score;
  1197. score += item.score;
  1198. number++;
  1199. rightQuestionIds.push(item.questionId);
  1200. } else {
  1201. //错误
  1202. item.scoreResult = 0;
  1203. if (item.ques) {
  1204. doWrongQuestionIds.push(item.questionId);
  1205. }
  1206. }
  1207. allScore += item.score;
  1208. if (item.ques) {
  1209. doQuestionNum++;
  1210. doQuestionIds.push(item.questionId);
  1211. }
  1212. } else if (item.type == 2) {
  1213. let isRight =
  1214. item.ans &&
  1215. item.ans.every((quesItem, quesIndex) => {
  1216. if (item.ques) {
  1217. return item.ques[quesIndex] == item.ans[quesIndex];
  1218. } else {
  1219. return false;
  1220. }
  1221. });
  1222. if (isRight) {
  1223. score += item.score;
  1224. number++;
  1225. item.scoreResult = item.score;
  1226. rightQuestionIds.push(item.questionId);
  1227. } else {
  1228. let hasPart = false;
  1229. let checkboxScore = 1; //获取单题总分数
  1230. item.ques &&
  1231. item.ques.forEach((ques, quesIndex) => {
  1232. //选错一个全扣
  1233. if (item.ques) {
  1234. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1235. checkboxScore = 0;
  1236. }
  1237. } else {
  1238. checkboxScore = 0;
  1239. }
  1240. });
  1241. console.log(checkboxScore);
  1242. //没选错
  1243. if (checkboxScore) {
  1244. checkboxScore = 0;
  1245. item.ans.forEach((ans, quesIndex) => {
  1246. //漏选只能得部分分数
  1247. if (item.ques) {
  1248. if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1249. checkboxScore = +item.partScore;
  1250. hasPart = true;
  1251. }
  1252. } else {
  1253. checkboxScore = 0;
  1254. }
  1255. });
  1256. }
  1257. if (!hasPart) {
  1258. //0分
  1259. item.scoreResult = 0;
  1260. if (item.ques) {
  1261. doWrongQuestionIds.push(item.questionId);
  1262. }
  1263. } else {
  1264. //部分分
  1265. // number++;
  1266. lessQuestionNum++;
  1267. // doWrongQuestionIds.push(item.questionId);
  1268. item.scoreResult = checkboxScore;
  1269. score += checkboxScore;
  1270. // rightQuestionIds.push(item.questionId)
  1271. }
  1272. }
  1273. allScore += item.score;
  1274. if (item.ques && item.ques.length) {
  1275. doQuestionNum++;
  1276. doQuestionIds.push(item.questionId);
  1277. }
  1278. } else if (item.type == 3) {
  1279. if (item.ques == item.ans) {
  1280. item.scoreResult = item.score;
  1281. score += item.score;
  1282. number++;
  1283. rightQuestionIds.push(item.questionId);
  1284. } else {
  1285. item.scoreResult = 0;
  1286. if (item.ques) {
  1287. doWrongQuestionIds.push(item.questionId);
  1288. }
  1289. }
  1290. allScore += item.score;
  1291. if (item.ques) {
  1292. doQuestionNum++;
  1293. doQuestionIds.push(item.questionId);
  1294. }
  1295. } else if (item.type == 4) {
  1296. allScore += item.score;
  1297. if (item.ques && item.ques.length) {
  1298. doQuestionNum++;
  1299. doQuestionIds.push(item.questionId);
  1300. }
  1301. } else if (item.type == 5) {
  1302. allScore += item.score;
  1303. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1304. doQuestionNum++;
  1305. doQuestionIds.push(item.questionId);
  1306. }
  1307. }
  1308. });
  1309. //大于60分及格
  1310. if (score >= 60) {
  1311. reportStatus = 1;
  1312. } else {
  1313. reportStatus = 0;
  1314. }
  1315. //交卷
  1316. this.$api
  1317. .examRecordEdit({
  1318. examId: this.id,
  1319. goodsId: this.goodsId,
  1320. orderGoodsId: this.orderGoodsId,
  1321. reportStatus: reportStatus,
  1322. recordId: this.recordId,
  1323. rightQuestionNum: number,
  1324. status: 1,
  1325. lessQuestionNum: lessQuestionNum,
  1326. moduleExamId: this.moduleId || 0,
  1327. chapterExamId: this.chapterId || 0,
  1328. doQuestionIds: doQuestionIds.join(","),
  1329. rightQuestionIds: rightQuestionIds.join(","),
  1330. doQuestionNum: doQuestionNum,
  1331. performance: score,
  1332. totalScore: allScore,
  1333. examTime: parseInt(this.allTimes),
  1334. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1335. historyExamJson: JSON.stringify(this.questionList),
  1336. })
  1337. .then((res) => {
  1338. this.isSubmit = true;
  1339. if (res.data.code == 200) {
  1340. this.entryType == "daily" && this.dailyExam();
  1341. }
  1342. });
  1343. //错题集id提交(客观题)
  1344. this.$api
  1345. .examWrongRecord({
  1346. orderGoodsId: this.orderGoodsId,
  1347. moduleExamId: this.moduleId || 0,
  1348. chapterExamId: this.chapterId || 0,
  1349. examId: this.id,
  1350. goodsId: this.goodsId,
  1351. questionIds: doWrongQuestionIds,
  1352. recordId: this.recordId,
  1353. type: 1, // 题库试卷传1
  1354. doMode: this.doMode,
  1355. })
  1356. .then((res) => {});
  1357. },
  1358. /**
  1359. * 立即交卷
  1360. */
  1361. submitNow() {
  1362. this.showpopups = false;
  1363. this.needBack = false;
  1364. this.submit();
  1365. },
  1366. /**
  1367. * 离开页面统计回答正确题数
  1368. */
  1369. examRecordEdit() {
  1370. if (!this.isSubmit) {
  1371. let number = 0;
  1372. let score = 0;
  1373. let doQuestionNum = 0;
  1374. let doQuestionIds = []; //做过的题目id
  1375. this.questionList.forEach((item, index) => {
  1376. if (item.type == 1) {
  1377. if (item.ques == item.ans) {
  1378. score += item.score;
  1379. number++;
  1380. }
  1381. if (item.ques) {
  1382. doQuestionNum++;
  1383. doQuestionIds.push(item.questionId);
  1384. }
  1385. } else if (item.type == 2) {
  1386. let isRight =
  1387. item.ans &&
  1388. item.ans.every((quesItem, quesIndex) => {
  1389. if (item.ques) {
  1390. return item.ques[quesIndex] == item.ans[quesIndex];
  1391. } else {
  1392. return false;
  1393. }
  1394. });
  1395. if (isRight) {
  1396. score += item.score;
  1397. number++;
  1398. } else {
  1399. let checkboxScore = 1; //获取单题总分数
  1400. item.ques &&
  1401. item.ques.forEach((ques, quesIndex) => {
  1402. //选错一个全扣
  1403. if (item.ques) {
  1404. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1405. checkboxScore = 0;
  1406. }
  1407. } else {
  1408. checkboxScore = 0;
  1409. }
  1410. });
  1411. console.log(checkboxScore);
  1412. //没选错
  1413. if (checkboxScore) {
  1414. checkboxScore = 0;
  1415. item.ans.forEach((ans, quesIndex) => {
  1416. //漏选扣一部分,对n题给n X partScore 分
  1417. if (item.ques) {
  1418. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  1419. checkboxScore += item.partScore;
  1420. }
  1421. } else {
  1422. checkboxScore = 0;
  1423. }
  1424. });
  1425. }
  1426. if (checkboxScore <= 0) {
  1427. //0分
  1428. } else {
  1429. //部分分
  1430. // number++;
  1431. score += checkboxScore;
  1432. }
  1433. }
  1434. if (item.ques && item.ques.length) {
  1435. doQuestionNum++;
  1436. doQuestionIds.push(item.questionId);
  1437. }
  1438. } else if (item.type == 3) {
  1439. if (item.ques == item.ans) {
  1440. score += item.score;
  1441. number++;
  1442. }
  1443. if (item.ques) {
  1444. doQuestionNum++;
  1445. doQuestionIds.push(item.questionId);
  1446. }
  1447. } else if (item == 4) {
  1448. if (item.ques.length) {
  1449. doQuestionNum++;
  1450. doQuestionIds.push(item.questionId);
  1451. }
  1452. } else if (item.type == 5) {
  1453. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1454. doQuestionNum++;
  1455. doQuestionIds.push(item.questionId);
  1456. }
  1457. }
  1458. });
  1459. this.$api
  1460. .examRecordEdit({
  1461. orderGoodsId: this.orderGoodsId,
  1462. examId: this.id,
  1463. goodsId: this.goodsId,
  1464. recordId: this.recordId,
  1465. doQuestionIds: doQuestionIds.join(","),
  1466. rightQuestionNum: number,
  1467. moduleExamId: this.moduleId || 0,
  1468. chapterExamId: this.chapterId || 0,
  1469. status: 0,
  1470. doQuestionNum: doQuestionNum,
  1471. historyExamJson: JSON.stringify(this.questionList),
  1472. })
  1473. .then((res) => {
  1474. if (res.data.code == 200) {
  1475. this.entryType == "daily" && this.dailyExam();
  1476. }
  1477. });
  1478. }
  1479. },
  1480. /**
  1481. * 记录总题数
  1482. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1483. */
  1484. examRecord(hasSpecial) {
  1485. let questionList = 0;
  1486. // if(!hasSpecial) {
  1487. this.questionList.forEach((item, index) => {
  1488. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1489. questionList++;
  1490. }
  1491. });
  1492. // } else {
  1493. // questionList = this.questionList.length;
  1494. // }
  1495. this.$api
  1496. .examRecord({
  1497. chapterExamId: this.chapterId || 0,
  1498. orderGoodsId: this.orderGoodsId,
  1499. moduleExamId: this.moduleId || 0,
  1500. examId: this.id,
  1501. goodsId: this.goodsId,
  1502. totalQuestionNum: questionList,
  1503. allQuestionNum: this.questionList.length,
  1504. doMode: this.doMode,
  1505. simulateExamId: this.simulateExamId,
  1506. })
  1507. .then((res) => {
  1508. this.recordId = res.data.data;
  1509. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1510. if (this.bankType == 1) {
  1511. this.examRecordEdit();
  1512. }
  1513. });
  1514. },
  1515. /**
  1516. * @param {Object} second倒计时过滤器
  1517. */
  1518. countdown(second) {
  1519. if (second) {
  1520. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1521. let m = parseInt((second / 60) % 60); // 计算分数
  1522. let s = parseInt(second % 60); // 计算当前秒数
  1523. if (h < 10) h = "0" + h;
  1524. if (m < 10) m = "0" + m;
  1525. if (s < 10) s = "0" + s;
  1526. return h + ":" + m + ":" + s;
  1527. } else {
  1528. return "";
  1529. }
  1530. },
  1531. hideDialog() {
  1532. this.showDialog = false;
  1533. },
  1534. // 请求随机练习题目列表
  1535. randomQuestionList() {
  1536. this.$http({
  1537. url: "/bank/exam/temp",
  1538. method: "post",
  1539. data: {
  1540. goodsId: this.goodsId,
  1541. orderGoodsId: this.orderGoodsId,
  1542. number: this.bankNum,
  1543. },
  1544. }).then((res) => {
  1545. if (res.data.code == 200) {
  1546. this.examData = res.data.data || {};
  1547. this.id = this.examData.examId;
  1548. if (!this.examData.questionList.length) {
  1549. this.hideDialog();
  1550. uni.showModal({
  1551. showCancel: false,
  1552. content: "该试卷暂无题目",
  1553. success: (k) => {
  1554. if (k.confirm) {
  1555. this.isSubmit = true;
  1556. uni.navigateBack();
  1557. }
  1558. },
  1559. });
  1560. return;
  1561. }
  1562. this.dataAnlyze(this.examData.questionList || []);
  1563. } else {
  1564. this.$u.toast(res.data.msg);
  1565. setTimeout(() => {
  1566. uni.navigateBack();
  1567. }, 2000);
  1568. }
  1569. });
  1570. },
  1571. /**
  1572. * 请求题目列表 app/common/bank/question/list
  1573. */
  1574. goodsQuestionList() {
  1575. this.$api[
  1576. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1577. ]({
  1578. examId: this.id,
  1579. goodsId: this.goodsId,
  1580. orderGoodsId: this.orderGoodsId,
  1581. from: 1,
  1582. }).then((res) => {
  1583. let data = res.data.data;
  1584. if (this.doMode == 3) {
  1585. this.simulateExamId = data.simulateExamId;
  1586. data = data.questionList;
  1587. }
  1588. if (!data.length) {
  1589. this.hideDialog();
  1590. uni.showModal({
  1591. showCancel: false,
  1592. content: this.simulateExamId ? "您已经毕业了" : "该试卷暂无题目",
  1593. success: (k) => {
  1594. if (k.confirm) {
  1595. this.isSubmit = true;
  1596. uni.navigateBack();
  1597. }
  1598. },
  1599. });
  1600. return;
  1601. }
  1602. this.allTimes = data[0].answerTime * 60;
  1603. this.lastTime = data[0].answerTime && data[0].answerTime * 60;
  1604. //考试时间到了自动交卷
  1605. if (this.lastTime) {
  1606. this.timer = setInterval(() => {
  1607. if (this.lastTime <= 0) {
  1608. clearInterval(this.timer);
  1609. uni.showToast({
  1610. icon: "none",
  1611. mask: true,
  1612. title: "考试时间已到,系统将自动交卷",
  1613. duration: 10000,
  1614. });
  1615. this.submit();
  1616. return;
  1617. }
  1618. this.lastTime--;
  1619. }, 1000);
  1620. } else {
  1621. }
  1622. this.dataAnlyze(data);
  1623. });
  1624. },
  1625. dataAnlyze(datas = []) {
  1626. console.log("datas:", datas);
  1627. datas.forEach((item, index) => {
  1628. // if (typeof item.jsonStr == 'string') {
  1629. item.jsonStr = JSON.parse(item.jsonStr);
  1630. if (item.type == 2) {
  1631. //多选
  1632. item.jsonStr.forEach((str) => {
  1633. str.optionsId = "" + str.optionsId;
  1634. });
  1635. let arr = item.answerQuestion.split(",");
  1636. arr.forEach((a, i) => {
  1637. arr[i] = "" + a;
  1638. });
  1639. item.ans = arr;
  1640. item.analysisContent &&
  1641. (item.analysisContent = item.analysisContent.replace(
  1642. /<img/gi,
  1643. '<img style="max-width:100%;"'
  1644. ));
  1645. item.content &&
  1646. (item.content = item.content.replace(
  1647. /<img/gi,
  1648. '<img style="max-width:100%;"'
  1649. ));
  1650. return;
  1651. } else if (item.type == 5) {
  1652. //简答题
  1653. item.ansText = {
  1654. text: "",
  1655. imageList: [],
  1656. };
  1657. item.ques = {
  1658. text: "",
  1659. imageList: [],
  1660. };
  1661. item.analysisContent &&
  1662. (item.analysisContent = item.analysisContent.replace(
  1663. /<img/gi,
  1664. '<img style="max-width:100%;"'
  1665. ));
  1666. item.content &&
  1667. (item.content = item.content.replace(
  1668. /<img/gi,
  1669. '<img style="max-width:100%;"'
  1670. ));
  1671. } else if (item.type == 4) {
  1672. //案例题
  1673. item.ques = [];
  1674. item.current = 0;
  1675. let ansArr = [];
  1676. item.jsonStr.forEach((json, index) => {
  1677. if (json.type == 1) {
  1678. ansArr[index] = json.answerQuestion;
  1679. json.content &&
  1680. (json.content = json.content.replace(
  1681. /<img/gi,
  1682. '<img style="max-width:100%;"'
  1683. ));
  1684. } else if (json.type == 2) {
  1685. json.optionsList.forEach((str) => {
  1686. str.optionsId = "" + str.optionsId;
  1687. });
  1688. let arr = json.answerQuestion.split(",");
  1689. arr.forEach((a, i) => {
  1690. arr[i] = "" + a;
  1691. });
  1692. ansArr[index] = arr;
  1693. json.content &&
  1694. (json.content = json.content.replace(
  1695. /<img/gi,
  1696. '<img style="max-width:100%;"'
  1697. ));
  1698. } else if (json.type == 3) {
  1699. ansArr[index] = json.answerQuestion;
  1700. json.content &&
  1701. (json.content = json.content.replace(
  1702. /<img/gi,
  1703. '<img style="max-width:100%;"'
  1704. ));
  1705. } else if (json.type == 5) {
  1706. ansArr[index] = {
  1707. text: json.answerQuestion,
  1708. imageList: [],
  1709. };
  1710. json.ansText = {
  1711. text: "",
  1712. imageList: [],
  1713. };
  1714. json.content &&
  1715. (json.content = json.content.replace(
  1716. /<img/gi,
  1717. '<img style="max-width:100%;"'
  1718. ));
  1719. }
  1720. });
  1721. item.analysisContent &&
  1722. (item.analysisContent = item.analysisContent.replace(
  1723. /<img/gi,
  1724. '<img style="max-width:100%;"'
  1725. ));
  1726. item.content &&
  1727. (item.content = item.content.replace(
  1728. /<img/gi,
  1729. '<img style="max-width:100%;"'
  1730. ));
  1731. item.ans = ansArr;
  1732. return;
  1733. }
  1734. item.analysisContent &&
  1735. (item.analysisContent = item.analysisContent.replace(
  1736. /<img/gi,
  1737. '<img style="max-width:100%;"'
  1738. ));
  1739. item.content &&
  1740. (item.content = item.content.replace(
  1741. /<img/gi,
  1742. '<img style="max-width:100%;"'
  1743. ));
  1744. item.ans = item.answerQuestion;
  1745. // }
  1746. });
  1747. this.questionList = datas;
  1748. this.lastCount = this.questionList.length;
  1749. this.examRecord();
  1750. this.getCollectInfo(this.current);
  1751. },
  1752. /**
  1753. * @param {Object} e单选点击
  1754. */
  1755. radioSelect(optionsId, bindex) {
  1756. // if (this.questionList[bindex].ques) return;
  1757. if (this.questionList[bindex].ques && this.bankType == 1) {
  1758. return;
  1759. }
  1760. this.$set(this.questionList[bindex], "ques", optionsId);
  1761. // if ((bindex + 1) < this.questionList.length) {
  1762. // this.current = bindex + 1
  1763. // }
  1764. this.isDoOver();
  1765. // 回答错误
  1766. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1767. // // /exam/wwrong/record
  1768. // this.$api
  1769. // .examWrongRecord({
  1770. // orderGoodsId: this.orderGoodsId,
  1771. // examId: this.id,
  1772. // goodsId: this.goodsId,
  1773. // moduleExamId: this.moduleId || 0,
  1774. // chapterExamId: this.chapterId || 0,
  1775. // questionIds: [this.questionList[bindex].questionId],
  1776. // recordId: this.recordId,
  1777. // })
  1778. // .then((res) => {});
  1779. // } else {
  1780. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1781. // // if(question) {
  1782. // // this.$api.wrongRecordDelete({
  1783. // // "examId": +this.id,
  1784. // // "goodsId": +this.goodsId,
  1785. // // "questionId": this.questionList[bindex].questionId,
  1786. // // }).then(res => {
  1787. // // })
  1788. // // }
  1789. // }
  1790. },
  1791. /**
  1792. * @param {Object} e案例单选点击
  1793. */
  1794. radioSelectChild(optionsId, ansIndex, bindex) {
  1795. // if (this.questionList[bindex].ques[ansIndex]) return;
  1796. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1797. return;
  1798. }
  1799. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1800. this.isDoOver();
  1801. },
  1802. /**
  1803. * @param {Object} 多选点击
  1804. */
  1805. checkboxSelect(optionsId, bindex, index) {
  1806. if (this.questionList[bindex].ques && this.bankType == 1) {
  1807. return;
  1808. }
  1809. this.$set(
  1810. this.questionList[bindex].jsonStr[index],
  1811. "checked",
  1812. !this.questionList[bindex].jsonStr[index].checked
  1813. );
  1814. },
  1815. /**
  1816. * @param {Object} 案例多选点击
  1817. */
  1818. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1819. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1820. return;
  1821. }
  1822. this.$set(
  1823. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1824. "checked",
  1825. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1826. .checked
  1827. );
  1828. },
  1829. isCheckboxChecked(arr) {
  1830. return arr.some((item) => {
  1831. if (item.checked) {
  1832. return true;
  1833. }
  1834. });
  1835. },
  1836. /**
  1837. * @param {Object} 多选确认
  1838. */
  1839. checkboxSubmit(bindex) {
  1840. // console.log('')
  1841. // if (this.questionList[bindex].ques) return;
  1842. if (this.questionList[bindex].ques && this.bankType == 1) {
  1843. return;
  1844. }
  1845. let arr = [];
  1846. this.questionList[bindex].jsonStr.forEach((item) => {
  1847. if (item.checked) {
  1848. arr.push(item.optionsId);
  1849. }
  1850. });
  1851. if (!arr.length) {
  1852. delete this.questionList[bindex].ques;
  1853. uni.showToast({
  1854. title: "请选择答案",
  1855. icon: "none",
  1856. });
  1857. return;
  1858. }
  1859. this.$set(this.questionList[bindex], "ques", arr);
  1860. this.$u.toast("已确认答案");
  1861. this.isDoOver();
  1862. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1863. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1864. // })
  1865. // // 回答错误
  1866. // if (isWrong) {
  1867. // this.$api
  1868. // .examWrongRecord({
  1869. // orderGoodsId: this.orderGoodsId,
  1870. // examId: this.id,
  1871. // goodsId: this.goodsId,
  1872. // moduleExamId: this.moduleId || 0,
  1873. // chapterExamId: this.chapterId || 0,
  1874. // questionIds: [this.questionList[bindex].questionId],
  1875. // recordId: this.recordId,
  1876. // })
  1877. // .then((res) => {});
  1878. // } else {
  1879. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1880. // // if(question) {
  1881. // // this.$api.wrongRecordDelete({
  1882. // // "examId": +this.id,
  1883. // // "goodsId": +this.goodsId,
  1884. // // "questionId": this.questionList[bindex].questionId,
  1885. // // }).then(res => {
  1886. // // })
  1887. // // }
  1888. // }
  1889. },
  1890. /**
  1891. * @param {Object} 案例多选确认
  1892. */
  1893. checkboxSubmitChild(bindex, ansIndex) {
  1894. // if (this.questionList[bindex].ques[ansIndex]) return;
  1895. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1896. return;
  1897. }
  1898. let arr = [];
  1899. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1900. (item) => {
  1901. if (item.checked) {
  1902. arr.push(item.optionsId);
  1903. }
  1904. }
  1905. );
  1906. if (!arr.length) {
  1907. delete this.questionList[bindex].ques[ansIndex];
  1908. uni.showToast({
  1909. title: "请选择答案",
  1910. icon: "none",
  1911. });
  1912. return;
  1913. }
  1914. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1915. this.$u.toast("已确认答案");
  1916. this.isDoOver();
  1917. },
  1918. /**
  1919. * @param {Object} index
  1920. * @param {Object} bindex
  1921. * 判断题
  1922. */
  1923. judgeSelect(index, bindex) {
  1924. // if (this.questionList[bindex].ques) return;
  1925. if (this.questionList[bindex].ques && this.bankType == 1) {
  1926. return;
  1927. } // 答案: 判断题1正确 0错误
  1928. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  1929. console.log(
  1930. "this.questionList[bindex]:",
  1931. this.questionList[bindex].ques,
  1932. this.questionList[bindex].ans
  1933. );
  1934. this.isDoOver();
  1935. // 回答错误
  1936. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1937. // this.$api
  1938. // .examWrongRecord({
  1939. // orderGoodsId: this.orderGoodsId,
  1940. // examId: this.id,
  1941. // goodsId: this.goodsId,
  1942. // moduleExamId: this.moduleId || 0,
  1943. // chapterExamId: this.chapterId || 0,
  1944. // questionIds: [this.questionList[bindex].questionId],
  1945. // recordId: this.recordId,
  1946. // })
  1947. // .then((res) => {});
  1948. // } else {
  1949. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1950. // // if(question) {
  1951. // // this.$api.wrongRecordDelete({
  1952. // // "examId": +this.id,
  1953. // // "goodsId": +this.goodsId,
  1954. // // "questionId": this.questionList[bindex].questionId,
  1955. // // }).then(res => {
  1956. // // })
  1957. // // }
  1958. // }
  1959. },
  1960. /**
  1961. * @param {Object} ansindex
  1962. * @param {Object} childindex
  1963. * @param {Object} bindex
  1964. * 案例判断题
  1965. */
  1966. judgeSelectChild(ansindex, childindex, bindex) {
  1967. // if (this.questionList[bindex].ques[ansindex]) return;
  1968. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  1969. return;
  1970. }
  1971. this.$set(
  1972. this.questionList[bindex].ques,
  1973. ansindex,
  1974. childindex == 0 ? "1" : "0"
  1975. );
  1976. this.isDoOver();
  1977. },
  1978. openFooterTab() {
  1979. this.show = true;
  1980. },
  1981. changeIndex(index) {
  1982. this.current = index;
  1983. },
  1984. swiperChange(e) {
  1985. this.current = e.detail.current;
  1986. this.getCollectInfo(this.current);
  1987. },
  1988. /**
  1989. * @param {Object} current
  1990. * 获取收藏信息
  1991. */
  1992. getCollectInfo(current) {
  1993. this.$api
  1994. .getCollectInfo({
  1995. examId: this.id,
  1996. questionId: this.questionList[current].questionId,
  1997. goodsId: this.goodsId,
  1998. orderGoodsId: this.orderGoodsId,
  1999. })
  2000. .then((res) => {
  2001. if (res.data.code == 500) {
  2002. this.$set(this.collectList, current, false);
  2003. } else if (res.data.code == 200) {
  2004. this.$set(this.collectList, current, res.data.data);
  2005. }
  2006. });
  2007. },
  2008. pdsubmit() {
  2009. // if (this.bankType == 1) {
  2010. let ansCount = this.questionOverNum(true); //已答题数
  2011. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2012. //没有答完
  2013. if (this.lastCount !== 0) {
  2014. this.cgType = 6;
  2015. this.showpopups = true;
  2016. return;
  2017. }
  2018. // }
  2019. if (this.bankType == 2) {
  2020. if (this.lastTime > 0) {
  2021. let lastTime = this.countdown(this.lastTime);
  2022. uni.showModal({
  2023. title: "提示",
  2024. content: `时间还剩余${lastTime},确定交卷吗?`,
  2025. confirmText: "交卷",
  2026. cancelText: "继续答题",
  2027. success: (res) => {
  2028. if (res.confirm) {
  2029. //确定
  2030. this.submit();
  2031. } else {
  2032. //取消
  2033. }
  2034. },
  2035. });
  2036. return;
  2037. }
  2038. }
  2039. this.submit();
  2040. },
  2041. /**
  2042. * 交卷
  2043. */
  2044. submit() {
  2045. let score = 0; //计算总分
  2046. let reportStatus = 0;
  2047. let number = 0; //做对的题目数量
  2048. let doQuestionNum = 0; //做过的题目数量
  2049. let allScore = 0; //总分
  2050. let passScore = 0;
  2051. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2052. let doQuestionIds = []; //做过的题目id
  2053. let lessQuestionNum = 0;
  2054. let rightQuestionIds = []; //做对的题目id
  2055. this.questionList.forEach((item, index) => {
  2056. passScore = item.passScore;
  2057. if (item.type == 1) {
  2058. //正确
  2059. if (item.ques == item.ans) {
  2060. item.scoreResult = item.score;
  2061. score += item.score;
  2062. number++;
  2063. rightQuestionIds.push(item.questionId);
  2064. } else {
  2065. //错误
  2066. item.scoreResult = 0;
  2067. if (item.ques) {
  2068. doWrongQuestionIds.push(item.questionId);
  2069. }
  2070. }
  2071. allScore += item.score;
  2072. if (item.ques) {
  2073. doQuestionNum++;
  2074. doQuestionIds.push(item.questionId);
  2075. }
  2076. } else if (item.type == 2) {
  2077. let isRight =
  2078. item.ans &&
  2079. item.ans.every((quesItem, quesIndex) => {
  2080. if (item.ques) {
  2081. return item.ques[quesIndex] == item.ans[quesIndex];
  2082. } else {
  2083. return false;
  2084. }
  2085. });
  2086. if (isRight) {
  2087. score += item.score;
  2088. number++;
  2089. item.scoreResult = item.score;
  2090. rightQuestionIds.push(item.questionId);
  2091. } else {
  2092. let hasPart = false;
  2093. let checkboxScore = 1; //获取单题总分数
  2094. item.ques &&
  2095. item.ques.forEach((ques, quesIndex) => {
  2096. //选错一个全扣
  2097. if (item.ques) {
  2098. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2099. checkboxScore = 0;
  2100. }
  2101. } else {
  2102. checkboxScore = 0;
  2103. }
  2104. });
  2105. //没选错
  2106. if (checkboxScore) {
  2107. checkboxScore = 0;
  2108. item.ans.forEach((ans, quesIndex) => {
  2109. //漏选扣一部分,对n题给n X partScore 分
  2110. if (item.ques) {
  2111. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2112. checkboxScore += item.partScore;
  2113. hasPart = true;
  2114. }
  2115. } else {
  2116. checkboxScore = 0;
  2117. }
  2118. });
  2119. }
  2120. if (!hasPart) {
  2121. //0分
  2122. item.scoreResult = 0;
  2123. if (item.ques) {
  2124. doWrongQuestionIds.push(item.questionId);
  2125. }
  2126. } else {
  2127. //部分分
  2128. // number++;
  2129. lessQuestionNum++;
  2130. // doWrongQuestionIds.push(item.questionId);
  2131. item.scoreResult = checkboxScore;
  2132. score += checkboxScore;
  2133. // rightQuestionIds.push(item.questionId)
  2134. }
  2135. }
  2136. allScore += item.score;
  2137. if (item.ques && item.ques.length) {
  2138. doQuestionNum++;
  2139. doQuestionIds.push(item.questionId);
  2140. }
  2141. } else if (item.type == 3) {
  2142. if (item.ques == item.ans) {
  2143. item.scoreResult = item.score;
  2144. score += item.score;
  2145. number++;
  2146. rightQuestionIds.push(item.questionId);
  2147. } else {
  2148. item.scoreResult = 0;
  2149. if (item.ques) {
  2150. doWrongQuestionIds.push(item.questionId);
  2151. }
  2152. }
  2153. allScore += item.score;
  2154. if (item.ques) {
  2155. doQuestionNum++;
  2156. doQuestionIds.push(item.questionId);
  2157. }
  2158. } else if (item.type == 4) {
  2159. allScore += item.score;
  2160. if (item.ques && item.ques.length) {
  2161. doQuestionNum++;
  2162. doQuestionIds.push(item.questionId);
  2163. }
  2164. } else if (item.type == 5) {
  2165. allScore += item.score;
  2166. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2167. doQuestionNum++;
  2168. doQuestionIds.push(item.questionId);
  2169. }
  2170. }
  2171. });
  2172. //大于及格
  2173. if (score >= passScore) {
  2174. reportStatus = 1;
  2175. } else {
  2176. reportStatus = 0;
  2177. }
  2178. //交卷
  2179. this.$api
  2180. .examRecordEdit({
  2181. // courseId: this.courseId,
  2182. examId: this.id,
  2183. goodsId: this.goodsId,
  2184. reportStatus: reportStatus,
  2185. recordId: this.recordId,
  2186. rightQuestionNum: number,
  2187. orderGoodsId: this.orderGoodsId,
  2188. status: 1,
  2189. lessQuestionNum: lessQuestionNum,
  2190. moduleExamId: this.moduleId || 0,
  2191. chapterExamId: this.chapterId || 0,
  2192. doQuestionIds: doQuestionIds.join(","),
  2193. rightQuestionIds: rightQuestionIds.join(","),
  2194. doQuestionNum: doQuestionNum,
  2195. performance: score,
  2196. totalScore: allScore,
  2197. examTime: parseInt(this.allTimes),
  2198. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2199. historyExamJson: JSON.stringify(this.questionList),
  2200. // type: ''
  2201. })
  2202. .then((res) => {
  2203. this.isSubmit = true;
  2204. if (res.data.code == 200) {
  2205. this.entryType == "daily" && this.dailyExam();
  2206. uni.showToast({
  2207. title: "交卷成功",
  2208. duration: 1000,
  2209. icon: "none",
  2210. });
  2211. setTimeout(() => {
  2212. uni.redirectTo({
  2213. url:
  2214. "/pages2/bank/question_report?goodsId=" +
  2215. this.goodsId +
  2216. "&chapterId=" +
  2217. this.chapterId +
  2218. "&moduleId=" +
  2219. this.moduleId +
  2220. "&examId=" +
  2221. this.id +
  2222. "&id=" +
  2223. this.recordId +
  2224. "&orderGoodsId=" +
  2225. this.orderGoodsId +
  2226. "&entryType=" +
  2227. this.entryType +
  2228. "&bankNum=" +
  2229. this.bankNum +
  2230. "&doMode=" +
  2231. this.doMode +
  2232. "&courseType=1",
  2233. });
  2234. }, 1000);
  2235. }
  2236. });
  2237. //错题集id提交(客观题)
  2238. this.$api
  2239. .examWrongRecord({
  2240. examId: this.id,
  2241. goodsId: this.goodsId,
  2242. orderGoodsId: this.orderGoodsId,
  2243. questionIds: doWrongQuestionIds,
  2244. recordId: this.recordId,
  2245. type: 1, // 题库试卷传1
  2246. doMode: this.doMode,
  2247. })
  2248. .then((res) => {});
  2249. },
  2250. // 每日一练试卷打卡
  2251. dailyExam() {
  2252. const dateStamp = parseInt(
  2253. new Date(new Date().toLocaleDateString()).getTime() / 1000
  2254. );
  2255. this.$http({
  2256. url: "/bank/question/special/exam/record",
  2257. method: "post",
  2258. data: {
  2259. examId: this.id,
  2260. chapterExamId: this.chapterId, // 章卷ID
  2261. moduleExamId: this.moduleId, //模块卷ID
  2262. goodsId: this.goodsId,
  2263. recordTime: dateStamp, // 传当天0点时间戳(秒)
  2264. },
  2265. }).then((res) => {
  2266. if (res.data.code == 200) {
  2267. }
  2268. });
  2269. },
  2270. /**
  2271. * @param {Object} state
  2272. * @param {Object} index
  2273. * 收藏
  2274. */
  2275. collect(state, index) {
  2276. if (!state) {
  2277. this.$api
  2278. .collectQuestion({
  2279. examId: this.id,
  2280. questionId: this.questionList[index].questionId,
  2281. goodsId: this.goodsId || "",
  2282. orderGoodsId: this.orderGoodsId,
  2283. doMode: this.doMode,
  2284. })
  2285. .then((res) => {
  2286. if (res.data.code == 200) {
  2287. this.$set(this.collectList, index, true);
  2288. uni.showToast({
  2289. title: "收藏成功",
  2290. duration: 2000,
  2291. icon: "none",
  2292. });
  2293. this.getCollectInfo(index);
  2294. }
  2295. });
  2296. } else {
  2297. this.$api
  2298. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2299. .then((res) => {
  2300. if (res.data.code == 200) {
  2301. this.$set(this.collectList, index, false);
  2302. uni.showToast({
  2303. title: "取消收藏成功",
  2304. duration: 2000,
  2305. icon: "none",
  2306. });
  2307. }
  2308. });
  2309. }
  2310. return;
  2311. },
  2312. /**
  2313. * @param {Object} imgIndex
  2314. * @param {Object} bankIndex
  2315. * 删除简答图片
  2316. */
  2317. deleteImg(imgIndex, bankIndex) {
  2318. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2319. },
  2320. /**
  2321. * @param {Object} imgIndex
  2322. * @param {Object} bankIndex
  2323. * @param {Object} ansIndex
  2324. * 删除案例题简答图片
  2325. */
  2326. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2327. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2328. imgIndex,
  2329. 1
  2330. );
  2331. },
  2332. /**
  2333. * @param {Object} bankindex
  2334. * 选择上传图片
  2335. */
  2336. chooseImg(bankindex) {
  2337. if (
  2338. this.questionList[bankindex] &&
  2339. this.questionList[bankindex].ansText &&
  2340. this.questionList[bankindex].ansText.imageList.length >= 4
  2341. ) {
  2342. uni.showToast({
  2343. icon: "none",
  2344. title: "最多选择4张",
  2345. });
  2346. return;
  2347. }
  2348. uni.chooseImage({
  2349. count: 1, //默认9
  2350. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2351. sourceType: ["album", "camera"], //从相册选择
  2352. success: (res) => {
  2353. let self = this;
  2354. // console.log(JSON.stringify(res.tempFilePaths));
  2355. let img = res.tempFilePaths[0];
  2356. uni.getImageInfo({
  2357. src: img,
  2358. success: async (res) => {
  2359. let canvasWidth = res.width; //图片原始长宽
  2360. let canvasHeight = res.height;
  2361. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2362. uni.compressImage({
  2363. src: img,
  2364. quality: 75,
  2365. width: "50%",
  2366. height: "50%",
  2367. success: async (rest) => {
  2368. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2369. this.questionList[bankindex].ansText.imageList.push(dir);
  2370. },
  2371. });
  2372. } else {
  2373. const dir = await self.uploadFile(img, 0);
  2374. this.questionList[bankindex].ansText.imageList.push(dir);
  2375. }
  2376. },
  2377. });
  2378. },
  2379. });
  2380. },
  2381. /**
  2382. * @param {Object} bankindex
  2383. * @param {Object} ansindex
  2384. * 案例题选择上传图片
  2385. */
  2386. chooseImgChild(bankindex, ansindex) {
  2387. if (
  2388. this.questionList[bankindex].jsonStr[ansindex] &&
  2389. this.questionList[bankindex].jsonStr[ansindex].ansText &&
  2390. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
  2391. .length >= 4
  2392. ) {
  2393. uni.showToast({
  2394. icon: "none",
  2395. title: "最多选择4张",
  2396. });
  2397. return;
  2398. }
  2399. uni.chooseImage({
  2400. count: 1, //默认9
  2401. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2402. sourceType: ["album", "camera"], //从相册选择
  2403. success: (res) => {
  2404. let self = this;
  2405. // console.log(JSON.stringify(res.tempFilePaths));
  2406. let img = res.tempFilePaths[0];
  2407. uni.getImageInfo({
  2408. src: img,
  2409. success: async (res) => {
  2410. let canvasWidth = res.width; //图片原始长宽
  2411. let canvasHeight = res.height;
  2412. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2413. uni.compressImage({
  2414. src: img,
  2415. quality: 75,
  2416. width: "50%",
  2417. height: "50%",
  2418. success: async (rest) => {
  2419. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2420. this.questionList[bankindex].jsonStr[
  2421. ansindex
  2422. ].ansText.imageList.push(dir);
  2423. },
  2424. });
  2425. } else {
  2426. const dir = await self.uploadFile(img, 0);
  2427. this.questionList[bankindex].jsonStr[
  2428. ansindex
  2429. ].ansText.imageList.push(dir);
  2430. }
  2431. },
  2432. });
  2433. },
  2434. });
  2435. },
  2436. uploadFile(options, int) {
  2437. var self = this;
  2438. return new Promise((resolve, reject) => {
  2439. var data = {
  2440. orderGoodsId: this.orderGoodsId,
  2441. imageStatus: int,
  2442. };
  2443. self.$api.aliyunpolicy(data).then((res) => {
  2444. console.log(res.data, 6);
  2445. if (res.data.code != 200) {
  2446. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  2447. return;
  2448. }
  2449. var ossToken = res.data.data.resultContent;
  2450. if (ossToken.host == null || ossToken.host == undefined) {
  2451. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  2452. return;
  2453. }
  2454. uni.uploadFile({
  2455. url: ossToken.host,
  2456. name: "file",
  2457. filePath: options,
  2458. fileType: "image",
  2459. header: {
  2460. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  2461. },
  2462. formData: {
  2463. key: ossToken.dir,
  2464. OSSAccessKeyId: ossToken.accessid,
  2465. policy: ossToken.policy,
  2466. Signature: ossToken.signature,
  2467. callback: ossToken.callback,
  2468. success_action_status: 200,
  2469. },
  2470. success: (result) => {
  2471. // if (result.statusCode === 200) {
  2472. resolve(ossToken.dir);
  2473. // } else {
  2474. // uni.showToast({
  2475. // title: "上传失败",
  2476. // icon: "none",
  2477. // });
  2478. // return;
  2479. // }
  2480. },
  2481. fail: (error) => {
  2482. uni.showToast({
  2483. title: "上传接口报错" + error,
  2484. icon: "none",
  2485. });
  2486. return;
  2487. },
  2488. });
  2489. });
  2490. });
  2491. },
  2492. /**
  2493. * @param {Object} type
  2494. * @param {Object} bankindex
  2495. * 简答题答案确认
  2496. */
  2497. submitAns(bankindex) {
  2498. if (
  2499. !this.questionList[bankindex].ansText.text &&
  2500. !this.questionList[bankindex].ansText.imageList.length
  2501. ) {
  2502. uni.showToast({
  2503. title: "请输入内容或上传图片",
  2504. duration: 2000,
  2505. icon: "none",
  2506. });
  2507. return;
  2508. }
  2509. this.$set(this.questionList[bankindex], "ques", {
  2510. imageList: this.questionList[bankindex].ansText.imageList || [],
  2511. text: this.questionList[bankindex].ansText.text || "",
  2512. });
  2513. this.$u.toast("已确认答案");
  2514. this.isDoOver();
  2515. },
  2516. /**
  2517. * @param {Object} bankindex
  2518. * @param {Object} ansindex
  2519. * 案例题简答答案确认
  2520. */
  2521. submitAnsChild(bankindex, ansindex) {
  2522. if (
  2523. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2524. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2525. ) {
  2526. uni.showToast({
  2527. title: "请输入内容或上传图片",
  2528. duration: 2000,
  2529. icon: "none",
  2530. });
  2531. return;
  2532. }
  2533. this.$set(this.questionList[bankindex].ques, ansindex, {
  2534. imageList:
  2535. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
  2536. [],
  2537. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
  2538. });
  2539. this.$u.toast("已确认答案");
  2540. this.isDoOver();
  2541. },
  2542. isCheck(item, index) {
  2543. if (this.questionList[index].ques) {
  2544. return true;
  2545. }
  2546. },
  2547. isRight(item, index) {
  2548. //单选
  2549. if (this.questionList[index].ques) {
  2550. if (item.type == 1) {
  2551. return this.questionList[index].ques == this.questionList[index].ans;
  2552. //多选
  2553. } else if (item.type == 2) {
  2554. //每一项都相等
  2555. return this.questionList[index].ans.every((item, i) => {
  2556. return item == this.questionList[index].ques[i];
  2557. });
  2558. //判断
  2559. } else if (item.type == 3) {
  2560. return this.questionList[index].ques == this.questionList[index].ans;
  2561. // } else if (item.type == 5) {
  2562. // if(this.questionList[index].ques.text){
  2563. // return true
  2564. // }else{
  2565. // return false
  2566. // }
  2567. } else {
  2568. return false;
  2569. }
  2570. } else {
  2571. return false;
  2572. }
  2573. },
  2574. right(bankIndex, ansIndex, option) {
  2575. if (
  2576. this.questionList[bankIndex].ques[ansIndex] &&
  2577. this.questionList[bankIndex].ans[ansIndex]
  2578. ) {
  2579. if (
  2580. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2581. option.optionsId
  2582. ) != -1 ||
  2583. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2584. option.optionsId
  2585. ) != -1
  2586. ) {
  2587. return true;
  2588. } else {
  2589. return false;
  2590. }
  2591. } else {
  2592. return false;
  2593. }
  2594. },
  2595. wrong(bankIndex, ansIndex, option) {
  2596. if (
  2597. this.questionList[bankIndex].ques[ansIndex] &&
  2598. this.questionList[bankIndex].ans[ansIndex]
  2599. ) {
  2600. if (
  2601. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2602. option.optionsId
  2603. ) != -1 &&
  2604. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2605. option.optionsId
  2606. ) == -1
  2607. ) {
  2608. return true;
  2609. } else {
  2610. return false;
  2611. }
  2612. } else {
  2613. return false;
  2614. }
  2615. },
  2616. isWrong(item, index) {
  2617. if (this.questionList[index].ques) {
  2618. //单选
  2619. if (item.type == 1) {
  2620. return this.questionList[index].ques != this.questionList[index].ans;
  2621. //多选
  2622. } else if (item.type == 2) {
  2623. //每一项都相等
  2624. return this.questionList[index].ques.some((item, i) => {
  2625. return this.questionList[index].ans.indexOf(item) == -1;
  2626. });
  2627. //判断
  2628. } else if (item.type == 3) {
  2629. return this.questionList[index].ques != this.questionList[index].ans;
  2630. } else {
  2631. return false;
  2632. }
  2633. } else {
  2634. return false;
  2635. }
  2636. },
  2637. isPart(item, index) {
  2638. if (this.questionList[index].ques) {
  2639. if (item.type == 2) {
  2640. let isWrong = this.questionList[index].ques.some((item, i) => {
  2641. return this.questionList[index].ans.indexOf(item) == -1;
  2642. });
  2643. let isRight = this.questionList[index].ans.every((item, i) => {
  2644. return item == this.questionList[index].ques[i];
  2645. });
  2646. if (!isRight && !isWrong) {
  2647. return true;
  2648. }
  2649. }
  2650. } else {
  2651. return false;
  2652. }
  2653. },
  2654. isOver(item, index) {
  2655. if (this.questionList[index].ques) {
  2656. if (item.type == 4) {
  2657. //案例题
  2658. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2659. if (
  2660. jsonItem.type == 1 ||
  2661. jsonItem.type == 2 ||
  2662. jsonItem.type == 3
  2663. ) {
  2664. if (item.ques[indexs]) {
  2665. return true;
  2666. } else {
  2667. return false;
  2668. }
  2669. } else if (jsonItem.type == 5) {
  2670. if (
  2671. item.ques[indexs] &&
  2672. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2673. ) {
  2674. console.log("chil");
  2675. return true;
  2676. } else {
  2677. return false;
  2678. }
  2679. }
  2680. });
  2681. if (isOver) {
  2682. return true;
  2683. } else {
  2684. return false;
  2685. }
  2686. } else if (item.type == 5) {
  2687. //简答题
  2688. //每一项都相等
  2689. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2690. return true;
  2691. }
  2692. //判断
  2693. } else {
  2694. return false;
  2695. }
  2696. } else {
  2697. return false;
  2698. }
  2699. },
  2700. tabSelect(index, bankindex) {
  2701. this.$set(this.questionList[bankindex], "current", index);
  2702. },
  2703. showPhoto(contentStr) {
  2704. if (contentStr && typeof contentStr == "string") {
  2705. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  2706. let strArr = contentStr.match(reg);
  2707. strArr.forEach((str, index) => {
  2708. strArr[index] = str.replace(reg, "$1");
  2709. });
  2710. // 预览图片
  2711. uni.previewImage({
  2712. urls: strArr,
  2713. longPressActions: {
  2714. itemList: ["发送给朋友", "保存图片", "收藏"],
  2715. success: function (data) {
  2716. console.log(
  2717. "选中了第" +
  2718. (data.tapIndex + 1) +
  2719. "个按钮,第" +
  2720. (data.index + 1) +
  2721. "张图片"
  2722. );
  2723. },
  2724. fail: function (err) {
  2725. console.log(err.errMsg);
  2726. },
  2727. },
  2728. });
  2729. }
  2730. },
  2731. },
  2732. computed: {
  2733. doMode() {
  2734. // 做题模式 1章卷 2随机练习 3模拟组卷
  2735. return this.examData.simulateStatus
  2736. ? 3
  2737. : this.entryType == "random"
  2738. ? 2
  2739. : 1;
  2740. },
  2741. },
  2742. };
  2743. </script>
  2744. <style lang="scss" scoped>
  2745. .questionBank {
  2746. width: 100%;
  2747. height: 100vh;
  2748. display: flex;
  2749. flex-direction: column;
  2750. }
  2751. .swiper {
  2752. width: 100%;
  2753. flex: 1;
  2754. }
  2755. .lisSty {
  2756. margin-bottom: 16rpx;
  2757. display: flex;
  2758. align-items: center;
  2759. .flex_auto {
  2760. word-break: break-all;
  2761. flex: 1;
  2762. }
  2763. }
  2764. .activeTI {
  2765. vertical-align: middle;
  2766. display: inline-block;
  2767. border: 1rpx solid #eee;
  2768. border-radius: 50rpx;
  2769. height: 48rpx;
  2770. line-height: 46rpx;
  2771. text-align: center;
  2772. width: 48rpx;
  2773. margin-right: 15rpx;
  2774. color: #666;
  2775. font-size: 30rpx;
  2776. &.right {
  2777. color: #fff;
  2778. background: #36c75a;
  2779. }
  2780. &.wrong {
  2781. color: #fff;
  2782. background: #ff3b30;
  2783. }
  2784. &.checked,
  2785. &.user_choose {
  2786. color: #fff;
  2787. background: #007aff;
  2788. }
  2789. }
  2790. .submit_checkbox {
  2791. position: fixed;
  2792. left: 0;
  2793. right: 0;
  2794. bottom: 120rpx;
  2795. margin: 20rpx auto;
  2796. width: 526rpx;
  2797. height: 80rpx;
  2798. background: rgba(0, 122, 255, 1);
  2799. color: #fff;
  2800. text-align: center;
  2801. line-height: 80rpx;
  2802. font-size: 30rpx;
  2803. border-radius: 40rpx;
  2804. &.disabled {
  2805. opacity: 0.6;
  2806. }
  2807. }
  2808. .titles {
  2809. overflow: hidden;
  2810. margin-bottom: 24rpx;
  2811. }
  2812. .titBox {
  2813. padding: 41rpx 25rpx 24rpx 25rpx;
  2814. }
  2815. .titBox_title {
  2816. padding: 21rpx;
  2817. }
  2818. .tabs {
  2819. margin: 10rpx;
  2820. display: flex;
  2821. .tab {
  2822. margin: 0 4rpx;
  2823. padding: 10rpx 13rpx;
  2824. text-align: center;
  2825. color: #007aff;
  2826. font-size: 28rpx;
  2827. border-radius: 16rpx;
  2828. background: #fff;
  2829. &.current {
  2830. color: #fff;
  2831. background: #007aff;
  2832. }
  2833. }
  2834. }
  2835. .ans {
  2836. margin: 8rpx 8rpx 8rpx;
  2837. .ans_input {
  2838. border-radius: 16rpx;
  2839. background: #fff;
  2840. .top {
  2841. border-bottom: 1rpx solid #eeeeee;
  2842. padding: 16rpx;
  2843. display: flex;
  2844. align-items: center;
  2845. .icon {
  2846. margin-right: 20rpx;
  2847. width: 40rpx;
  2848. height: 38rpx;
  2849. }
  2850. .progress {
  2851. flex: 1;
  2852. }
  2853. .submit {
  2854. width: 168rpx;
  2855. height: 48rpx;
  2856. line-height: 48rpx;
  2857. text-align: center;
  2858. color: #fff;
  2859. font-size: 30rpx;
  2860. background: #007aff;
  2861. border-radius: 24rpx;
  2862. &.disabled {
  2863. opacity: 0.6;
  2864. }
  2865. }
  2866. }
  2867. .textarea {
  2868. textarea {
  2869. width: 100%;
  2870. height: 287rpx;
  2871. padding: 10rpx;
  2872. }
  2873. }
  2874. .imgs {
  2875. overflow: hidden;
  2876. display: flex;
  2877. width: 100%;
  2878. .img {
  2879. width: 104rpx;
  2880. height: 104rpx;
  2881. border-radius: 8rpx;
  2882. position: relative;
  2883. margin: 20rpx;
  2884. text {
  2885. position: absolute;
  2886. right: -15rpx;
  2887. top: -15rpx;
  2888. width: 30rpx;
  2889. height: 30rpx;
  2890. text-align: center;
  2891. line-height: 30rpx;
  2892. color: #fff;
  2893. background: #ff3b30;
  2894. border-radius: 50%;
  2895. }
  2896. image {
  2897. width: 100%;
  2898. height: 100%;
  2899. }
  2900. }
  2901. }
  2902. }
  2903. .ans_submit {
  2904. padding: 16rpx;
  2905. border-radius: 16rpx;
  2906. background: #fff;
  2907. .imgs {
  2908. overflow: hidden;
  2909. display: flex;
  2910. width: 100%;
  2911. .img {
  2912. width: 104rpx;
  2913. height: 104rpx;
  2914. border-radius: 8rpx;
  2915. position: relative;
  2916. margin: 20rpx;
  2917. image {
  2918. width: 100%;
  2919. height: 100%;
  2920. }
  2921. }
  2922. }
  2923. }
  2924. }
  2925. .leftLetters {
  2926. display: flex;
  2927. align-items: center;
  2928. width: 220rpx;
  2929. .btnType {
  2930. padding: 5rpx 10rpx;
  2931. border: 1rpx solid #007aff;
  2932. border-radius: 10rpx;
  2933. background-color: rgba(0, 122, 255, 0.1);
  2934. font-size: 28rpx;
  2935. color: #007aff;
  2936. margin-right: 15rpx;
  2937. }
  2938. }
  2939. .firstLetter {
  2940. display: flex;
  2941. justify-content: space-between;
  2942. align-items: center;
  2943. margin-bottom: 30rpx;
  2944. }
  2945. .popupView {
  2946. height: 100%;
  2947. padding-bottom: 100rpx;
  2948. .popupTops {
  2949. height: 77rpx;
  2950. border-bottom: 1rpx solid #eee;
  2951. text-align: center;
  2952. line-height: 77rpx;
  2953. font-size: 24rpx;
  2954. color: #999;
  2955. position: relative;
  2956. .topIcon {
  2957. position: absolute;
  2958. top: 10rpx;
  2959. left: 50%;
  2960. transform: translateX(-50%);
  2961. width: 80rpx;
  2962. height: 8rpx;
  2963. background-color: #999;
  2964. border-radius: 4rpx;
  2965. }
  2966. }
  2967. .popupContent {
  2968. }
  2969. }
  2970. .pageContent {
  2971. position: relative;
  2972. background-color: #eaeef1;
  2973. height: 100%;
  2974. padding-top: 8rpx;
  2975. padding-bottom: 100rpx;
  2976. overflow-y: scroll;
  2977. }
  2978. .pad_8 {
  2979. background-color: #fff;
  2980. margin: 0rpx 8rpx 8rpx;
  2981. border-radius: 16rpx;
  2982. &.no-margin {
  2983. margin-top: -16rpx;
  2984. border-radius: 0 0 16rpx 16rpx;
  2985. }
  2986. }
  2987. .answer {
  2988. height: 80rpx;
  2989. line-height: 80rpx;
  2990. padding: 0rpx 24rpx;
  2991. display: flex;
  2992. align-items: center;
  2993. justify-content: space-between;
  2994. color: #666;
  2995. font-size: 30rpx;
  2996. }
  2997. .footer_btn {
  2998. background-color: #fff;
  2999. z-index: 10078;
  3000. position: fixed;
  3001. bottom: 0rpx;
  3002. display: flex;
  3003. align-items: center;
  3004. justify-content: space-between;
  3005. width: 100%;
  3006. height: 98rpx;
  3007. padding: 0rpx 38rpx;
  3008. border-top: 1rpx solid #eee;
  3009. .flex_center {
  3010. flex: 1;
  3011. display: flex;
  3012. justify-content: center;
  3013. align-items: center;
  3014. flex-direction: column;
  3015. margin: 0 200rpx;
  3016. font-size: 24rpx;
  3017. color: #999999;
  3018. .up-icon {
  3019. margin-bottom: 18rpx;
  3020. width: 100%;
  3021. display: flex;
  3022. justify-content: center;
  3023. image {
  3024. width: 58rpx;
  3025. height: 21rpx;
  3026. }
  3027. }
  3028. }
  3029. .collect {
  3030. visibility: hidden;
  3031. width: 100rpx;
  3032. &.show {
  3033. visibility: visible;
  3034. }
  3035. > view {
  3036. display: flex;
  3037. flex-direction: column;
  3038. align-items: center;
  3039. justify-content: center;
  3040. image {
  3041. width: 32rpx;
  3042. height: 32rpx;
  3043. margin-bottom: 6rpx;
  3044. }
  3045. view {
  3046. font-size: 24rpx;
  3047. color: #999999;
  3048. }
  3049. }
  3050. }
  3051. }
  3052. .boxSty {
  3053. padding: 44rpx 41rpx 0rpx;
  3054. }
  3055. .liListSty {
  3056. border: 1rpx solid #eeeeee;
  3057. width: 88rpx;
  3058. height: 88rpx;
  3059. border-radius: 32rpx;
  3060. text-align: center;
  3061. line-height: 88rpx;
  3062. color: #333;
  3063. font-size: 32rpx;
  3064. float: left;
  3065. margin: 20rpx 23rpx;
  3066. &.isRight {
  3067. border: 1rpx solid #eeeeee;
  3068. color: #fff;
  3069. background: #36c75a;
  3070. }
  3071. &.isWrong {
  3072. border: 1rpx solid #eeeeee;
  3073. color: #fff;
  3074. background: #ff3b30;
  3075. }
  3076. &.isPart {
  3077. border: 1rpx solid #eeeeee;
  3078. color: #fff;
  3079. background: #ffc53d;
  3080. }
  3081. &.isOver {
  3082. border: 1rpx solid #eeeeee;
  3083. color: #fff;
  3084. background: blue;
  3085. }
  3086. &.check_ans {
  3087. border: 1rpx solid #eeeeee;
  3088. color: #fff;
  3089. background: #007aff;
  3090. }
  3091. }
  3092. .answerInfos {
  3093. padding: 25rpx 25rpx 25rpx 23rpx;
  3094. }
  3095. .answerTitle {
  3096. margin-bottom: 28rpx;
  3097. color: #666;
  3098. font-size: 30rpx;
  3099. }
  3100. .answerContent {
  3101. font-size: 30rpx;
  3102. color: #666;
  3103. }
  3104. .textChild {
  3105. display: inline-block;
  3106. vertical-align: middle;
  3107. }
  3108. .dialog {
  3109. position: fixed;
  3110. left: 0;
  3111. top: 0;
  3112. width: 100%;
  3113. height: 100%;
  3114. background-color: rgba(0, 0, 0, 0.8);
  3115. display: flex;
  3116. flex-direction: column;
  3117. align-items: center;
  3118. justify-content: center;
  3119. z-index: 20000;
  3120. .pointer {
  3121. width: 338rpx;
  3122. height: 240rpx;
  3123. }
  3124. .text {
  3125. font-size: 32rpx;
  3126. color: #ffffff;
  3127. text-align: center;
  3128. }
  3129. .btn {
  3130. width: 242rpx;
  3131. height: 82rpx;
  3132. border: 2rpx solid #ffffff;
  3133. border-radius: 16rpx;
  3134. text-align: center;
  3135. line-height: 82rpx;
  3136. margin: 41rpx auto;
  3137. color: #fff;
  3138. font-size: 32rpx;
  3139. }
  3140. }
  3141. .dialog-arrow {
  3142. padding-top: 124rpx;
  3143. position: fixed;
  3144. left: 0;
  3145. top: 0;
  3146. width: 100%;
  3147. height: 100%;
  3148. background-color: rgba(0, 0, 0, 0.8);
  3149. z-index: 20000;
  3150. .pointer {
  3151. margin-left: 87rpx;
  3152. display: block;
  3153. width: 95rpx;
  3154. height: 98rpx;
  3155. }
  3156. .text {
  3157. padding-left: 177rpx;
  3158. font-size: 32rpx;
  3159. color: #ffffff;
  3160. }
  3161. .btn {
  3162. width: 242rpx;
  3163. height: 82rpx;
  3164. border: 2rpx solid #ffffff;
  3165. border-radius: 16rpx;
  3166. text-align: center;
  3167. line-height: 82rpx;
  3168. margin: 500rpx auto 0;
  3169. color: #fff;
  3170. font-size: 32rpx;
  3171. }
  3172. }
  3173. .dialog_wrap {
  3174. position: fixed;
  3175. left: 0;
  3176. top: 0;
  3177. width: 100%;
  3178. height: 100%;
  3179. z-index: 9999999999;
  3180. .bg {
  3181. background: rgba(0, 0, 0, 0.3);
  3182. position: absolute;
  3183. left: 0;
  3184. top: 0;
  3185. width: 100%;
  3186. height: 100%;
  3187. }
  3188. .dialog {
  3189. position: absolute;
  3190. left: 50%;
  3191. top: 50%;
  3192. transform: translate3D(-50%, -50%, 0);
  3193. width: 640rpx;
  3194. height: 439rpx;
  3195. background: #ffffff;
  3196. border-radius: 24rpx;
  3197. .title {
  3198. font-size: 30rpx;
  3199. font-weight: bold;
  3200. color: #333333;
  3201. line-height: 48rpx;
  3202. text-align: center;
  3203. margin-top: 40rpx;
  3204. }
  3205. .content {
  3206. margin: 35rpx 35rpx 0;
  3207. font-size: 30rpx;
  3208. color: #666666;
  3209. line-height: 48rpx;
  3210. }
  3211. .btns {
  3212. margin-top: 35rpx;
  3213. display: flex;
  3214. align-items: center;
  3215. justify-content: center;
  3216. .btn {
  3217. width: 200rpx;
  3218. height: 80rpx;
  3219. line-height: 80rpx;
  3220. text-align: center;
  3221. background: #f5f5f5;
  3222. border-radius: 40rpx;
  3223. font-size: 30rpx;
  3224. color: rgba(0, 122, 255, 1);
  3225. background: #f5f5f5;
  3226. margin: 0 20rpx;
  3227. &.active {
  3228. color: #f5f5f5;
  3229. background: rgba(0, 122, 255, 1);
  3230. }
  3231. }
  3232. }
  3233. }
  3234. }
  3235. .popboxs {
  3236. width: 100%;
  3237. height: 100%;
  3238. display: flex;
  3239. flex-direction: column;
  3240. align-items: center;
  3241. }
  3242. .classTops {
  3243. flex-shrink: 0;
  3244. padding: 39rpx 0rpx 4rpx;
  3245. font-weight: bold;
  3246. color: #333;
  3247. font-size: 30rpx;
  3248. }
  3249. .textStys {
  3250. width: 100%;
  3251. flex: 1;
  3252. padding: 36rpx;
  3253. }
  3254. .classFootsty {
  3255. flex-shrink: 0;
  3256. display: flex;
  3257. align-items: center;
  3258. justify-content: center;
  3259. padding: 10rpx 0rpx 40rpx;
  3260. .btnsty {
  3261. width: 200rpx;
  3262. height: 80rpx;
  3263. border-radius: 40rpx;
  3264. font-weight: bold;
  3265. font-size: 30rpx;
  3266. text-align: center;
  3267. line-height: 80rpx;
  3268. }
  3269. .btns1 {
  3270. background-color: #f5f5f5;
  3271. color: #007aff;
  3272. }
  3273. .btns2 {
  3274. margin-left: 40rpx;
  3275. background-color: #007aff;
  3276. color: #ffffff;
  3277. }
  3278. }
  3279. </style>