questionBank.vue 100 KB

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