questionBank.vue 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420
  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. return this.noListTip()
  1550. }
  1551. this.dataAnlyze(this.examData.questionList || []);
  1552. } else {
  1553. this.$u.toast(res.data.msg);
  1554. setTimeout(() => {
  1555. uni.navigateBack();
  1556. }, 2000);
  1557. }
  1558. });
  1559. },
  1560. noListTip(content = "该试卷暂无题目") {
  1561. this.hideDialog();
  1562. uni.showModal({
  1563. showCancel: false,
  1564. content,
  1565. success: (k) => {
  1566. if (k.confirm) {
  1567. this.isSubmit = true;
  1568. uni.navigateBack();
  1569. }
  1570. },
  1571. });
  1572. },
  1573. /**
  1574. * 请求题目列表 app/common/bank/question/list
  1575. */
  1576. goodsQuestionList() {
  1577. this.$api[
  1578. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1579. ]({
  1580. examId: this.id,
  1581. goodsId: this.goodsId,
  1582. orderGoodsId: this.orderGoodsId,
  1583. from: 1,
  1584. }).then((res) => {
  1585. if (res.data.code == 500) {
  1586. return this.noListTip('你已完成所有题目')
  1587. }
  1588. let data = res.data.data;
  1589. if (this.doMode == 3) {
  1590. this.simulateExamId = data.simulateExamId;
  1591. data = data.questionList;
  1592. }
  1593. if (!data.length) {
  1594. return this.noListTip()
  1595. }
  1596. this.allTimes = data[0].answerTime * 60;
  1597. this.lastTime = data[0].answerTime && data[0].answerTime * 60;
  1598. //考试时间到了自动交卷
  1599. if (this.lastTime) {
  1600. this.timer = setInterval(() => {
  1601. if (this.lastTime <= 0) {
  1602. clearInterval(this.timer);
  1603. uni.showToast({
  1604. icon: "none",
  1605. mask: true,
  1606. title: "考试时间已到,系统将自动交卷",
  1607. duration: 10000,
  1608. });
  1609. this.submit();
  1610. return;
  1611. }
  1612. this.lastTime--;
  1613. }, 1000);
  1614. } else {
  1615. }
  1616. this.dataAnlyze(data);
  1617. });
  1618. },
  1619. dataAnlyze(datas = []) {
  1620. console.log("datas:", datas);
  1621. datas.forEach((item, index) => {
  1622. // if (typeof item.jsonStr == 'string') {
  1623. item.jsonStr = JSON.parse(item.jsonStr);
  1624. if (item.type == 2) {
  1625. //多选
  1626. item.jsonStr.forEach((str) => {
  1627. str.optionsId = "" + str.optionsId;
  1628. });
  1629. let arr = item.answerQuestion.split(",");
  1630. arr.forEach((a, i) => {
  1631. arr[i] = "" + a;
  1632. });
  1633. item.ans = arr;
  1634. item.analysisContent &&
  1635. (item.analysisContent = item.analysisContent.replace(
  1636. /<img/gi,
  1637. '<img style="max-width:100%;"'
  1638. ));
  1639. item.content &&
  1640. (item.content = item.content.replace(
  1641. /<img/gi,
  1642. '<img style="max-width:100%;"'
  1643. ));
  1644. return;
  1645. } else if (item.type == 5) {
  1646. //简答题
  1647. item.ansText = {
  1648. text: "",
  1649. imageList: [],
  1650. };
  1651. item.ques = {
  1652. text: "",
  1653. imageList: [],
  1654. };
  1655. item.analysisContent &&
  1656. (item.analysisContent = item.analysisContent.replace(
  1657. /<img/gi,
  1658. '<img style="max-width:100%;"'
  1659. ));
  1660. item.content &&
  1661. (item.content = item.content.replace(
  1662. /<img/gi,
  1663. '<img style="max-width:100%;"'
  1664. ));
  1665. } else if (item.type == 4) {
  1666. //案例题
  1667. item.ques = [];
  1668. item.current = 0;
  1669. let ansArr = [];
  1670. item.jsonStr.forEach((json, index) => {
  1671. if (json.type == 1) {
  1672. ansArr[index] = json.answerQuestion;
  1673. json.content &&
  1674. (json.content = json.content.replace(
  1675. /<img/gi,
  1676. '<img style="max-width:100%;"'
  1677. ));
  1678. } else if (json.type == 2) {
  1679. json.optionsList.forEach((str) => {
  1680. str.optionsId = "" + str.optionsId;
  1681. });
  1682. let arr = json.answerQuestion.split(",");
  1683. arr.forEach((a, i) => {
  1684. arr[i] = "" + a;
  1685. });
  1686. ansArr[index] = arr;
  1687. json.content &&
  1688. (json.content = json.content.replace(
  1689. /<img/gi,
  1690. '<img style="max-width:100%;"'
  1691. ));
  1692. } else if (json.type == 3) {
  1693. ansArr[index] = json.answerQuestion;
  1694. json.content &&
  1695. (json.content = json.content.replace(
  1696. /<img/gi,
  1697. '<img style="max-width:100%;"'
  1698. ));
  1699. } else if (json.type == 5) {
  1700. ansArr[index] = {
  1701. text: json.answerQuestion,
  1702. imageList: [],
  1703. };
  1704. json.ansText = {
  1705. text: "",
  1706. imageList: [],
  1707. };
  1708. json.content &&
  1709. (json.content = json.content.replace(
  1710. /<img/gi,
  1711. '<img style="max-width:100%;"'
  1712. ));
  1713. }
  1714. });
  1715. item.analysisContent &&
  1716. (item.analysisContent = item.analysisContent.replace(
  1717. /<img/gi,
  1718. '<img style="max-width:100%;"'
  1719. ));
  1720. item.content &&
  1721. (item.content = item.content.replace(
  1722. /<img/gi,
  1723. '<img style="max-width:100%;"'
  1724. ));
  1725. item.ans = ansArr;
  1726. return;
  1727. }
  1728. item.analysisContent &&
  1729. (item.analysisContent = item.analysisContent.replace(
  1730. /<img/gi,
  1731. '<img style="max-width:100%;"'
  1732. ));
  1733. item.content &&
  1734. (item.content = item.content.replace(
  1735. /<img/gi,
  1736. '<img style="max-width:100%;"'
  1737. ));
  1738. item.ans = item.answerQuestion;
  1739. // }
  1740. });
  1741. this.questionList = datas;
  1742. this.lastCount = this.questionList.length;
  1743. this.examRecord();
  1744. this.getCollectInfo(this.current);
  1745. },
  1746. /**
  1747. * @param {Object} e单选点击
  1748. */
  1749. radioSelect(optionsId, bindex) {
  1750. // if (this.questionList[bindex].ques) return;
  1751. if (this.questionList[bindex].ques && this.bankType == 1) {
  1752. return;
  1753. }
  1754. this.$set(this.questionList[bindex], "ques", optionsId);
  1755. // if ((bindex + 1) < this.questionList.length) {
  1756. // this.current = bindex + 1
  1757. // }
  1758. this.isDoOver();
  1759. // 回答错误
  1760. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1761. // // /exam/wwrong/record
  1762. // this.$api
  1763. // .examWrongRecord({
  1764. // orderGoodsId: this.orderGoodsId,
  1765. // examId: this.id,
  1766. // goodsId: this.goodsId,
  1767. // moduleExamId: this.moduleId || 0,
  1768. // chapterExamId: this.chapterId || 0,
  1769. // questionIds: [this.questionList[bindex].questionId],
  1770. // recordId: this.recordId,
  1771. // })
  1772. // .then((res) => {});
  1773. // } else {
  1774. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1775. // // if(question) {
  1776. // // this.$api.wrongRecordDelete({
  1777. // // "examId": +this.id,
  1778. // // "goodsId": +this.goodsId,
  1779. // // "questionId": this.questionList[bindex].questionId,
  1780. // // }).then(res => {
  1781. // // })
  1782. // // }
  1783. // }
  1784. },
  1785. /**
  1786. * @param {Object} e案例单选点击
  1787. */
  1788. radioSelectChild(optionsId, ansIndex, bindex) {
  1789. // if (this.questionList[bindex].ques[ansIndex]) return;
  1790. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1791. return;
  1792. }
  1793. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1794. this.isDoOver();
  1795. },
  1796. /**
  1797. * @param {Object} 多选点击
  1798. */
  1799. checkboxSelect(optionsId, bindex, index) {
  1800. if (this.questionList[bindex].ques && this.bankType == 1) {
  1801. return;
  1802. }
  1803. this.$set(
  1804. this.questionList[bindex].jsonStr[index],
  1805. "checked",
  1806. !this.questionList[bindex].jsonStr[index].checked
  1807. );
  1808. },
  1809. /**
  1810. * @param {Object} 案例多选点击
  1811. */
  1812. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1813. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1814. return;
  1815. }
  1816. this.$set(
  1817. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1818. "checked",
  1819. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1820. .checked
  1821. );
  1822. },
  1823. isCheckboxChecked(arr) {
  1824. return arr.some((item) => {
  1825. if (item.checked) {
  1826. return true;
  1827. }
  1828. });
  1829. },
  1830. /**
  1831. * @param {Object} 多选确认
  1832. */
  1833. checkboxSubmit(bindex) {
  1834. // console.log('')
  1835. // if (this.questionList[bindex].ques) return;
  1836. if (this.questionList[bindex].ques && this.bankType == 1) {
  1837. return;
  1838. }
  1839. let arr = [];
  1840. this.questionList[bindex].jsonStr.forEach((item) => {
  1841. if (item.checked) {
  1842. arr.push(item.optionsId);
  1843. }
  1844. });
  1845. if (!arr.length) {
  1846. delete this.questionList[bindex].ques;
  1847. uni.showToast({
  1848. title: "请选择答案",
  1849. icon: "none",
  1850. });
  1851. return;
  1852. }
  1853. this.$set(this.questionList[bindex], "ques", arr);
  1854. this.$u.toast("已确认答案");
  1855. this.isDoOver();
  1856. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1857. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1858. // })
  1859. // // 回答错误
  1860. // if (isWrong) {
  1861. // this.$api
  1862. // .examWrongRecord({
  1863. // orderGoodsId: this.orderGoodsId,
  1864. // examId: this.id,
  1865. // goodsId: this.goodsId,
  1866. // moduleExamId: this.moduleId || 0,
  1867. // chapterExamId: this.chapterId || 0,
  1868. // questionIds: [this.questionList[bindex].questionId],
  1869. // recordId: this.recordId,
  1870. // })
  1871. // .then((res) => {});
  1872. // } else {
  1873. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1874. // // if(question) {
  1875. // // this.$api.wrongRecordDelete({
  1876. // // "examId": +this.id,
  1877. // // "goodsId": +this.goodsId,
  1878. // // "questionId": this.questionList[bindex].questionId,
  1879. // // }).then(res => {
  1880. // // })
  1881. // // }
  1882. // }
  1883. },
  1884. /**
  1885. * @param {Object} 案例多选确认
  1886. */
  1887. checkboxSubmitChild(bindex, ansIndex) {
  1888. // if (this.questionList[bindex].ques[ansIndex]) return;
  1889. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1890. return;
  1891. }
  1892. let arr = [];
  1893. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1894. (item) => {
  1895. if (item.checked) {
  1896. arr.push(item.optionsId);
  1897. }
  1898. }
  1899. );
  1900. if (!arr.length) {
  1901. delete this.questionList[bindex].ques[ansIndex];
  1902. uni.showToast({
  1903. title: "请选择答案",
  1904. icon: "none",
  1905. });
  1906. return;
  1907. }
  1908. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1909. this.$u.toast("已确认答案");
  1910. this.isDoOver();
  1911. },
  1912. /**
  1913. * @param {Object} index
  1914. * @param {Object} bindex
  1915. * 判断题
  1916. */
  1917. judgeSelect(index, bindex) {
  1918. // if (this.questionList[bindex].ques) return;
  1919. if (this.questionList[bindex].ques && this.bankType == 1) {
  1920. return;
  1921. } // 答案: 判断题1正确 0错误
  1922. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  1923. console.log(
  1924. "this.questionList[bindex]:",
  1925. this.questionList[bindex].ques,
  1926. this.questionList[bindex].ans
  1927. );
  1928. this.isDoOver();
  1929. // 回答错误
  1930. // if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1931. // this.$api
  1932. // .examWrongRecord({
  1933. // orderGoodsId: this.orderGoodsId,
  1934. // examId: this.id,
  1935. // goodsId: this.goodsId,
  1936. // moduleExamId: this.moduleId || 0,
  1937. // chapterExamId: this.chapterId || 0,
  1938. // questionIds: [this.questionList[bindex].questionId],
  1939. // recordId: this.recordId,
  1940. // })
  1941. // .then((res) => {});
  1942. // } else {
  1943. // // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1944. // // if(question) {
  1945. // // this.$api.wrongRecordDelete({
  1946. // // "examId": +this.id,
  1947. // // "goodsId": +this.goodsId,
  1948. // // "questionId": this.questionList[bindex].questionId,
  1949. // // }).then(res => {
  1950. // // })
  1951. // // }
  1952. // }
  1953. },
  1954. /**
  1955. * @param {Object} ansindex
  1956. * @param {Object} childindex
  1957. * @param {Object} bindex
  1958. * 案例判断题
  1959. */
  1960. judgeSelectChild(ansindex, childindex, bindex) {
  1961. // if (this.questionList[bindex].ques[ansindex]) return;
  1962. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  1963. return;
  1964. }
  1965. this.$set(
  1966. this.questionList[bindex].ques,
  1967. ansindex,
  1968. childindex == 0 ? "1" : "0"
  1969. );
  1970. this.isDoOver();
  1971. },
  1972. openFooterTab() {
  1973. this.show = true;
  1974. },
  1975. changeIndex(index) {
  1976. this.current = index;
  1977. },
  1978. swiperChange(e) {
  1979. this.current = e.detail.current;
  1980. this.getCollectInfo(this.current);
  1981. },
  1982. /**
  1983. * @param {Object} current
  1984. * 获取收藏信息
  1985. */
  1986. getCollectInfo(current) {
  1987. this.$api
  1988. .getCollectInfo({
  1989. examId: this.id,
  1990. questionId: this.questionList[current].questionId,
  1991. goodsId: this.goodsId,
  1992. orderGoodsId: this.orderGoodsId,
  1993. })
  1994. .then((res) => {
  1995. if (res.data.code == 500) {
  1996. this.$set(this.collectList, current, false);
  1997. } else if (res.data.code == 200) {
  1998. this.$set(this.collectList, current, res.data.data);
  1999. }
  2000. });
  2001. },
  2002. pdsubmit() {
  2003. // if (this.bankType == 1) {
  2004. let ansCount = this.questionOverNum(true); //已答题数
  2005. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2006. //没有答完
  2007. if (this.lastCount !== 0) {
  2008. this.cgType = 6;
  2009. this.showpopups = true;
  2010. return;
  2011. }
  2012. // }
  2013. if (this.bankType == 2) {
  2014. if (this.lastTime > 0) {
  2015. let lastTime = this.countdown(this.lastTime);
  2016. uni.showModal({
  2017. title: "提示",
  2018. content: `时间还剩余${lastTime},确定交卷吗?`,
  2019. confirmText: "交卷",
  2020. cancelText: "继续答题",
  2021. success: (res) => {
  2022. if (res.confirm) {
  2023. //确定
  2024. this.submit();
  2025. } else {
  2026. //取消
  2027. }
  2028. },
  2029. });
  2030. return;
  2031. }
  2032. }
  2033. this.submit();
  2034. },
  2035. /**
  2036. * 交卷
  2037. */
  2038. submit() {
  2039. let score = 0; //计算总分
  2040. let reportStatus = 0;
  2041. let number = 0; //做对的题目数量
  2042. let doQuestionNum = 0; //做过的题目数量
  2043. let allScore = 0; //总分
  2044. let passScore = 0;
  2045. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2046. let doQuestionIds = []; //做过的题目id
  2047. let lessQuestionNum = 0;
  2048. let rightQuestionIds = []; //做对的题目id
  2049. this.questionList.forEach((item, index) => {
  2050. passScore = item.passScore;
  2051. if (item.type == 1) {
  2052. //正确
  2053. if (item.ques == item.ans) {
  2054. item.scoreResult = item.score;
  2055. score += item.score;
  2056. number++;
  2057. rightQuestionIds.push(item.questionId);
  2058. } else {
  2059. //错误
  2060. item.scoreResult = 0;
  2061. if (item.ques) {
  2062. doWrongQuestionIds.push(item.questionId);
  2063. }
  2064. }
  2065. allScore += item.score;
  2066. if (item.ques) {
  2067. doQuestionNum++;
  2068. doQuestionIds.push(item.questionId);
  2069. }
  2070. } else if (item.type == 2) {
  2071. let isRight =
  2072. item.ans &&
  2073. item.ans.every((quesItem, quesIndex) => {
  2074. if (item.ques) {
  2075. return item.ques[quesIndex] == item.ans[quesIndex];
  2076. } else {
  2077. return false;
  2078. }
  2079. });
  2080. if (isRight) {
  2081. score += item.score;
  2082. number++;
  2083. item.scoreResult = item.score;
  2084. rightQuestionIds.push(item.questionId);
  2085. } else {
  2086. let hasPart = false;
  2087. let checkboxScore = 1; //获取单题总分数
  2088. item.ques &&
  2089. item.ques.forEach((ques, quesIndex) => {
  2090. //选错一个全扣
  2091. if (item.ques) {
  2092. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2093. checkboxScore = 0;
  2094. }
  2095. } else {
  2096. checkboxScore = 0;
  2097. }
  2098. });
  2099. //没选错
  2100. if (checkboxScore) {
  2101. checkboxScore = 0;
  2102. item.ans.forEach((ans, quesIndex) => {
  2103. //漏选扣一部分,对n题给n X partScore 分
  2104. if (item.ques) {
  2105. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2106. checkboxScore += item.partScore;
  2107. hasPart = true;
  2108. }
  2109. } else {
  2110. checkboxScore = 0;
  2111. }
  2112. });
  2113. }
  2114. if (!hasPart) {
  2115. //0分
  2116. item.scoreResult = 0;
  2117. if (item.ques) {
  2118. doWrongQuestionIds.push(item.questionId);
  2119. }
  2120. } else {
  2121. //部分分
  2122. // number++;
  2123. lessQuestionNum++;
  2124. // doWrongQuestionIds.push(item.questionId);
  2125. item.scoreResult = checkboxScore;
  2126. score += checkboxScore;
  2127. // rightQuestionIds.push(item.questionId)
  2128. }
  2129. }
  2130. allScore += item.score;
  2131. if (item.ques && item.ques.length) {
  2132. doQuestionNum++;
  2133. doQuestionIds.push(item.questionId);
  2134. }
  2135. } else if (item.type == 3) {
  2136. if (item.ques == item.ans) {
  2137. item.scoreResult = item.score;
  2138. score += item.score;
  2139. number++;
  2140. rightQuestionIds.push(item.questionId);
  2141. } else {
  2142. item.scoreResult = 0;
  2143. if (item.ques) {
  2144. doWrongQuestionIds.push(item.questionId);
  2145. }
  2146. }
  2147. allScore += item.score;
  2148. if (item.ques) {
  2149. doQuestionNum++;
  2150. doQuestionIds.push(item.questionId);
  2151. }
  2152. } else if (item.type == 4) {
  2153. allScore += item.score;
  2154. if (item.ques && item.ques.length) {
  2155. doQuestionNum++;
  2156. doQuestionIds.push(item.questionId);
  2157. }
  2158. } else if (item.type == 5) {
  2159. allScore += item.score;
  2160. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2161. doQuestionNum++;
  2162. doQuestionIds.push(item.questionId);
  2163. }
  2164. }
  2165. });
  2166. //大于及格
  2167. if (score >= passScore) {
  2168. reportStatus = 1;
  2169. } else {
  2170. reportStatus = 0;
  2171. }
  2172. //交卷
  2173. this.$api
  2174. .examRecordEdit({
  2175. // courseId: this.courseId,
  2176. examId: this.id,
  2177. goodsId: this.goodsId,
  2178. reportStatus: reportStatus,
  2179. recordId: this.recordId,
  2180. rightQuestionNum: number,
  2181. orderGoodsId: this.orderGoodsId,
  2182. status: 1,
  2183. lessQuestionNum: lessQuestionNum,
  2184. moduleExamId: this.moduleId || 0,
  2185. chapterExamId: this.chapterId || 0,
  2186. doQuestionIds: doQuestionIds.join(","),
  2187. rightQuestionIds: rightQuestionIds.join(","),
  2188. doQuestionNum: doQuestionNum,
  2189. performance: score,
  2190. totalScore: allScore,
  2191. examTime: parseInt(this.allTimes),
  2192. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2193. historyExamJson: JSON.stringify(this.questionList),
  2194. // type: ''
  2195. })
  2196. .then((res) => {
  2197. this.isSubmit = true;
  2198. if (res.data.code == 200) {
  2199. this.entryType == "daily" && this.dailyExam();
  2200. uni.showToast({
  2201. title: "交卷成功",
  2202. duration: 1000,
  2203. icon: "none",
  2204. });
  2205. setTimeout(() => {
  2206. uni.redirectTo({
  2207. url:
  2208. "/pages2/bank/question_report?goodsId=" +
  2209. this.goodsId +
  2210. "&chapterId=" +
  2211. this.chapterId +
  2212. "&moduleId=" +
  2213. this.moduleId +
  2214. "&examId=" +
  2215. this.id +
  2216. "&id=" +
  2217. this.recordId +
  2218. "&orderGoodsId=" +
  2219. this.orderGoodsId +
  2220. "&entryType=" +
  2221. this.entryType +
  2222. "&bankNum=" +
  2223. this.bankNum +
  2224. "&doMode=" +
  2225. this.doMode +
  2226. "&courseType=1",
  2227. });
  2228. }, 1000);
  2229. }
  2230. });
  2231. //错题集id提交(客观题)
  2232. this.$api
  2233. .examWrongRecord({
  2234. examId: this.id,
  2235. goodsId: this.goodsId,
  2236. orderGoodsId: this.orderGoodsId,
  2237. questionIds: doWrongQuestionIds,
  2238. recordId: this.recordId,
  2239. type: 1, // 题库试卷传1
  2240. doMode: this.doMode,
  2241. })
  2242. .then((res) => {});
  2243. },
  2244. // 每日一练试卷打卡
  2245. dailyExam() {
  2246. const dateStamp = parseInt(
  2247. new Date(new Date().toLocaleDateString()).getTime() / 1000
  2248. );
  2249. this.$http({
  2250. url: "/bank/question/special/exam/record",
  2251. method: "post",
  2252. data: {
  2253. examId: this.id,
  2254. chapterExamId: this.chapterId, // 章卷ID
  2255. moduleExamId: this.moduleId, //模块卷ID
  2256. goodsId: this.goodsId,
  2257. recordTime: dateStamp, // 传当天0点时间戳(秒)
  2258. },
  2259. }).then((res) => {
  2260. if (res.data.code == 200) {
  2261. }
  2262. });
  2263. },
  2264. /**
  2265. * @param {Object} state
  2266. * @param {Object} index
  2267. * 收藏
  2268. */
  2269. collect(state, index) {
  2270. if (!state) {
  2271. this.$api
  2272. .collectQuestion({
  2273. examId: this.id,
  2274. questionId: this.questionList[index].questionId,
  2275. goodsId: this.goodsId || "",
  2276. orderGoodsId: this.orderGoodsId,
  2277. doMode: this.doMode,
  2278. })
  2279. .then((res) => {
  2280. if (res.data.code == 200) {
  2281. this.$set(this.collectList, index, true);
  2282. uni.showToast({
  2283. title: "收藏成功",
  2284. duration: 2000,
  2285. icon: "none",
  2286. });
  2287. this.getCollectInfo(index);
  2288. }
  2289. });
  2290. } else {
  2291. this.$api
  2292. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2293. .then((res) => {
  2294. if (res.data.code == 200) {
  2295. this.$set(this.collectList, index, false);
  2296. uni.showToast({
  2297. title: "取消收藏成功",
  2298. duration: 2000,
  2299. icon: "none",
  2300. });
  2301. }
  2302. });
  2303. }
  2304. return;
  2305. },
  2306. /**
  2307. * @param {Object} imgIndex
  2308. * @param {Object} bankIndex
  2309. * 删除简答图片
  2310. */
  2311. deleteImg(imgIndex, bankIndex) {
  2312. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2313. },
  2314. /**
  2315. * @param {Object} imgIndex
  2316. * @param {Object} bankIndex
  2317. * @param {Object} ansIndex
  2318. * 删除案例题简答图片
  2319. */
  2320. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2321. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2322. imgIndex,
  2323. 1
  2324. );
  2325. },
  2326. /**
  2327. * @param {Object} bankindex
  2328. * 选择上传图片
  2329. */
  2330. chooseImg(bankindex) {
  2331. if (
  2332. this.questionList[bankindex] &&
  2333. this.questionList[bankindex].ansText &&
  2334. this.questionList[bankindex].ansText.imageList.length >= 4
  2335. ) {
  2336. uni.showToast({
  2337. icon: "none",
  2338. title: "最多选择4张",
  2339. });
  2340. return;
  2341. }
  2342. uni.chooseImage({
  2343. count: 1, //默认9
  2344. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2345. sourceType: ["album", "camera"], //从相册选择
  2346. success: (res) => {
  2347. let self = this;
  2348. // console.log(JSON.stringify(res.tempFilePaths));
  2349. let img = res.tempFilePaths[0];
  2350. uni.getImageInfo({
  2351. src: img,
  2352. success: async (res) => {
  2353. let canvasWidth = res.width; //图片原始长宽
  2354. let canvasHeight = res.height;
  2355. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2356. uni.compressImage({
  2357. src: img,
  2358. quality: 75,
  2359. width: "50%",
  2360. height: "50%",
  2361. success: async (rest) => {
  2362. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2363. this.questionList[bankindex].ansText.imageList.push(dir);
  2364. },
  2365. });
  2366. } else {
  2367. const dir = await self.uploadFile(img, 0);
  2368. this.questionList[bankindex].ansText.imageList.push(dir);
  2369. }
  2370. },
  2371. });
  2372. },
  2373. });
  2374. },
  2375. /**
  2376. * @param {Object} bankindex
  2377. * @param {Object} ansindex
  2378. * 案例题选择上传图片
  2379. */
  2380. chooseImgChild(bankindex, ansindex) {
  2381. if (
  2382. this.questionList[bankindex].jsonStr[ansindex] &&
  2383. this.questionList[bankindex].jsonStr[ansindex].ansText &&
  2384. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
  2385. .length >= 4
  2386. ) {
  2387. uni.showToast({
  2388. icon: "none",
  2389. title: "最多选择4张",
  2390. });
  2391. return;
  2392. }
  2393. uni.chooseImage({
  2394. count: 1, //默认9
  2395. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2396. sourceType: ["album", "camera"], //从相册选择
  2397. success: (res) => {
  2398. let self = this;
  2399. // console.log(JSON.stringify(res.tempFilePaths));
  2400. let img = res.tempFilePaths[0];
  2401. uni.getImageInfo({
  2402. src: img,
  2403. success: async (res) => {
  2404. let canvasWidth = res.width; //图片原始长宽
  2405. let canvasHeight = res.height;
  2406. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2407. uni.compressImage({
  2408. src: img,
  2409. quality: 75,
  2410. width: "50%",
  2411. height: "50%",
  2412. success: async (rest) => {
  2413. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2414. this.questionList[bankindex].jsonStr[
  2415. ansindex
  2416. ].ansText.imageList.push(dir);
  2417. },
  2418. });
  2419. } else {
  2420. const dir = await self.uploadFile(img, 0);
  2421. this.questionList[bankindex].jsonStr[
  2422. ansindex
  2423. ].ansText.imageList.push(dir);
  2424. }
  2425. },
  2426. });
  2427. },
  2428. });
  2429. },
  2430. uploadFile(options, int) {
  2431. var self = this;
  2432. return new Promise((resolve, reject) => {
  2433. var data = {
  2434. orderGoodsId: this.orderGoodsId,
  2435. imageStatus: int,
  2436. };
  2437. self.$api.aliyunpolicy(data).then((res) => {
  2438. console.log(res.data, 6);
  2439. if (res.data.code != 200) {
  2440. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  2441. return;
  2442. }
  2443. var ossToken = res.data.data.resultContent;
  2444. if (ossToken.host == null || ossToken.host == undefined) {
  2445. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  2446. return;
  2447. }
  2448. uni.uploadFile({
  2449. url: ossToken.host,
  2450. name: "file",
  2451. filePath: options,
  2452. fileType: "image",
  2453. header: {
  2454. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  2455. },
  2456. formData: {
  2457. key: ossToken.dir,
  2458. OSSAccessKeyId: ossToken.accessid,
  2459. policy: ossToken.policy,
  2460. Signature: ossToken.signature,
  2461. callback: ossToken.callback,
  2462. success_action_status: 200,
  2463. },
  2464. success: (result) => {
  2465. // if (result.statusCode === 200) {
  2466. resolve(ossToken.dir);
  2467. // } else {
  2468. // uni.showToast({
  2469. // title: "上传失败",
  2470. // icon: "none",
  2471. // });
  2472. // return;
  2473. // }
  2474. },
  2475. fail: (error) => {
  2476. uni.showToast({
  2477. title: "上传接口报错" + error,
  2478. icon: "none",
  2479. });
  2480. return;
  2481. },
  2482. });
  2483. });
  2484. });
  2485. },
  2486. /**
  2487. * @param {Object} type
  2488. * @param {Object} bankindex
  2489. * 简答题答案确认
  2490. */
  2491. submitAns(bankindex) {
  2492. if (
  2493. !this.questionList[bankindex].ansText.text &&
  2494. !this.questionList[bankindex].ansText.imageList.length
  2495. ) {
  2496. uni.showToast({
  2497. title: "请输入内容或上传图片",
  2498. duration: 2000,
  2499. icon: "none",
  2500. });
  2501. return;
  2502. }
  2503. this.$set(this.questionList[bankindex], "ques", {
  2504. imageList: this.questionList[bankindex].ansText.imageList || [],
  2505. text: this.questionList[bankindex].ansText.text || "",
  2506. });
  2507. this.$u.toast("已确认答案");
  2508. this.isDoOver();
  2509. },
  2510. /**
  2511. * @param {Object} bankindex
  2512. * @param {Object} ansindex
  2513. * 案例题简答答案确认
  2514. */
  2515. submitAnsChild(bankindex, ansindex) {
  2516. if (
  2517. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2518. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2519. ) {
  2520. uni.showToast({
  2521. title: "请输入内容或上传图片",
  2522. duration: 2000,
  2523. icon: "none",
  2524. });
  2525. return;
  2526. }
  2527. this.$set(this.questionList[bankindex].ques, ansindex, {
  2528. imageList:
  2529. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
  2530. [],
  2531. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
  2532. });
  2533. this.$u.toast("已确认答案");
  2534. this.isDoOver();
  2535. },
  2536. isCheck(item, index) {
  2537. if (this.questionList[index].ques) {
  2538. return true;
  2539. }
  2540. },
  2541. isRight(item, index) {
  2542. //单选
  2543. if (this.questionList[index].ques) {
  2544. if (item.type == 1) {
  2545. return this.questionList[index].ques == this.questionList[index].ans;
  2546. //多选
  2547. } else if (item.type == 2) {
  2548. //每一项都相等
  2549. return this.questionList[index].ans.every((item, i) => {
  2550. return item == this.questionList[index].ques[i];
  2551. });
  2552. //判断
  2553. } else if (item.type == 3) {
  2554. return this.questionList[index].ques == this.questionList[index].ans;
  2555. // } else if (item.type == 5) {
  2556. // if(this.questionList[index].ques.text){
  2557. // return true
  2558. // }else{
  2559. // return false
  2560. // }
  2561. } else {
  2562. return false;
  2563. }
  2564. } else {
  2565. return false;
  2566. }
  2567. },
  2568. right(bankIndex, ansIndex, option) {
  2569. if (
  2570. this.questionList[bankIndex].ques[ansIndex] &&
  2571. this.questionList[bankIndex].ans[ansIndex]
  2572. ) {
  2573. if (
  2574. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2575. option.optionsId
  2576. ) != -1 ||
  2577. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2578. option.optionsId
  2579. ) != -1
  2580. ) {
  2581. return true;
  2582. } else {
  2583. return false;
  2584. }
  2585. } else {
  2586. return false;
  2587. }
  2588. },
  2589. wrong(bankIndex, ansIndex, option) {
  2590. if (
  2591. this.questionList[bankIndex].ques[ansIndex] &&
  2592. this.questionList[bankIndex].ans[ansIndex]
  2593. ) {
  2594. if (
  2595. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2596. option.optionsId
  2597. ) != -1 &&
  2598. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2599. option.optionsId
  2600. ) == -1
  2601. ) {
  2602. return true;
  2603. } else {
  2604. return false;
  2605. }
  2606. } else {
  2607. return false;
  2608. }
  2609. },
  2610. isWrong(item, index) {
  2611. if (this.questionList[index].ques) {
  2612. //单选
  2613. if (item.type == 1) {
  2614. return this.questionList[index].ques != this.questionList[index].ans;
  2615. //多选
  2616. } else if (item.type == 2) {
  2617. //每一项都相等
  2618. return this.questionList[index].ques.some((item, i) => {
  2619. return this.questionList[index].ans.indexOf(item) == -1;
  2620. });
  2621. //判断
  2622. } else if (item.type == 3) {
  2623. return this.questionList[index].ques != this.questionList[index].ans;
  2624. } else {
  2625. return false;
  2626. }
  2627. } else {
  2628. return false;
  2629. }
  2630. },
  2631. isPart(item, index) {
  2632. if (this.questionList[index].ques) {
  2633. if (item.type == 2) {
  2634. let isWrong = this.questionList[index].ques.some((item, i) => {
  2635. return this.questionList[index].ans.indexOf(item) == -1;
  2636. });
  2637. let isRight = this.questionList[index].ans.every((item, i) => {
  2638. return item == this.questionList[index].ques[i];
  2639. });
  2640. if (!isRight && !isWrong) {
  2641. return true;
  2642. }
  2643. }
  2644. } else {
  2645. return false;
  2646. }
  2647. },
  2648. isOver(item, index) {
  2649. if (this.questionList[index].ques) {
  2650. if (item.type == 4) {
  2651. //案例题
  2652. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2653. if (
  2654. jsonItem.type == 1 ||
  2655. jsonItem.type == 2 ||
  2656. jsonItem.type == 3
  2657. ) {
  2658. if (item.ques[indexs]) {
  2659. return true;
  2660. } else {
  2661. return false;
  2662. }
  2663. } else if (jsonItem.type == 5) {
  2664. if (
  2665. item.ques[indexs] &&
  2666. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2667. ) {
  2668. console.log("chil");
  2669. return true;
  2670. } else {
  2671. return false;
  2672. }
  2673. }
  2674. });
  2675. if (isOver) {
  2676. return true;
  2677. } else {
  2678. return false;
  2679. }
  2680. } else if (item.type == 5) {
  2681. //简答题
  2682. //每一项都相等
  2683. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2684. return true;
  2685. }
  2686. //判断
  2687. } else {
  2688. return false;
  2689. }
  2690. } else {
  2691. return false;
  2692. }
  2693. },
  2694. tabSelect(index, bankindex) {
  2695. this.$set(this.questionList[bankindex], "current", index);
  2696. },
  2697. showPhoto(contentStr) {
  2698. if (contentStr && typeof contentStr == "string") {
  2699. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  2700. let strArr = contentStr.match(reg);
  2701. strArr.forEach((str, index) => {
  2702. strArr[index] = str.replace(reg, "$1");
  2703. });
  2704. // 预览图片
  2705. uni.previewImage({
  2706. urls: strArr,
  2707. longPressActions: {
  2708. itemList: ["发送给朋友", "保存图片", "收藏"],
  2709. success: function (data) {
  2710. console.log(
  2711. "选中了第" +
  2712. (data.tapIndex + 1) +
  2713. "个按钮,第" +
  2714. (data.index + 1) +
  2715. "张图片"
  2716. );
  2717. },
  2718. fail: function (err) {
  2719. console.log(err.errMsg);
  2720. },
  2721. },
  2722. });
  2723. }
  2724. },
  2725. },
  2726. computed: {
  2727. doMode() {
  2728. // 做题模式 1章卷 2随机练习 3模拟组卷
  2729. return this.examData.simulateStatus
  2730. ? 3
  2731. : this.entryType == "random"
  2732. ? 2
  2733. : 1;
  2734. },
  2735. },
  2736. };
  2737. </script>
  2738. <style lang="scss" scoped>
  2739. .questionBank {
  2740. width: 100%;
  2741. height: 100vh;
  2742. display: flex;
  2743. flex-direction: column;
  2744. }
  2745. .swiper {
  2746. width: 100%;
  2747. flex: 1;
  2748. }
  2749. .lisSty {
  2750. margin-bottom: 16rpx;
  2751. display: flex;
  2752. align-items: center;
  2753. .flex_auto {
  2754. word-break: break-all;
  2755. flex: 1;
  2756. }
  2757. }
  2758. .activeTI {
  2759. vertical-align: middle;
  2760. display: inline-block;
  2761. border: 1rpx solid #eee;
  2762. border-radius: 50rpx;
  2763. height: 48rpx;
  2764. line-height: 46rpx;
  2765. text-align: center;
  2766. width: 48rpx;
  2767. margin-right: 15rpx;
  2768. color: #666;
  2769. font-size: 30rpx;
  2770. &.right {
  2771. color: #fff;
  2772. background: #36c75a;
  2773. }
  2774. &.wrong {
  2775. color: #fff;
  2776. background: #ff3b30;
  2777. }
  2778. &.checked,
  2779. &.user_choose {
  2780. color: #fff;
  2781. background: #007aff;
  2782. }
  2783. }
  2784. .submit_checkbox {
  2785. position: fixed;
  2786. left: 0;
  2787. right: 0;
  2788. bottom: 120rpx;
  2789. margin: 20rpx auto;
  2790. width: 526rpx;
  2791. height: 80rpx;
  2792. background: rgba(0, 122, 255, 1);
  2793. color: #fff;
  2794. text-align: center;
  2795. line-height: 80rpx;
  2796. font-size: 30rpx;
  2797. border-radius: 40rpx;
  2798. &.disabled {
  2799. opacity: 0.6;
  2800. }
  2801. }
  2802. .titles {
  2803. overflow: hidden;
  2804. margin-bottom: 24rpx;
  2805. }
  2806. .titBox {
  2807. padding: 41rpx 25rpx 24rpx 25rpx;
  2808. }
  2809. .titBox_title {
  2810. padding: 21rpx;
  2811. }
  2812. .tabs {
  2813. margin: 10rpx;
  2814. display: flex;
  2815. .tab {
  2816. margin: 0 4rpx;
  2817. padding: 10rpx 13rpx;
  2818. text-align: center;
  2819. color: #007aff;
  2820. font-size: 28rpx;
  2821. border-radius: 16rpx;
  2822. background: #fff;
  2823. &.current {
  2824. color: #fff;
  2825. background: #007aff;
  2826. }
  2827. }
  2828. }
  2829. .ans {
  2830. margin: 8rpx 8rpx 8rpx;
  2831. .ans_input {
  2832. border-radius: 16rpx;
  2833. background: #fff;
  2834. .top {
  2835. border-bottom: 1rpx solid #eeeeee;
  2836. padding: 16rpx;
  2837. display: flex;
  2838. align-items: center;
  2839. .icon {
  2840. margin-right: 20rpx;
  2841. width: 40rpx;
  2842. height: 38rpx;
  2843. }
  2844. .progress {
  2845. flex: 1;
  2846. }
  2847. .submit {
  2848. width: 168rpx;
  2849. height: 48rpx;
  2850. line-height: 48rpx;
  2851. text-align: center;
  2852. color: #fff;
  2853. font-size: 30rpx;
  2854. background: #007aff;
  2855. border-radius: 24rpx;
  2856. &.disabled {
  2857. opacity: 0.6;
  2858. }
  2859. }
  2860. }
  2861. .textarea {
  2862. textarea {
  2863. width: 100%;
  2864. height: 287rpx;
  2865. padding: 10rpx;
  2866. }
  2867. }
  2868. .imgs {
  2869. overflow: hidden;
  2870. display: flex;
  2871. width: 100%;
  2872. .img {
  2873. width: 104rpx;
  2874. height: 104rpx;
  2875. border-radius: 8rpx;
  2876. position: relative;
  2877. margin: 20rpx;
  2878. text {
  2879. position: absolute;
  2880. right: -15rpx;
  2881. top: -15rpx;
  2882. width: 30rpx;
  2883. height: 30rpx;
  2884. text-align: center;
  2885. line-height: 30rpx;
  2886. color: #fff;
  2887. background: #ff3b30;
  2888. border-radius: 50%;
  2889. }
  2890. image {
  2891. width: 100%;
  2892. height: 100%;
  2893. }
  2894. }
  2895. }
  2896. }
  2897. .ans_submit {
  2898. padding: 16rpx;
  2899. border-radius: 16rpx;
  2900. background: #fff;
  2901. .imgs {
  2902. overflow: hidden;
  2903. display: flex;
  2904. width: 100%;
  2905. .img {
  2906. width: 104rpx;
  2907. height: 104rpx;
  2908. border-radius: 8rpx;
  2909. position: relative;
  2910. margin: 20rpx;
  2911. image {
  2912. width: 100%;
  2913. height: 100%;
  2914. }
  2915. }
  2916. }
  2917. }
  2918. }
  2919. .leftLetters {
  2920. display: flex;
  2921. align-items: center;
  2922. width: 220rpx;
  2923. .btnType {
  2924. padding: 5rpx 10rpx;
  2925. border: 1rpx solid #007aff;
  2926. border-radius: 10rpx;
  2927. background-color: rgba(0, 122, 255, 0.1);
  2928. font-size: 28rpx;
  2929. color: #007aff;
  2930. margin-right: 15rpx;
  2931. }
  2932. }
  2933. .firstLetter {
  2934. display: flex;
  2935. justify-content: space-between;
  2936. align-items: center;
  2937. margin-bottom: 30rpx;
  2938. }
  2939. .popupView {
  2940. height: 100%;
  2941. padding-bottom: 100rpx;
  2942. .popupTops {
  2943. height: 77rpx;
  2944. border-bottom: 1rpx solid #eee;
  2945. text-align: center;
  2946. line-height: 77rpx;
  2947. font-size: 24rpx;
  2948. color: #999;
  2949. position: relative;
  2950. .topIcon {
  2951. position: absolute;
  2952. top: 10rpx;
  2953. left: 50%;
  2954. transform: translateX(-50%);
  2955. width: 80rpx;
  2956. height: 8rpx;
  2957. background-color: #999;
  2958. border-radius: 4rpx;
  2959. }
  2960. }
  2961. .popupContent {
  2962. }
  2963. }
  2964. .pageContent {
  2965. position: relative;
  2966. background-color: #eaeef1;
  2967. height: 100%;
  2968. padding-top: 8rpx;
  2969. padding-bottom: 100rpx;
  2970. overflow-y: scroll;
  2971. }
  2972. .pad_8 {
  2973. background-color: #fff;
  2974. margin: 0rpx 8rpx 8rpx;
  2975. border-radius: 16rpx;
  2976. &.no-margin {
  2977. margin-top: -16rpx;
  2978. border-radius: 0 0 16rpx 16rpx;
  2979. }
  2980. }
  2981. .answer {
  2982. height: 80rpx;
  2983. line-height: 80rpx;
  2984. padding: 0rpx 24rpx;
  2985. display: flex;
  2986. align-items: center;
  2987. justify-content: space-between;
  2988. color: #666;
  2989. font-size: 30rpx;
  2990. }
  2991. .footer_btn {
  2992. background-color: #fff;
  2993. z-index: 10078;
  2994. position: fixed;
  2995. bottom: 0rpx;
  2996. display: flex;
  2997. align-items: center;
  2998. justify-content: space-between;
  2999. width: 100%;
  3000. height: 98rpx;
  3001. padding: 0rpx 38rpx;
  3002. border-top: 1rpx solid #eee;
  3003. .flex_center {
  3004. flex: 1;
  3005. display: flex;
  3006. justify-content: center;
  3007. align-items: center;
  3008. flex-direction: column;
  3009. margin: 0 200rpx;
  3010. font-size: 24rpx;
  3011. color: #999999;
  3012. .up-icon {
  3013. margin-bottom: 18rpx;
  3014. width: 100%;
  3015. display: flex;
  3016. justify-content: center;
  3017. image {
  3018. width: 58rpx;
  3019. height: 21rpx;
  3020. }
  3021. }
  3022. }
  3023. .collect {
  3024. visibility: hidden;
  3025. width: 100rpx;
  3026. &.show {
  3027. visibility: visible;
  3028. }
  3029. > view {
  3030. display: flex;
  3031. flex-direction: column;
  3032. align-items: center;
  3033. justify-content: center;
  3034. image {
  3035. width: 32rpx;
  3036. height: 32rpx;
  3037. margin-bottom: 6rpx;
  3038. }
  3039. view {
  3040. font-size: 24rpx;
  3041. color: #999999;
  3042. }
  3043. }
  3044. }
  3045. }
  3046. .boxSty {
  3047. padding: 44rpx 41rpx 0rpx;
  3048. }
  3049. .liListSty {
  3050. border: 1rpx solid #eeeeee;
  3051. width: 88rpx;
  3052. height: 88rpx;
  3053. border-radius: 32rpx;
  3054. text-align: center;
  3055. line-height: 88rpx;
  3056. color: #333;
  3057. font-size: 32rpx;
  3058. float: left;
  3059. margin: 20rpx 23rpx;
  3060. &.isRight {
  3061. border: 1rpx solid #eeeeee;
  3062. color: #fff;
  3063. background: #36c75a;
  3064. }
  3065. &.isWrong {
  3066. border: 1rpx solid #eeeeee;
  3067. color: #fff;
  3068. background: #ff3b30;
  3069. }
  3070. &.isPart {
  3071. border: 1rpx solid #eeeeee;
  3072. color: #fff;
  3073. background: #ffc53d;
  3074. }
  3075. &.isOver {
  3076. border: 1rpx solid #eeeeee;
  3077. color: #fff;
  3078. background: blue;
  3079. }
  3080. &.check_ans {
  3081. border: 1rpx solid #eeeeee;
  3082. color: #fff;
  3083. background: #007aff;
  3084. }
  3085. }
  3086. .answerInfos {
  3087. padding: 25rpx 25rpx 25rpx 23rpx;
  3088. }
  3089. .answerTitle {
  3090. margin-bottom: 28rpx;
  3091. color: #666;
  3092. font-size: 30rpx;
  3093. }
  3094. .answerContent {
  3095. font-size: 30rpx;
  3096. color: #666;
  3097. }
  3098. .textChild {
  3099. display: inline-block;
  3100. vertical-align: middle;
  3101. }
  3102. .dialog {
  3103. position: fixed;
  3104. left: 0;
  3105. top: 0;
  3106. width: 100%;
  3107. height: 100%;
  3108. background-color: rgba(0, 0, 0, 0.8);
  3109. display: flex;
  3110. flex-direction: column;
  3111. align-items: center;
  3112. justify-content: center;
  3113. z-index: 20000;
  3114. .pointer {
  3115. width: 338rpx;
  3116. height: 240rpx;
  3117. }
  3118. .text {
  3119. font-size: 32rpx;
  3120. color: #ffffff;
  3121. text-align: center;
  3122. }
  3123. .btn {
  3124. width: 242rpx;
  3125. height: 82rpx;
  3126. border: 2rpx solid #ffffff;
  3127. border-radius: 16rpx;
  3128. text-align: center;
  3129. line-height: 82rpx;
  3130. margin: 41rpx auto;
  3131. color: #fff;
  3132. font-size: 32rpx;
  3133. }
  3134. }
  3135. .dialog-arrow {
  3136. padding-top: 124rpx;
  3137. position: fixed;
  3138. left: 0;
  3139. top: 0;
  3140. width: 100%;
  3141. height: 100%;
  3142. background-color: rgba(0, 0, 0, 0.8);
  3143. z-index: 20000;
  3144. .pointer {
  3145. margin-left: 87rpx;
  3146. display: block;
  3147. width: 95rpx;
  3148. height: 98rpx;
  3149. }
  3150. .text {
  3151. padding-left: 177rpx;
  3152. font-size: 32rpx;
  3153. color: #ffffff;
  3154. }
  3155. .btn {
  3156. width: 242rpx;
  3157. height: 82rpx;
  3158. border: 2rpx solid #ffffff;
  3159. border-radius: 16rpx;
  3160. text-align: center;
  3161. line-height: 82rpx;
  3162. margin: 500rpx auto 0;
  3163. color: #fff;
  3164. font-size: 32rpx;
  3165. }
  3166. }
  3167. .dialog_wrap {
  3168. position: fixed;
  3169. left: 0;
  3170. top: 0;
  3171. width: 100%;
  3172. height: 100%;
  3173. z-index: 9999999999;
  3174. .bg {
  3175. background: rgba(0, 0, 0, 0.3);
  3176. position: absolute;
  3177. left: 0;
  3178. top: 0;
  3179. width: 100%;
  3180. height: 100%;
  3181. }
  3182. .dialog {
  3183. position: absolute;
  3184. left: 50%;
  3185. top: 50%;
  3186. transform: translate3D(-50%, -50%, 0);
  3187. width: 640rpx;
  3188. height: 439rpx;
  3189. background: #ffffff;
  3190. border-radius: 24rpx;
  3191. .title {
  3192. font-size: 30rpx;
  3193. font-weight: bold;
  3194. color: #333333;
  3195. line-height: 48rpx;
  3196. text-align: center;
  3197. margin-top: 40rpx;
  3198. }
  3199. .content {
  3200. margin: 35rpx 35rpx 0;
  3201. font-size: 30rpx;
  3202. color: #666666;
  3203. line-height: 48rpx;
  3204. }
  3205. .btns {
  3206. margin-top: 35rpx;
  3207. display: flex;
  3208. align-items: center;
  3209. justify-content: center;
  3210. .btn {
  3211. width: 200rpx;
  3212. height: 80rpx;
  3213. line-height: 80rpx;
  3214. text-align: center;
  3215. background: #f5f5f5;
  3216. border-radius: 40rpx;
  3217. font-size: 30rpx;
  3218. color: rgba(0, 122, 255, 1);
  3219. background: #f5f5f5;
  3220. margin: 0 20rpx;
  3221. &.active {
  3222. color: #f5f5f5;
  3223. background: rgba(0, 122, 255, 1);
  3224. }
  3225. }
  3226. }
  3227. }
  3228. }
  3229. .popboxs {
  3230. width: 100%;
  3231. height: 100%;
  3232. display: flex;
  3233. flex-direction: column;
  3234. align-items: center;
  3235. }
  3236. .classTops {
  3237. flex-shrink: 0;
  3238. padding: 39rpx 0rpx 4rpx;
  3239. font-weight: bold;
  3240. color: #333;
  3241. font-size: 30rpx;
  3242. }
  3243. .textStys {
  3244. width: 100%;
  3245. flex: 1;
  3246. padding: 36rpx;
  3247. }
  3248. .classFootsty {
  3249. flex-shrink: 0;
  3250. display: flex;
  3251. align-items: center;
  3252. justify-content: center;
  3253. padding: 10rpx 0rpx 40rpx;
  3254. .btnsty {
  3255. width: 200rpx;
  3256. height: 80rpx;
  3257. border-radius: 40rpx;
  3258. font-weight: bold;
  3259. font-size: 30rpx;
  3260. text-align: center;
  3261. line-height: 80rpx;
  3262. }
  3263. .btns1 {
  3264. background-color: #f5f5f5;
  3265. color: #007aff;
  3266. }
  3267. .btns2 {
  3268. margin-left: 40rpx;
  3269. background-color: #007aff;
  3270. color: #ffffff;
  3271. }
  3272. }
  3273. </style>