index.vue 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101
  1. <template>
  2. <div class="course-exam">
  3. <Header></Header>
  4. <section class="section">
  5. <div class="container">
  6. <div class="section__header">
  7. <!-- <el-breadcrumb separator="/">
  8. <el-breadcrumb-item
  9. v-for="(item, index) in $route.matched"
  10. :key="index"
  11. :to="{ path: item.path }"
  12. >{{ item.name }}</el-breadcrumb-item
  13. >
  14. </el-breadcrumb> -->
  15. </div>
  16. <div class="section__body">
  17. <div class="explain-record">
  18. <div class="explain-record__body">
  19. <div class="left-box">
  20. <Header-tab-box
  21. :num="questionOverNum(true)"
  22. @prevQuestion="prevQuestion"
  23. @nextQuestion="nextQuestion"
  24. ></Header-tab-box>
  25. <div class="left-box__body">
  26. <template v-for="(question, questionIndex) in questionList">
  27. <div
  28. class="question"
  29. v-if="question.type == 1 && current == questionIndex"
  30. :key="questionIndex"
  31. >
  32. <div class="question__title">
  33. {{ questionIndex + 1 }}、单选题
  34. </div>
  35. <div
  36. class="question__desc"
  37. v-html="question.content"
  38. ></div>
  39. <div class="question__content">
  40. <div class="question-list" v-if="!question.ques">
  41. <div
  42. class="radio"
  43. v-for="(item, index) in question.jsonStr"
  44. :key="index"
  45. @click="
  46. radioSelect(
  47. question,
  48. questionIndex,
  49. item.optionsId
  50. )
  51. "
  52. >
  53. <div>
  54. {{ ast[index] }}. {{ item.content }}
  55. <div v-if="item.imgUrl">
  56. <img
  57. style="max-width: 100%"
  58. :src="$tools.splitImgHost(item.imgUrl)"
  59. alt=""
  60. />
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="question-list" v-if="question.ques">
  66. <div
  67. class="radio"
  68. :class="{
  69. right:
  70. bankType == 1 &&
  71. (item.optionsId == question.ques ||
  72. item.optionsId == question.ans),
  73. wrong:
  74. bankType == 1 &&
  75. item.optionsId == question.ques &&
  76. question.ques != question.ans,
  77. user_choose:
  78. bankType == 2 &&
  79. item.optionsId == question.ques,
  80. }"
  81. v-for="(item, index) in question.jsonStr"
  82. :key="index"
  83. @click="
  84. radioSelect(
  85. question,
  86. questionIndex,
  87. item.optionsId
  88. )
  89. "
  90. >
  91. <div>
  92. {{ ast[index] }}. {{ item.content }}
  93. <div v-if="item.imgUrl">
  94. <img
  95. style="max-width: 100%"
  96. :src="$tools.splitImgHost(item.imgUrl)"
  97. alt=""
  98. />
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <div
  104. class="answer-list"
  105. v-if="bankType == 1 && question.ques"
  106. >
  107. <div class="answer-list__left">
  108. 正确答案:{{ ast[question.ans - 1] }}
  109. </div>
  110. <div class="answer-list__left">
  111. 我的答案:{{ ast[question.ques - 1] }}
  112. </div>
  113. </div>
  114. <div
  115. class="explain-list"
  116. v-if="bankType == 1 && question.ques"
  117. >
  118. <div class="explain-list__header">答案解析:</div>
  119. <div
  120. class="explain-list__body"
  121. v-html="question.analysisContent"
  122. ></div>
  123. </div>
  124. </div>
  125. </div>
  126. <div
  127. class="question"
  128. v-if="question.type == 2 && current == questionIndex"
  129. :key="questionIndex"
  130. >
  131. <div class="question__title">
  132. {{ questionIndex + 1 }}、多选题
  133. </div>
  134. <div
  135. class="question__desc"
  136. v-html="question.content"
  137. ></div>
  138. <div class="question__content">
  139. <div class="question-list" v-if="!question.ques">
  140. <el-checkbox
  141. class="checkbox"
  142. v-for="(item, index) in question.jsonStr"
  143. :key="index"
  144. :label="item.optionsId"
  145. v-model="item.checked"
  146. >
  147. <div>
  148. {{ ast[index] }}. {{ item.content }}
  149. <div v-if="item.imgUrl">
  150. <img
  151. style="max-width: 100%"
  152. :src="$tools.splitImgHost(item.imgUrl)"
  153. alt=""
  154. />
  155. </div>
  156. </div>
  157. </el-checkbox>
  158. </div>
  159. <div class="question-list" v-if="question.ques">
  160. <el-checkbox
  161. :disabled="bankType == 2 ? false : true"
  162. class="checkbox"
  163. :class="{
  164. right:
  165. bankType == 1 &&
  166. (question.ques.indexOf(item.optionsId) != -1 ||
  167. question.ans.indexOf(item.optionsId) != -1),
  168. wrong:
  169. bankType == 1 &&
  170. question.ques.indexOf(item.optionsId) != -1 &&
  171. question.ans.indexOf(item.optionsId) == -1,
  172. user_choose:
  173. bankType == 2 &&
  174. question.ques.indexOf(item.optionsId) != -1,
  175. }"
  176. v-for="(item, index) in question.jsonStr"
  177. :key="index"
  178. :label="item.optionsId"
  179. v-model="item.checked"
  180. >
  181. <div>
  182. {{ ast[index] }}. {{ item.content }}
  183. <div v-if="item.imgUrl">
  184. <img
  185. style="max-width: 100%"
  186. :src="$tools.splitImgHost(item.imgUrl)"
  187. alt=""
  188. />
  189. </div>
  190. </div>
  191. </el-checkbox>
  192. </div>
  193. <div
  194. class="answer-list"
  195. v-if="bankType == 1 && question.ques"
  196. >
  197. <div class="answer-list__left">
  198. 正确答案:
  199. <template v-for="ansItem in question.ans">{{
  200. ast[ansItem - 1]
  201. }}</template>
  202. </div>
  203. <div class="answer-list__left">
  204. 我的答案:
  205. <template v-for="quesItem in question.ques">{{
  206. ast[quesItem - 1]
  207. }}</template>
  208. </div>
  209. </div>
  210. <div
  211. class="explain-list"
  212. v-if="bankType == 1 && question.ques"
  213. >
  214. <div class="explain-list__header">答案解析:</div>
  215. <div
  216. class="explain-list__body"
  217. v-html="question.analysisContent"
  218. ></div>
  219. </div>
  220. </div>
  221. <div class="question__btns">
  222. <div
  223. v-if="
  224. bankType == 2 || (bankType == 1 && !question.ques)
  225. "
  226. class="submit"
  227. @click="checkboxSubmit(question, questionIndex)"
  228. >
  229. 确认答案
  230. </div>
  231. </div>
  232. </div>
  233. <div
  234. class="question"
  235. v-if="question.type == 3 && current == questionIndex"
  236. :key="questionIndex"
  237. >
  238. <div class="question__title">
  239. {{ questionIndex + 1 }}、判断题
  240. </div>
  241. <div
  242. class="question__desc"
  243. v-html="question.content"
  244. ></div>
  245. <div class="question__content">
  246. <div class="question-list" v-if="!question.ques">
  247. <div
  248. class="radio"
  249. v-for="(item, index) in judge"
  250. :key="index"
  251. @click="judgeSelect(question, questionIndex, index)"
  252. >
  253. <div>
  254. {{ ast[index] }}. {{ item }}
  255. <div v-if="item.imgUrl">
  256. <img
  257. style="max-width: 100%"
  258. :src="$tools.splitImgHost(item.imgUrl)"
  259. alt=""
  260. />
  261. </div>
  262. </div>
  263. </div>
  264. </div>
  265. <div class="question-list" v-if="question.ques">
  266. <div
  267. class="radio"
  268. :class="{
  269. right:
  270. bankType == 1 &&
  271. (index == (question.ques == 1 ? 0 : 1) ||
  272. index != question.ans),
  273. wrong:
  274. bankType == 1 &&
  275. index == (question.ques == 1 ? 0 : 1) &&
  276. question.ques != question.ans,
  277. user_choose:
  278. bankType == 2 &&
  279. index == (question.ques == 1 ? 0 : 1),
  280. }"
  281. v-for="(item, index) in judge"
  282. :key="index"
  283. @click="judgeSelect(question, questionIndex, index)"
  284. >
  285. <div>
  286. {{ ast[index] }}. {{ item }}
  287. <div v-if="item.imgUrl">
  288. <img
  289. style="max-width: 100%"
  290. :src="$tools.splitImgHost(item.imgUrl)"
  291. alt=""
  292. />
  293. </div>
  294. </div>
  295. </div>
  296. </div>
  297. <div
  298. class="answer-list"
  299. v-if="bankType == 1 && question.ques"
  300. >
  301. <div class="answer-list__left">
  302. 正确答案:{{ ast[question.ans == 1 ? 0 : 1] }}
  303. </div>
  304. <div class="answer-list__left">
  305. 我的答案:{{ ast[question.ques == 1 ? 0 : 1] }}
  306. </div>
  307. </div>
  308. <div
  309. class="explain-list"
  310. v-if="bankType == 1 && question.ques"
  311. >
  312. <div class="explain-list__header">答案解析:</div>
  313. <div
  314. class="explain-list__body"
  315. v-html="question.analysisContent"
  316. ></div>
  317. </div>
  318. </div>
  319. </div>
  320. <div
  321. class="question"
  322. v-if="question.type == 4 && current == questionIndex"
  323. :key="questionIndex"
  324. >
  325. <div class="question__title">
  326. {{ questionIndex + 1 }}、案例题
  327. </div>
  328. <div
  329. class="question__desc"
  330. v-html="question.content"
  331. ></div>
  332. <div class="question__content">
  333. <el-tabs v-model="question.tabIndex">
  334. <el-tab-pane
  335. v-for="(json, jsonIndex) in question.jsonStr"
  336. :label="'问题' + (jsonIndex + 1)"
  337. :name="jsonIndex + ''"
  338. :key="jsonIndex"
  339. >
  340. <div
  341. class="question"
  342. v-if="json.type == 1"
  343. :key="questionIndex"
  344. >
  345. <div class="question__title">
  346. {{ jsonIndex + 1 }}、单选题
  347. </div>
  348. <div
  349. class="question__desc"
  350. v-html="json.content"
  351. ></div>
  352. <div class="question__content">
  353. <div
  354. class="question-list"
  355. v-if="!question.ques[jsonIndex]"
  356. >
  357. <div
  358. class="radio"
  359. v-for="(item, index) in json.optionsList"
  360. :key="index"
  361. @click="
  362. radioSelectChild(
  363. questionIndex,
  364. jsonIndex,
  365. item.optionsId
  366. )
  367. "
  368. >
  369. <div>
  370. {{ ast[index] }}. {{ item.content }}
  371. <div v-if="item.imgUrl">
  372. <img
  373. style="max-width: 100%"
  374. :src="
  375. $tools.splitImgHost(item.imgUrl)
  376. "
  377. alt=""
  378. />
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. <div
  384. class="question-list"
  385. v-if="question.ques[jsonIndex]"
  386. >
  387. <div
  388. class="radio"
  389. :class="{
  390. right:
  391. bankType == 1 &&
  392. (item.optionsId ==
  393. question.ques[jsonIndex] ||
  394. item.optionsId ==
  395. question.ans[jsonIndex]),
  396. wrong:
  397. bankType == 1 &&
  398. item.optionsId ==
  399. question.ques[jsonIndex] &&
  400. question.ques[jsonIndex] !=
  401. question.ans[jsonIndex],
  402. user_choose:
  403. bankType == 2 &&
  404. item.optionsId ==
  405. question.ques[jsonIndex],
  406. }"
  407. v-for="(item, index) in json.optionsList"
  408. :key="index"
  409. @click="
  410. radioSelectChild(
  411. questionIndex,
  412. jsonIndex,
  413. item.optionsId
  414. )
  415. "
  416. >
  417. <div>
  418. {{ ast[index] }}. {{ item.content }}
  419. <div v-if="item.imgUrl">
  420. <img
  421. style="max-width: 100%"
  422. :src="
  423. $tools.splitImgHost(item.imgUrl)
  424. "
  425. alt=""
  426. />
  427. </div>
  428. </div>
  429. </div>
  430. </div>
  431. <div
  432. class="answer-list"
  433. v-if="
  434. bankType == 1 && question.ques[jsonIndex]
  435. "
  436. >
  437. <div class="answer-list__left">
  438. 正确答案:{{
  439. ast[question.ans[jsonIndex] - 1]
  440. }}
  441. </div>
  442. <div class="answer-list__left">
  443. 我的答案:{{
  444. ast[question.ques[jsonIndex] - 1]
  445. }}
  446. </div>
  447. </div>
  448. <div
  449. class="explain-list"
  450. v-if="
  451. bankType == 1 && question.ques[jsonIndex]
  452. "
  453. >
  454. <div class="explain-list__header">
  455. 答案解析:
  456. </div>
  457. <div
  458. class="explain-list__body"
  459. v-html="json.analysisContent"
  460. ></div>
  461. </div>
  462. </div>
  463. <div class="question__btns"></div>
  464. </div>
  465. <div
  466. class="question"
  467. v-if="json.type == 2"
  468. :key="jsonIndex"
  469. >
  470. <div class="question__title">
  471. {{ jsonIndex + 1 }}、多选题
  472. </div>
  473. <div
  474. class="question__desc"
  475. v-html="json.content"
  476. ></div>
  477. <div class="question__content">
  478. <div
  479. class="question-list"
  480. v-if="!question.ques[jsonIndex]"
  481. >
  482. <el-checkbox
  483. class="checkbox"
  484. v-for="(item, index) in json.optionsList"
  485. :key="index"
  486. :label="item.optionsId"
  487. v-model="item.checked"
  488. >
  489. <div>
  490. {{ ast[index] }}. {{ item.content }}
  491. <div v-if="item.imgUrl">
  492. <img
  493. style="max-width: 100%"
  494. :src="
  495. $tools.splitImgHost(item.imgUrl)
  496. "
  497. alt=""
  498. />
  499. </div>
  500. </div>
  501. </el-checkbox>
  502. </div>
  503. <div
  504. class="question-list"
  505. v-if="question.ques[jsonIndex]"
  506. >
  507. <el-checkbox
  508. :disabled="bankType == 2 ? false : true"
  509. class="checkbox"
  510. :class="{
  511. right:
  512. bankType == 1 &&
  513. (question.ques[jsonIndex].indexOf(
  514. item.optionsId
  515. ) != -1 ||
  516. question.ans[jsonIndex].indexOf(
  517. item.optionsId
  518. ) != -1),
  519. wrong:
  520. bankType == 1 &&
  521. question.ques[jsonIndex].indexOf(
  522. item.optionsId
  523. ) != -1 &&
  524. question.ans[jsonIndex].indexOf(
  525. item.optionsId
  526. ) == -1,
  527. user_choose:
  528. bankType == 2 &&
  529. question.ques[jsonIndex].indexOf(
  530. item.optionsId
  531. ) != -1,
  532. }"
  533. v-for="(item, index) in json.optionsList"
  534. :key="index"
  535. :label="item.optionsId"
  536. v-model="item.checked"
  537. >
  538. <div>
  539. {{ ast[index] }}. {{ item.content }}
  540. <div v-if="item.imgUrl">
  541. <img
  542. style="max-width: 100%"
  543. :src="
  544. $tools.splitImgHost(item.imgUrl)
  545. "
  546. alt=""
  547. />
  548. </div>
  549. </div>
  550. </el-checkbox>
  551. </div>
  552. <div
  553. class="answer-list"
  554. v-if="
  555. bankType == 1 && question.ques[jsonIndex]
  556. "
  557. >
  558. <div class="answer-list__left">
  559. 正确答案:
  560. <template
  561. v-for="ansItem in question.ans[jsonIndex]"
  562. >{{ ast[ansItem - 1] }}</template
  563. >
  564. </div>
  565. <div class="answer-list__left">
  566. 我的答案:
  567. <template
  568. v-for="quesItem in question.ques[
  569. jsonIndex
  570. ]"
  571. >{{ ast[quesItem - 1] }}</template
  572. >
  573. </div>
  574. </div>
  575. <div
  576. class="explain-list"
  577. v-if="
  578. bankType == 1 && question.ques[jsonIndex]
  579. "
  580. >
  581. <div class="explain-list__header">
  582. 答案解析:
  583. </div>
  584. <div
  585. class="explain-list__body"
  586. v-html="json.analysisContent"
  587. ></div>
  588. </div>
  589. </div>
  590. <div class="question__btns">
  591. <div
  592. v-if="
  593. bankType == 2 ||
  594. (bankType == 1 && !question.ques[jsonIndex])
  595. "
  596. class="submit"
  597. @click="
  598. checkboxSubmitChild(
  599. questionIndex,
  600. jsonIndex
  601. )
  602. "
  603. >
  604. 确认答案
  605. </div>
  606. </div>
  607. </div>
  608. <div
  609. class="question"
  610. v-if="json.type == 3"
  611. :key="jsonIndex"
  612. >
  613. <div class="question__title">
  614. {{ jsonIndex + 1 }}、判断题
  615. </div>
  616. <div
  617. class="question__desc"
  618. v-html="json.content"
  619. ></div>
  620. <div class="question__content">
  621. <div
  622. class="question-list"
  623. v-if="!question.ques[jsonIndex]"
  624. >
  625. <div
  626. class="radio"
  627. v-for="(item, index) in judge"
  628. :key="index"
  629. @click="
  630. judgeSelectChild(
  631. questionIndex,
  632. jsonIndex,
  633. index
  634. )
  635. "
  636. >
  637. <div>
  638. {{ ast[index] }}. {{ item }}
  639. <div v-if="item.imgUrl">
  640. <img
  641. style="max-width: 100%"
  642. :src="
  643. $tools.splitImgHost(item.imgUrl)
  644. "
  645. alt=""
  646. />
  647. </div>
  648. </div>
  649. </div>
  650. </div>
  651. <div
  652. class="question-list"
  653. v-if="question.ques[jsonIndex]"
  654. >
  655. <div
  656. class="radio"
  657. :class="{
  658. right:
  659. bankType == 1 &&
  660. (index ==
  661. (question.ques[jsonIndex] == 1
  662. ? 0
  663. : 1) ||
  664. index != question.ans[jsonIndex]),
  665. wrong:
  666. bankType == 1 &&
  667. index ==
  668. (question.ques[jsonIndex] == 1
  669. ? 0
  670. : 1) &&
  671. question.ques[jsonIndex] !=
  672. question.ans[jsonIndex],
  673. user_choose:
  674. bankType == 2 &&
  675. index ==
  676. (question.ques[jsonIndex] == 1
  677. ? 0
  678. : 1),
  679. }"
  680. v-for="(item, index) in judge"
  681. :key="index"
  682. @click="
  683. judgeSelectChild(
  684. questionIndex,
  685. jsonIndex,
  686. index
  687. )
  688. "
  689. >
  690. <div>
  691. {{ ast[index] }}. {{ item }}
  692. <div v-if="item.imgUrl">
  693. <img
  694. style="max-width: 100%"
  695. :src="
  696. $tools.splitImgHost(item.imgUrl)
  697. "
  698. alt=""
  699. />
  700. </div>
  701. </div>
  702. </div>
  703. </div>
  704. <div
  705. class="answer-list"
  706. v-if="
  707. bankType == 1 && question.ques[jsonIndex]
  708. "
  709. >
  710. <div class="answer-list__left">
  711. 正确答案:{{
  712. ast[question.ans[jsonIndex] == 1 ? 0 : 1]
  713. }}
  714. </div>
  715. <div class="answer-list__left">
  716. 我的答案:{{
  717. ast[question.ques[jsonIndex] == 1 ? 0 : 1]
  718. }}
  719. </div>
  720. </div>
  721. <div
  722. class="explain-list"
  723. v-if="
  724. bankType == 1 && question.ques[jsonIndex]
  725. "
  726. >
  727. <div class="explain-list__header">
  728. 答案解析:
  729. </div>
  730. <div
  731. class="explain-list__body"
  732. v-html="json.analysisContent"
  733. ></div>
  734. </div>
  735. </div>
  736. <div class="question__btns"></div>
  737. </div>
  738. <div
  739. class="question"
  740. v-if="json.type == 5"
  741. :key="jsonIndex"
  742. >
  743. <div class="question__title">
  744. {{ jsonIndex + 1 }}、简答题
  745. </div>
  746. <div
  747. class="question__desc"
  748. v-html="json.content"
  749. ></div>
  750. <div class="question__content">
  751. <div
  752. class="question-list textarea"
  753. v-if="
  754. bankType == 2 ||
  755. (bankType == 1 &&
  756. !(
  757. question.ques[jsonIndex] &&
  758. (question.ques[jsonIndex].imageList
  759. .length ||
  760. question.ques[jsonIndex].text)
  761. ))
  762. "
  763. >
  764. <el-input
  765. type="textarea"
  766. rows="5"
  767. v-model="json.ansText.text"
  768. resize="none"
  769. ></el-input>
  770. <div class="upload clearfix">
  771. <div
  772. class="upload__imgs"
  773. v-for="(img, imgIndex) in json.ansText
  774. .imageList"
  775. :key="imgIndex"
  776. >
  777. <img
  778. :src="$tools.splitImgHost(img, true)"
  779. alt=""
  780. />
  781. </div>
  782. <div class="upload__btn">
  783. <i class="el-icon-plus icon"></i>
  784. <p>上传图片</p>
  785. <input
  786. @change="
  787. uploadImgChild(
  788. $event,
  789. questionIndex,
  790. jsonIndex
  791. )
  792. "
  793. type="file"
  794. />
  795. </div>
  796. </div>
  797. </div>
  798. <div
  799. class="explain-list"
  800. v-if="
  801. bankType == 1 &&
  802. question.ques[jsonIndex] &&
  803. (question.ques[jsonIndex].imageList
  804. .length ||
  805. question.ques[jsonIndex].text)
  806. "
  807. >
  808. <div class="explain-list__header">
  809. 我的答案:
  810. </div>
  811. <div class="explain-list__body">
  812. <div>
  813. {{ question.ques[jsonIndex].text }}
  814. </div>
  815. <div class="upload clearfix">
  816. <div
  817. class="upload__imgs"
  818. v-for="(img, imgIndex) in question.ques[
  819. jsonIndex
  820. ].imageList"
  821. :key="imgIndex"
  822. >
  823. <img
  824. :src="$tools.splitImgHost(img, true)"
  825. alt=""
  826. />
  827. </div>
  828. </div>
  829. </div>
  830. <div class="explain-list__header">
  831. 答案解析:
  832. </div>
  833. <div
  834. class="explain-list__body"
  835. v-html="question.analysisContent"
  836. ></div>
  837. </div>
  838. </div>
  839. <div class="question__btns">
  840. <div
  841. v-if="
  842. bankType == 2 ||
  843. (bankType == 1 &&
  844. !(
  845. question.ques[jsonIndex] &&
  846. (question.ques[jsonIndex].imageList
  847. .length ||
  848. question.ques[jsonIndex].text)
  849. ))
  850. "
  851. class="submit"
  852. @click="
  853. ansSubmitChild(
  854. question,
  855. questionIndex,
  856. jsonIndex
  857. )
  858. "
  859. >
  860. 确认答案
  861. </div>
  862. </div>
  863. </div>
  864. </el-tab-pane>
  865. </el-tabs>
  866. </div>
  867. </div>
  868. <div
  869. class="question"
  870. v-if="question.type == 5 && current == questionIndex"
  871. :key="questionIndex"
  872. >
  873. <div class="question__title">
  874. {{ questionIndex + 1 }}、简答题
  875. </div>
  876. <div
  877. class="question__desc"
  878. v-html="question.content"
  879. ></div>
  880. <div class="question__content">
  881. <div
  882. class="question-list textarea"
  883. v-if="
  884. bankType == 2 ||
  885. (bankType == 1 &&
  886. !question.ques.imageList.length &&
  887. !question.ques.text)
  888. "
  889. >
  890. <el-input
  891. type="textarea"
  892. rows="5"
  893. v-model="question.ansText.text"
  894. resize="none"
  895. ></el-input>
  896. <div class="upload clearfix">
  897. <div
  898. class="upload__imgs"
  899. v-for="(img, imgIndex) in question.ansText
  900. .imageList"
  901. :key="imgIndex"
  902. >
  903. <img
  904. :src="$tools.splitImgHost(img, true)"
  905. alt=""
  906. />
  907. </div>
  908. <div class="upload__btn">
  909. <i class="el-icon-plus icon"></i>
  910. <p>上传图片</p>
  911. <input
  912. @change="
  913. uploadImg($event, question, questionIndex)
  914. "
  915. type="file"
  916. />
  917. </div>
  918. </div>
  919. </div>
  920. <div
  921. class="explain-list"
  922. v-if="
  923. (bankType == 1 && question.ques.imageList.length) ||
  924. question.ques.text
  925. "
  926. >
  927. <div class="explain-list__header">我的答案:</div>
  928. <div class="explain-list__body">
  929. <div>{{ question.ques.text }}</div>
  930. <div class="upload clearfix">
  931. <div
  932. class="upload__imgs"
  933. v-for="(img, imgIndex) in question.ques
  934. .imageList"
  935. :key="imgIndex"
  936. >
  937. <img
  938. :src="$tools.splitImgHost(img, true)"
  939. alt=""
  940. />
  941. </div>
  942. </div>
  943. </div>
  944. <div class="explain-list__header">答案解析:</div>
  945. <div
  946. class="explain-list__body"
  947. v-html="question.analysisContent"
  948. ></div>
  949. </div>
  950. </div>
  951. <div class="question__btns">
  952. <div
  953. v-if="
  954. bankType == 2 ||
  955. (bankType == 1 &&
  956. !question.ques.imageList.length &&
  957. !question.ques.text)
  958. "
  959. class="submit"
  960. @click="ansSubmit(question, questionIndex)"
  961. >
  962. 确认答案
  963. </div>
  964. </div>
  965. </div>
  966. </template>
  967. </div>
  968. <Collection-box
  969. :param="param"
  970. @sumit="getCollectInfo(current)"
  971. :showT="!collectList[current]"
  972. ></Collection-box>
  973. </div>
  974. <div class="right-box">
  975. <div class="right-box__header">
  976. <el-button
  977. type="primary"
  978. round
  979. plain
  980. size="small"
  981. class="back-btn"
  982. @click="$router.back(-1)"
  983. >返回</el-button
  984. >
  985. </div>
  986. <div class="right-box__footer">
  987. <div class="submit" @click="submit">交卷</div>
  988. </div>
  989. <div class="right-box__header">
  990. <div class="title">答题卡</div>
  991. <div class="time" v-if="allTimes">
  992. 剩余时间 {{ countdown(lastTime) }}
  993. </div>
  994. </div>
  995. <div class="right-box__body">
  996. <div class="card">
  997. <div class="card__note">
  998. <div class="item">
  999. <div class="box green"></div>
  1000. 正确
  1001. </div>
  1002. <div class="item">
  1003. <div class="box red"></div>
  1004. 错误
  1005. </div>
  1006. <div class="item">
  1007. <div class="box blue"></div>
  1008. 已做未评改
  1009. </div>
  1010. <div class="item">
  1011. <div class="box yellow"></div>
  1012. 少选
  1013. </div>
  1014. <div class="item">
  1015. <div class="box white"></div>
  1016. 未做
  1017. </div>
  1018. </div>
  1019. <div class="card__content">
  1020. <ul class="list">
  1021. <li
  1022. class="item white"
  1023. v-for="(item, index) in questionList"
  1024. :key="index"
  1025. :class="{
  1026. green: bankType == 1 && isRight(item, index),
  1027. red: bankType == 1 && isWrong(item, index),
  1028. yellow: bankType == 1 && isPart(item, index),
  1029. blue: bankType == 1 && isOver(item, index),
  1030. check_ans: bankType == 2 && isCheck(item, index),
  1031. }"
  1032. @click="changeIndex(index)"
  1033. >
  1034. {{ index + 1 }}
  1035. </li>
  1036. </ul>
  1037. </div>
  1038. </div>
  1039. </div>
  1040. </div>
  1041. </div>
  1042. </div>
  1043. </div>
  1044. </div>
  1045. </section>
  1046. <ToolBar></ToolBar>
  1047. <Footer></Footer>
  1048. <el-dialog
  1049. width="800px"
  1050. class="take-photo"
  1051. :visible.sync="takePhotoModal"
  1052. :close-on-click-modal="false"
  1053. :close-on-press-escape="false"
  1054. :show-close="false"
  1055. >
  1056. <div class="take-photo__content">
  1057. <!-- <div class="take-photo__close" @click="takePhotoModal = false">X</div> -->
  1058. <div class="take-photo__header">人脸验证</div>
  1059. <div class="take-photo__body clearfix">
  1060. <div class="left-box">
  1061. <div class="title">重要提示:</div>
  1062. <div class="content">
  1063. <p>1、请保证摄像头正对自己,避免头像偏左或者偏右。</p>
  1064. <p>
  1065. 2、请保证拍照环境光线充足(照片太暗或曝光会降低验证通过率)。
  1066. </p>
  1067. <p>
  1068. 3、请保证整个头像在人脸识别区域内,脸部无遮挡装饰物(佩戴眼镜会降低通过率)。
  1069. </p>
  1070. <p>
  1071. 4、如果下面视频中出现黑屏,摄像头可能被其他进程占用,请关闭其他调用摄像头的程序,重新刷新当前页面重新拍照识别。
  1072. </p>
  1073. </div>
  1074. </div>
  1075. <div class="right-box">
  1076. <img v-show="!isTaking" :src="faceUrl" alt="" />
  1077. <video v-show="isTaking" id="video" :src="stream"></video>
  1078. <div v-show="isTaking" class="mask"></div>
  1079. </div>
  1080. </div>
  1081. <div class="take-photo__footer">
  1082. <el-button
  1083. type="primary"
  1084. v-if="isTaking"
  1085. class="take"
  1086. @click="onPhoto"
  1087. >拍照</el-button
  1088. >
  1089. <el-button
  1090. type="primary"
  1091. v-if="!isTaking"
  1092. class="take"
  1093. @click="reTake"
  1094. :loading="loading"
  1095. >重拍</el-button
  1096. >
  1097. <el-button
  1098. type="primary"
  1099. v-if="!isTaking"
  1100. class="take"
  1101. @click="takeOk"
  1102. :loading="loading"
  1103. >确认</el-button
  1104. >
  1105. </div>
  1106. </div>
  1107. </el-dialog>
  1108. </div>
  1109. </template>
  1110. <script>
  1111. import Footer from "@/components/footer/index";
  1112. import Header from "@/components/header/index";
  1113. import ToolBar from "@/components/toolbar/index";
  1114. import CollectionBox from "@/components/common/CollectionBox.vue";
  1115. import HeaderTabBox from "../../components/exam/HeaderTabBox.vue";
  1116. import { mapMutations } from "vuex";
  1117. export default {
  1118. name: "BankExplain",
  1119. components: {
  1120. Footer,
  1121. Header,
  1122. ToolBar,
  1123. CollectionBox,
  1124. HeaderTabBox,
  1125. },
  1126. data() {
  1127. return {
  1128. hasTake: false,
  1129. recordId: 0,
  1130. tabIndex: "1",
  1131. textarea: "",
  1132. questionIndex: 0,
  1133. checked: false,
  1134. activeName: "1",
  1135. questionList: [],
  1136. goodsExamConfig: [],
  1137. goodsDetail: {},
  1138. bankList: [],
  1139. judge: ["正确", "错误"],
  1140. ast: [
  1141. "A",
  1142. "B",
  1143. "C",
  1144. "D",
  1145. "E",
  1146. "F",
  1147. "G",
  1148. "H",
  1149. "I",
  1150. "J",
  1151. "K",
  1152. "L",
  1153. "M",
  1154. "N",
  1155. "O",
  1156. "P",
  1157. "Q",
  1158. "R",
  1159. "S",
  1160. "T",
  1161. "U",
  1162. "V",
  1163. "W",
  1164. "X",
  1165. "Y",
  1166. "Z",
  1167. ],
  1168. needPhoto: false,
  1169. lastTime: 0, //剩余考试时长
  1170. allTimes: 0, //总考试时长
  1171. lastCount: 0,
  1172. examId: 0,
  1173. learning: 0,
  1174. goodsId: 0,
  1175. courseId: 0,
  1176. gradeId: 0,
  1177. moduleId: 0,
  1178. chapterId: 0,
  1179. sectionId: 0,
  1180. faceUrl: "",
  1181. stream: null,
  1182. ossAvatarUrl: "",
  1183. orderGoodsId: 0,
  1184. current: 0,
  1185. timer: null,
  1186. takePhotoModal: false,
  1187. isTaking: true, //是否正在拍照
  1188. stream: null,
  1189. loading: false,
  1190. type: 0, //type:1章卷,2节卷,3模块卷
  1191. bankType: 0,
  1192. compareFaceData: 0, // 拍照匹配相似度
  1193. collectList: [],
  1194. };
  1195. },
  1196. async mounted() {
  1197. this.goodsId = this.$route.params.goodsId;
  1198. this.examId = this.$route.query.examId;
  1199. this.learning = this.$route.query.learning;
  1200. this.type = this.$route.query.type;
  1201. this.courseId = this.$route.query.courseId;
  1202. this.gradeId = this.$route.query.gradeId;
  1203. this.moduleId = this.$route.query.moduleId;
  1204. this.sectionId = this.$route.query.sectionId;
  1205. this.chapterId = this.$route.query.chapterId;
  1206. this.orderGoodsId = this.$route.query.orderGoodsId;
  1207. await this.getGoodsDetail();
  1208. this.goodsQuestionList();
  1209. this.bankExam();
  1210. },
  1211. beforeDestroy() {
  1212. clearInterval(this.timer);
  1213. try {
  1214. this.$msgbox.close();
  1215. } catch (err) {}
  1216. },
  1217. methods: {
  1218. ...mapMutations(["setExamResult"]),
  1219. toFixed(num) {
  1220. if (num) {
  1221. let str = String(num).indexOf(".");
  1222. if (str != -1) {
  1223. return +num.toFixed(2);
  1224. } else {
  1225. return num;
  1226. }
  1227. } else {
  1228. return 0;
  1229. }
  1230. },
  1231. getGoodsDetail() {
  1232. return new Promise((resolve) => {
  1233. let self = this;
  1234. this.$request.goodsDetail(this.goodsId).then((res) => {
  1235. self.goodsDetail = res.data;
  1236. if (self.goodsDetail.goodsPhotoExamConfig) {
  1237. let goodsPhotoExamConfig = JSON.parse(
  1238. self.goodsDetail.goodsPhotoExamConfig
  1239. );
  1240. if (goodsPhotoExamConfig.photograph > 0) {
  1241. self.needPhoto = true;
  1242. }
  1243. }
  1244. resolve();
  1245. });
  1246. });
  1247. },
  1248. /**
  1249. * @param {Object} current
  1250. * 获取收藏信息
  1251. */
  1252. getCollectInfo(current) {
  1253. this.$request
  1254. .getCollectInfo({
  1255. examId: this.examId,
  1256. questionId: this.questionList[current].questionId,
  1257. goodsId: this.goodsId,
  1258. orderGoodsId: this.orderGoodsId,
  1259. })
  1260. .then((res) => {
  1261. this.$set(this.collectList, current, res.data);
  1262. })
  1263. .catch((err) => {
  1264. this.$set(this.collectList, current, false);
  1265. });
  1266. },
  1267. /**
  1268. * 请求题目列表
  1269. */
  1270. goodsQuestionList() {
  1271. this.$request
  1272. .goodsQuestionList({
  1273. examId: this.examId,
  1274. })
  1275. .then(async (res) => {
  1276. if (!res.data.length) {
  1277. this.$message({
  1278. type: "warning",
  1279. message: "该试卷暂无题目",
  1280. });
  1281. return;
  1282. }
  1283. this.allTimes = res.data[0].answerTime * 60;
  1284. this.lastTime = res.data[0].answerTime && res.data[0].answerTime * 60;
  1285. res.data.forEach((item, index) => {
  1286. if (typeof item.jsonStr == "string") {
  1287. item.jsonStr = JSON.parse(item.jsonStr);
  1288. if (item.type == 2) {
  1289. //多选
  1290. item.jsonStr.forEach((str) => {
  1291. str.optionsId = "" + str.optionsId;
  1292. });
  1293. let arr = item.answerQuestion.split(",");
  1294. arr.forEach((a, i) => {
  1295. arr[i] = "" + a;
  1296. });
  1297. item.ans = arr;
  1298. item.quesSelect = [];
  1299. item.analysisContent &&
  1300. (item.analysisContent = item.analysisContent.replace(
  1301. /<img/gi,
  1302. '<img style="max-width:100%;"'
  1303. ));
  1304. item.content &&
  1305. (item.content = item.content.replace(
  1306. /<img/gi,
  1307. '<img style="max-width:100%;"'
  1308. ));
  1309. return;
  1310. } else if (item.type == 5) {
  1311. //简答题
  1312. item.ansText = {
  1313. text: "",
  1314. imageList: [],
  1315. };
  1316. item.ques = {
  1317. text: "",
  1318. imageList: [],
  1319. };
  1320. item.analysisContent &&
  1321. (item.analysisContent = item.analysisContent.replace(
  1322. /<img/gi,
  1323. '<img style="max-width:100%;"'
  1324. ));
  1325. item.content &&
  1326. (item.content = item.content.replace(
  1327. /<img/gi,
  1328. '<img style="max-width:100%;"'
  1329. ));
  1330. return;
  1331. } else if (item.type == 4) {
  1332. //案例题
  1333. item.ques = [];
  1334. item.tabIndex = "0";
  1335. let ansArr = [];
  1336. item.jsonStr.forEach((json, index) => {
  1337. if (json.type == 1) {
  1338. ansArr[index] = json.answerQuestion;
  1339. json.content &&
  1340. (json.content = json.content.replace(
  1341. /<img/gi,
  1342. '<img style="max-width:100%;"'
  1343. ));
  1344. } else if (json.type == 2) {
  1345. json.optionsList.forEach((str) => {
  1346. str.optionsId = "" + str.optionsId;
  1347. });
  1348. let arr = json.answerQuestion.split(",");
  1349. arr.forEach((a, i) => {
  1350. arr[i] = "" + a;
  1351. });
  1352. ansArr[index] = arr;
  1353. json.content &&
  1354. (json.content = json.content.replace(
  1355. /<img/gi,
  1356. '<img style="max-width:100%;"'
  1357. ));
  1358. } else if (json.type == 3) {
  1359. ansArr[index] = json.answerQuestion;
  1360. json.content &&
  1361. (json.content = json.content.replace(
  1362. /<img/gi,
  1363. '<img style="max-width:100%;"'
  1364. ));
  1365. } else if (json.type == 5) {
  1366. ansArr[index] = {
  1367. text: "",
  1368. imageList: [],
  1369. };
  1370. json.ansText = {
  1371. text: "",
  1372. imageList: [],
  1373. };
  1374. json.ques = {
  1375. text: "",
  1376. imageList: [],
  1377. };
  1378. json.content &&
  1379. (json.content = json.content.replace(
  1380. /<img/gi,
  1381. '<img style="max-width:100%;"'
  1382. ));
  1383. }
  1384. });
  1385. item.ans = ansArr;
  1386. return;
  1387. }
  1388. item.analysisContent &&
  1389. (item.analysisContent = item.analysisContent.replace(
  1390. /<img/gi,
  1391. '<img style="max-width:100%;"'
  1392. ));
  1393. item.content &&
  1394. (item.content = item.content.replace(
  1395. /<img/gi,
  1396. '<img style="max-width:100%;"'
  1397. ));
  1398. item.ques = "";
  1399. item.ans = item.answerQuestion;
  1400. }
  1401. });
  1402. this.questionList = res.data;
  1403. this.lastCount = this.questionList.length;
  1404. this.getCollectInfo(this.current);
  1405. await this.examRecord();
  1406. });
  1407. },
  1408. //拍照
  1409. openPhoto() {
  1410. this.$nextTick(() => {
  1411. console.log(window.navigator.mediaDevices);
  1412. if (
  1413. (window.navigator.mediaDevices &&
  1414. window.navigator.mediaDevices.getUserMedia) ||
  1415. window.navigator.getUserMedia ||
  1416. window.navigator.webkitGetUserMedia ||
  1417. window.navigator.mozGetUserMedia
  1418. ) {
  1419. // 调用用户媒体设备, 访问摄像头
  1420. this.getUserMedia(
  1421. {
  1422. video: {
  1423. width: 400,
  1424. height: 400,
  1425. },
  1426. },
  1427. this.photographSuccess,
  1428. this.photographError
  1429. );
  1430. } else {
  1431. this.photographError();
  1432. }
  1433. });
  1434. },
  1435. async takeOk() {
  1436. this.loading = true;
  1437. let compareFaceData = await this.faceRecognition();
  1438. this.compareFaceData = compareFaceData;
  1439. if (compareFaceData >= 80) {
  1440. this.$message({
  1441. type: "success",
  1442. message: "拍照成功",
  1443. });
  1444. const waitYS = await this.imageInfos();
  1445. this.loading = false;
  1446. this.takePhotoModal = false;
  1447. this.isTaking = true;
  1448. this.postStudyRecord(); //提交记录
  1449. } else {
  1450. this.$message({
  1451. type: "warning",
  1452. message: "人脸匹配不通过,请重新拍照上传",
  1453. });
  1454. setTimeout(() => {
  1455. this.loading = false;
  1456. this.reTake();
  1457. }, 2000);
  1458. }
  1459. },
  1460. postStudyRecord() {
  1461. let self = this;
  1462. let data = {
  1463. photo: self.ossAvatarUrl,
  1464. recordId: self.recordId,
  1465. };
  1466. if (this.ossAvatarUrl) {
  1467. data.similarity = this.compareFaceData; // 相似度
  1468. }
  1469. this.$request
  1470. .studyExamPhotoRecord(data)
  1471. .then((res) => {
  1472. this.hasTake = true;
  1473. // console.log(res, "拍照提交结果");
  1474. self.ossAvatarUrl = "";
  1475. //拍照
  1476. if (this.lastTime) {
  1477. this.timer = setInterval(() => {
  1478. if (this.lastTime <= 0) {
  1479. clearInterval(this.timer);
  1480. this.$confirm("考试时间已到,系统将自动交卷", "提示", {
  1481. showConfirmButton: false,
  1482. closeOnClickModal: false,
  1483. showCancelButton: false,
  1484. closeOnPressEscape: false,
  1485. distinguishCancelAndClose: false,
  1486. showClose: false,
  1487. });
  1488. setTimeout(() => {
  1489. this.examSubmit();
  1490. }, 3000);
  1491. return;
  1492. }
  1493. this.lastTime--;
  1494. }, 1000);
  1495. }
  1496. })
  1497. .catch((err) => {
  1498. this.$message({
  1499. type: "warning",
  1500. message: err.msg,
  1501. });
  1502. });
  1503. },
  1504. imageInfos() {
  1505. var self = this;
  1506. return new Promise(async (resolve, reject) => {
  1507. const waitUpload = await self.uploadFile(self.faceUrl, 0);
  1508. resolve(waitUpload);
  1509. });
  1510. },
  1511. uploadFile(options, int) {
  1512. var self = this;
  1513. return new Promise((resolve, reject) => {
  1514. var data = {
  1515. imageStatus: int,
  1516. gradeId: this.gradeId,
  1517. orderGoodsId: this.orderGoodsId,
  1518. };
  1519. self.$request
  1520. .getPolicy(data)
  1521. .then((res) => {
  1522. var ossToken = res.data.resultContent;
  1523. if (ossToken.host == null || ossToken.host == undefined) {
  1524. this.$message({
  1525. type: "warning",
  1526. message: "上传路径报错" + JSON.stringify(res.data),
  1527. });
  1528. return;
  1529. }
  1530. let data = this.$tools.convertBase64UrlToBlob(this.faceUrl);
  1531. this.$upload
  1532. .upload(data, 0)
  1533. .then((res) => {
  1534. this.ossAvatarUrl = res;
  1535. resolve(res);
  1536. })
  1537. .catch((err) => {
  1538. this.$message({
  1539. type: "warning",
  1540. message: "上传接口报错,请重新拍照上传",
  1541. });
  1542. this.reTake();
  1543. });
  1544. })
  1545. .catch((err) => {
  1546. this.$message({
  1547. type: "warning",
  1548. message: "签名错误" + JSON.stringify(err),
  1549. });
  1550. return;
  1551. });
  1552. });
  1553. },
  1554. faceRecognition() {
  1555. return new Promise((resolve) => {
  1556. this.$request
  1557. .faceCertificationCompareFace({
  1558. imageA: this.faceUrl,
  1559. orderGoodsId: this.orderGoodsId,
  1560. gradeId: this.gradeId,
  1561. })
  1562. .then((res) => {
  1563. resolve(res.data);
  1564. })
  1565. .catch((err) => {
  1566. if (err.toString().indexOf("timeout") != -1) {
  1567. err = {
  1568. msg: "拍照超时,请重新拍照",
  1569. };
  1570. }
  1571. this.loading = false;
  1572. this.$message({
  1573. type: "warning",
  1574. message: err.msg,
  1575. });
  1576. });
  1577. });
  1578. },
  1579. /**
  1580. * 点击重拍
  1581. */
  1582. reTake() {
  1583. this.faceUrl = "";
  1584. this.isTaking = true;
  1585. this.getUserMedia({
  1586. video: {
  1587. width: 400,
  1588. height: 400,
  1589. },
  1590. });
  1591. },
  1592. // 点击拍照按钮
  1593. onPhoto() {
  1594. // if (this.isIE) {
  1595. // window.webcam.capture();
  1596. // } else {
  1597. const canvas = document.createElement("canvas");
  1598. canvas.width = 400;
  1599. canvas.height = 400;
  1600. const context = canvas.getContext("2d");
  1601. const video = document.getElementById("video");
  1602. context.drawImage(video, 0, 0, 400, 400);
  1603. this.faceUrl = canvas.toDataURL("image/png");
  1604. this.isTaking = false;
  1605. // }
  1606. },
  1607. getUserMedia(constraints, success, error) {
  1608. if (window.navigator.mediaDevices.getUserMedia) {
  1609. // 最新的标准API
  1610. window.navigator.mediaDevices
  1611. .getUserMedia(constraints)
  1612. .then(success)
  1613. .catch(error);
  1614. } else if (window.navigator.webkitGetUserMedia) {
  1615. // webkit核心浏览器
  1616. window.navigator.webkitGetUserMedia(constraints, success, error);
  1617. } else if (window.navigator.mozGetUserMedia) {
  1618. // firfox浏览器
  1619. window.navigator.mozGetUserMedia(constraints, success, error);
  1620. } else if (window.navigator.getUserMedia) {
  1621. // 旧版API
  1622. window.navigator.getUserMedia(constraints, success, error);
  1623. }
  1624. },
  1625. photographSuccess(stream) {
  1626. // 兼容webkit核心浏览器
  1627. this.isTaking = true;
  1628. this.takePhotoModal = true;
  1629. this.$nextTick(() => {
  1630. const video = document.getElementById("video");
  1631. // 将视频流设置为video元素的源
  1632. // console.dir(video);
  1633. video.srcObject = stream;
  1634. this.mediaStreamTrack =
  1635. typeof stream.stop === "function" ? stream : stream.getTracks()[0];
  1636. video.play();
  1637. });
  1638. },
  1639. photographError(err) {
  1640. this.$confirm(
  1641. "课程学习需要开启摄像头进行拍照,经检测您的设备无摄像头可使用,请检测环境是否支持。",
  1642. "提示",
  1643. {
  1644. confirmButtonText: "返回",
  1645. showConfirmButton: true,
  1646. closeOnClickModal: false,
  1647. showCancelButton: false,
  1648. closeOnPressEscape: false,
  1649. distinguishCancelAndClose: false,
  1650. showClose: false,
  1651. }
  1652. ).then(() => {
  1653. this.$router.go(-1);
  1654. });
  1655. },
  1656. /**
  1657. * 记录总题数,获取recordId
  1658. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1659. */
  1660. examRecord(hasSpecial) {
  1661. return new Promise((resolve) => {
  1662. let self = this;
  1663. let questionList = 0;
  1664. // if(!hasSpecial) {
  1665. this.questionList.forEach((item, index) => {
  1666. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1667. questionList++;
  1668. }
  1669. });
  1670. // } else {
  1671. // questionList = this.questionList.length;
  1672. // }
  1673. this.$request
  1674. .bankRecord({
  1675. courseId: this.courseId,
  1676. chapterId: this.chapterId || 0,
  1677. moduleId: this.moduleId || 0,
  1678. sectionId: this.sectionId || 0,
  1679. goodsId: this.goodsId,
  1680. examId: this.examId,
  1681. type: this.type,
  1682. gradeId: this.gradeId,
  1683. totalQuestionNum: questionList,
  1684. allQuestionNum: this.questionList.length,
  1685. orderGoodsId: this.orderGoodsId,
  1686. })
  1687. .then((res) => {
  1688. this.recordId = res.data;
  1689. // 节不需要拍照
  1690. if (self.needPhoto && this.type != 2 && this.learning != 1) {
  1691. this.openPhoto();
  1692. } else {
  1693. if (this.lastTime) {
  1694. this.timer = setInterval(() => {
  1695. if (this.lastTime <= 0) {
  1696. clearInterval(this.timer);
  1697. this.$confirm("考试时间已到,系统将自动交卷", "提示", {
  1698. showConfirmButton: false,
  1699. closeOnClickModal: false,
  1700. showCancelButton: false,
  1701. closeOnPressEscape: false,
  1702. distinguishCancelAndClose: false,
  1703. showClose: false,
  1704. });
  1705. setTimeout(() => {
  1706. this.examSubmit();
  1707. }, 2000);
  1708. return;
  1709. }
  1710. this.lastTime--;
  1711. }, 1000);
  1712. }
  1713. resolve();
  1714. }
  1715. });
  1716. });
  1717. },
  1718. /**
  1719. * 获取试卷类型2考试,1练习
  1720. */
  1721. bankExam() {
  1722. this.$request.bankExam(this.examId).then((res) => {
  1723. this.bankType = res.data.doType;
  1724. if (this.bankType == 2) {
  1725. this.needBack = true;
  1726. }
  1727. });
  1728. },
  1729. /**
  1730. * @param {Object}
  1731. * 单选点击确认
  1732. */
  1733. radioSelect(question, questionIndex, optionsId) {
  1734. // if (this.questionList[questionIndex].ques) return;
  1735. if (this.questionList[questionIndex].ques && this.bankType == 1) {
  1736. return;
  1737. }
  1738. this.$set(this.questionList[questionIndex], "ques", optionsId);
  1739. },
  1740. /**
  1741. * @param {Object}
  1742. * 案例单选点击
  1743. */
  1744. radioSelectChild(questionIndex, jsonIndex, optionsId) {
  1745. // if (this.questionList[questionIndex].ques[jsonIndex]) return;
  1746. if (
  1747. this.questionList[questionIndex].ques[jsonIndex] &&
  1748. this.bankType == 1
  1749. ) {
  1750. return;
  1751. }
  1752. this.$set(this.questionList[questionIndex].ques, jsonIndex, optionsId);
  1753. },
  1754. /**
  1755. * 多选点击确认
  1756. */
  1757. checkboxSubmit(question, questionIndex) {
  1758. // if (this.questionList[questionIndex].ques) return;
  1759. if (this.questionList[questionIndex].ques && this.bankType == 1) {
  1760. return;
  1761. }
  1762. let arr = [];
  1763. this.questionList[questionIndex].jsonStr.forEach((item) => {
  1764. if (item.checked) {
  1765. arr.push(item.optionsId);
  1766. }
  1767. });
  1768. if (!arr.length) {
  1769. delete this.questionList[questionIndex].ques;
  1770. this.$message({
  1771. type: "warning",
  1772. message: "请选择答案",
  1773. });
  1774. return;
  1775. }
  1776. this.$set(this.questionList[questionIndex], "ques", arr);
  1777. },
  1778. /**
  1779. * @param {Object}
  1780. * 案例多选确认
  1781. */
  1782. checkboxSubmitChild(questionIndex, ansIndex) {
  1783. // if (this.questionList[questionIndex].ques[ansIndex]) return;
  1784. if (
  1785. this.questionList[questionIndex].ques[ansIndex] &&
  1786. this.bankType == 1
  1787. ) {
  1788. return;
  1789. }
  1790. let arr = [];
  1791. this.questionList[questionIndex].jsonStr[ansIndex].optionsList.forEach(
  1792. (item) => {
  1793. if (item.checked) {
  1794. arr.push(item.optionsId);
  1795. }
  1796. }
  1797. );
  1798. if (!arr.length) {
  1799. delete this.questionList[questionIndex].ques[ansIndex];
  1800. this.$message({
  1801. type: "warning",
  1802. message: "请选择答案",
  1803. });
  1804. return;
  1805. }
  1806. this.$set(this.questionList[questionIndex].ques, ansIndex, arr);
  1807. },
  1808. /**
  1809. * 判断点击确认
  1810. */
  1811. judgeSelect(question, questionIndex, index) {
  1812. // if (question.ques) return;
  1813. if (question.ques && this.bankType == 1) {
  1814. return;
  1815. }
  1816. this.$set(
  1817. this.questionList[questionIndex],
  1818. "ques",
  1819. index == 0 ? "1" : "0"
  1820. );
  1821. },
  1822. judgeSelectChild(questionIndex, jsonIndex, index) {
  1823. // console.log(this.questionList[questionIndex].ques[jsonIndex]);
  1824. // if (this.questionList[questionIndex].ques[jsonIndex]) return;
  1825. if (
  1826. this.questionList[questionIndex].ques[jsonIndex] &&
  1827. this.bankType == 1
  1828. ) {
  1829. return;
  1830. }
  1831. this.$set(
  1832. this.questionList[questionIndex].ques,
  1833. jsonIndex,
  1834. index == 0 ? "1" : "0"
  1835. );
  1836. },
  1837. /**
  1838. * 上传图片
  1839. */
  1840. uploadImg(e, question, questionIndex) {
  1841. var file = e.target.files[0];
  1842. if (file.size > 2 * 1024 * 1024) {
  1843. this.$message.warn("图片不得大于2000kb");
  1844. return;
  1845. }
  1846. var type = e.target.value.toLowerCase().split(".").splice(-1);
  1847. if (
  1848. type[0] != "jpg" &&
  1849. type[0] != "png" &&
  1850. type[0] != "jpeg" &&
  1851. type[0] != "gif"
  1852. ) {
  1853. this.$message.error("上传格式需为:.jpg/.png/.jpeg/gif");
  1854. e.target.value = "";
  1855. return;
  1856. }
  1857. this.$upload.upload(file, 0).then((res) => {
  1858. question.ansText.imageList.push(res);
  1859. });
  1860. },
  1861. /**
  1862. * 案例上传图片
  1863. */
  1864. uploadImgChild(e, questionIndex, jsonIndex) {
  1865. var file = e.target.files[0];
  1866. if (file.size > 2 * 1024 * 1024) {
  1867. this.$message.warn("图片不得大于2000kb");
  1868. return;
  1869. }
  1870. var type = e.target.value.toLowerCase().split(".").splice(-1);
  1871. if (
  1872. type[0] != "jpg" &&
  1873. type[0] != "png" &&
  1874. type[0] != "jpeg" &&
  1875. type[0] != "gif"
  1876. ) {
  1877. this.$message.error("上传格式需为:.jpg/.png/.jpeg/gif");
  1878. e.target.value = "";
  1879. return;
  1880. }
  1881. this.$upload.upload(file, 0).then((res) => {
  1882. this.questionList[questionIndex].jsonStr[
  1883. jsonIndex
  1884. ].ansText.imageList.push(res);
  1885. });
  1886. },
  1887. isOver(item, index) {
  1888. if (this.questionList[index].ques) {
  1889. if (item.type == 4) {
  1890. //案例题
  1891. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1892. if (
  1893. jsonItem.type == 1 ||
  1894. jsonItem.type == 2 ||
  1895. jsonItem.type == 3
  1896. ) {
  1897. if (item.ques[indexs]) {
  1898. return true;
  1899. } else {
  1900. return false;
  1901. }
  1902. } else if (jsonItem.type == 5) {
  1903. if (
  1904. item.ques[indexs] &&
  1905. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  1906. ) {
  1907. return true;
  1908. } else {
  1909. return false;
  1910. }
  1911. }
  1912. });
  1913. if (isOver) {
  1914. return true;
  1915. } else {
  1916. return false;
  1917. }
  1918. } else if (item.type == 5) {
  1919. //简答题
  1920. //每一项都相等
  1921. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1922. return true;
  1923. }
  1924. //判断
  1925. } else {
  1926. return false;
  1927. }
  1928. } else {
  1929. return false;
  1930. }
  1931. },
  1932. ansSubmit(question, questionIndex) {
  1933. if (!question.ansText.text && !question.ansText.imageList.length) {
  1934. this.$message({
  1935. type: "warning",
  1936. message: "请输入内容或上传图片",
  1937. });
  1938. return;
  1939. }
  1940. question.ques.imageList = question.ansText.imageList;
  1941. question.ques.text = question.ansText.text;
  1942. },
  1943. ansSubmitChild(question, questionIndex, jsonIndex) {
  1944. if (
  1945. !this.questionList[questionIndex].jsonStr[jsonIndex].ansText.text &&
  1946. !this.questionList[questionIndex].jsonStr[jsonIndex].ansText.imageList
  1947. .length
  1948. ) {
  1949. this.$message({
  1950. type: "warning",
  1951. message: "请输入内容或上传图片",
  1952. });
  1953. return;
  1954. }
  1955. this.$set(this.questionList[questionIndex].ques, jsonIndex, {
  1956. imageList:
  1957. this.questionList[questionIndex].jsonStr[jsonIndex].ansText
  1958. .imageList || [],
  1959. text:
  1960. this.questionList[questionIndex].jsonStr[jsonIndex].ansText.text ||
  1961. "",
  1962. });
  1963. },
  1964. changeIndex(index) {
  1965. this.current = index;
  1966. this.getCollectInfo(this.current);
  1967. },
  1968. nextQuestion() {
  1969. if (this.current >= this.questionList.length - 1) {
  1970. this.$message({
  1971. type: "warning",
  1972. message: "已经是最后一题了!",
  1973. });
  1974. return;
  1975. }
  1976. this.current++;
  1977. this.getCollectInfo(this.current);
  1978. },
  1979. prevQuestion() {
  1980. if (this.current == 0) {
  1981. this.$message({
  1982. type: "warning",
  1983. message: "已经是第一题了!",
  1984. });
  1985. return;
  1986. } else {
  1987. this.current--;
  1988. this.getCollectInfo(this.current);
  1989. }
  1990. },
  1991. isCheck(item, index) {
  1992. if (this.questionList[index].ques) {
  1993. return true;
  1994. }
  1995. },
  1996. isRight(item, index) {
  1997. //单选
  1998. if (this.questionList[index].ques) {
  1999. if (item.type == 1) {
  2000. return this.questionList[index].ques == this.questionList[index].ans;
  2001. //多选
  2002. } else if (item.type == 2) {
  2003. //每一项都相等
  2004. return this.questionList[index].ans.every((item, i) => {
  2005. return item == this.questionList[index].ques[i];
  2006. });
  2007. //判断
  2008. } else if (item.type == 3) {
  2009. return this.questionList[index].ques == this.questionList[index].ans;
  2010. } else {
  2011. return false;
  2012. }
  2013. } else {
  2014. return false;
  2015. }
  2016. },
  2017. isWrong(item, index) {
  2018. if (this.questionList[index].ques) {
  2019. //单选
  2020. if (item.type == 1) {
  2021. return this.questionList[index].ques != this.questionList[index].ans;
  2022. //多选
  2023. } else if (item.type == 2) {
  2024. //每一项都相等
  2025. return this.questionList[index].ques.some((item, i) => {
  2026. return this.questionList[index].ans.indexOf(item) == -1;
  2027. });
  2028. //判断
  2029. } else if (item.type == 3) {
  2030. return this.questionList[index].ques != this.questionList[index].ans;
  2031. } else {
  2032. return false;
  2033. }
  2034. } else {
  2035. return false;
  2036. }
  2037. },
  2038. isPart(item, index) {
  2039. if (this.questionList[index].ques) {
  2040. if (item.type == 2) {
  2041. let isWrong = this.questionList[index].ques.some((item, i) => {
  2042. return this.questionList[index].ans.indexOf(item) == -1;
  2043. });
  2044. let isRight = this.questionList[index].ans.every((item, i) => {
  2045. return item == this.questionList[index].ques[i];
  2046. });
  2047. if (!isRight && !isWrong) {
  2048. return true;
  2049. }
  2050. }
  2051. } else {
  2052. return false;
  2053. }
  2054. },
  2055. right(bankIndex, ansIndex, option) {
  2056. if (
  2057. this.questionList[bankIndex].ques[ansIndex] &&
  2058. this.questionList[bankIndex].ans[ansIndex]
  2059. ) {
  2060. if (
  2061. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2062. option.optionsId
  2063. ) != -1 ||
  2064. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2065. option.optionsId
  2066. ) != -1
  2067. ) {
  2068. return true;
  2069. } else {
  2070. return false;
  2071. }
  2072. } else {
  2073. return false;
  2074. }
  2075. },
  2076. wrong(bankIndex, ansIndex, option) {
  2077. if (
  2078. this.questionList[bankIndex].ques[ansIndex] &&
  2079. this.questionList[bankIndex].ans[ansIndex]
  2080. ) {
  2081. if (
  2082. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2083. option.optionsId
  2084. ) != -1 &&
  2085. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2086. option.optionsId
  2087. ) == -1
  2088. ) {
  2089. return true;
  2090. } else {
  2091. return false;
  2092. }
  2093. } else {
  2094. return false;
  2095. }
  2096. },
  2097. /**
  2098. * 获取已经回答的题目数
  2099. * hasSpecail (是否包含简答和案例)
  2100. */
  2101. questionOverNum(hasSpecail) {
  2102. let count = 0;
  2103. this.questionList.forEach((item) => {
  2104. if (item.type == 1 || item.type == 2 || item.type == 3) {
  2105. if (item.ques) {
  2106. count++;
  2107. }
  2108. } else if (item.type == 4) {
  2109. //案例题
  2110. if (hasSpecail) {
  2111. let isOver = item.jsonStr.every((jsonItem, index) => {
  2112. if (
  2113. jsonItem.type == 1 ||
  2114. jsonItem.type == 2 ||
  2115. jsonItem.type == 3
  2116. ) {
  2117. if (item.ques[index]) {
  2118. return true;
  2119. } else {
  2120. return false;
  2121. }
  2122. } else if (jsonItem.type == 5) {
  2123. if (
  2124. item.ques[index] &&
  2125. (item.ques[index].text || item.ques[index].imageList.length)
  2126. ) {
  2127. return true;
  2128. } else {
  2129. return false;
  2130. }
  2131. }
  2132. });
  2133. if (isOver) {
  2134. count++;
  2135. }
  2136. }
  2137. } else if (item.type == 5) {
  2138. //简答题
  2139. if (hasSpecail) {
  2140. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  2141. count++;
  2142. }
  2143. }
  2144. }
  2145. });
  2146. return count;
  2147. },
  2148. collect(state, index) {
  2149. if (!state) {
  2150. this.$request
  2151. .collectQuestion({
  2152. examId: this.examId,
  2153. questionId: this.questionList[index].questionId,
  2154. goodsId: this.goodsId || "",
  2155. orderGoodsId: this.orderGoodsId,
  2156. })
  2157. .then((res) => {
  2158. this.$set(this.collectList, index, true);
  2159. this.$message.success("收藏成功");
  2160. this.getCollectInfo(index);
  2161. });
  2162. } else {
  2163. this.$request
  2164. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2165. .then((res) => {
  2166. this.$set(this.collectList, index, false);
  2167. this.$message.success("取消收藏成功");
  2168. });
  2169. }
  2170. return;
  2171. },
  2172. submit() {
  2173. let ansCount = this.questionOverNum(true); //已答题数
  2174. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2175. //没有答完
  2176. if (this.lastCount !== 0) {
  2177. this.$confirm(
  2178. `您还有${this.lastCount}道题未作答, 现在继续作答,还是下次继续?`,
  2179. "提示",
  2180. {
  2181. confirmButtonText: "立即交卷",
  2182. cancelButtonText: "继续做题",
  2183. closeOnClickModal: false,
  2184. closeOnPressEscape: false,
  2185. distinguishCancelAndClose: false,
  2186. showClose: false,
  2187. }
  2188. )
  2189. .then((_) => {
  2190. this.examSubmit();
  2191. })
  2192. .catch((_) => {});
  2193. return;
  2194. }
  2195. if (this.bankType == 2) {
  2196. if (this.lastTime > 0) {
  2197. let lastTime = this.countdown(this.lastTime);
  2198. this.$confirm(`时间还剩余${lastTime},确定交卷吗?`, "提示", {
  2199. confirmButtonText: "交卷",
  2200. cancelButtonText: "继续答题",
  2201. closeOnClickModal: false,
  2202. closeOnPressEscape: false,
  2203. distinguishCancelAndClose: false,
  2204. showClose: false,
  2205. })
  2206. .then((_) => {
  2207. this.examSubmit();
  2208. })
  2209. .catch((_) => {});
  2210. return;
  2211. }
  2212. }
  2213. this.examSubmit();
  2214. },
  2215. /**
  2216. * @param {Object} second倒计时过滤器
  2217. */
  2218. countdown(second) {
  2219. if (second) {
  2220. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  2221. let m = parseInt((second / 60) % 60); // 计算分数
  2222. let s = parseInt(second % 60); // 计算当前秒数
  2223. if (h < 10) h = "0" + h;
  2224. if (m < 10) m = "0" + m;
  2225. if (s < 10) s = "0" + s;
  2226. return h + ":" + m + ":" + s;
  2227. } else {
  2228. return "";
  2229. }
  2230. },
  2231. examSubmit() {
  2232. if (this.needPhoto && !this.hasTake) {
  2233. this.$confirm("未拍照成功不能交卷", "提示", {
  2234. closeOnClickModal: false,
  2235. showCancelButton: false,
  2236. closeOnPressEscape: false,
  2237. distinguishCancelAndClose: false,
  2238. showClose: false,
  2239. });
  2240. return;
  2241. }
  2242. let score = 0; //计算总分
  2243. let reportStatus = 0;
  2244. let number = 0; //做对的题目数量
  2245. let doQuestionNum = 0; //做过的题目数量
  2246. let allScore = 0; //总分
  2247. let passScore = 0;
  2248. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2249. let doQuestionIds = []; //做过的题目id
  2250. let rightQuestionIds = []; //做对的题目id
  2251. let lessQuestionNum = 0;
  2252. this.questionList.forEach((item, index) => {
  2253. passScore = item.passScore;
  2254. if (item.type == 1) {
  2255. //正确
  2256. if (item.ques == item.ans) {
  2257. item.scoreResult = item.score;
  2258. score += item.score;
  2259. number++;
  2260. rightQuestionIds.push(item.questionId);
  2261. } else {
  2262. //错误
  2263. item.scoreResult = 0;
  2264. if (item.ques) {
  2265. doWrongQuestionIds.push(item.questionId);
  2266. }
  2267. }
  2268. allScore += item.score;
  2269. if (item.ques) {
  2270. doQuestionNum++;
  2271. doQuestionIds.push(item.questionId);
  2272. }
  2273. } else if (item.type == 2) {
  2274. let isRight =
  2275. item.ans &&
  2276. item.ans.every((quesItem, quesIndex) => {
  2277. if (item.ques) {
  2278. return item.ques[quesIndex] == item.ans[quesIndex];
  2279. } else {
  2280. return false;
  2281. }
  2282. });
  2283. if (isRight) {
  2284. score += item.score;
  2285. number++;
  2286. item.scoreResult = item.score;
  2287. rightQuestionIds.push(item.questionId);
  2288. } else {
  2289. let hasPart = false;
  2290. let checkboxScore = 1; //获取单题总分数
  2291. item.ques &&
  2292. item.ques.forEach((ques, quesIndex) => {
  2293. //选错一个全扣
  2294. if (item.ques) {
  2295. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2296. checkboxScore = 0;
  2297. }
  2298. } else {
  2299. checkboxScore = 0;
  2300. }
  2301. });
  2302. //没选错
  2303. if (checkboxScore) {
  2304. checkboxScore = 0;
  2305. item.ans.forEach((ans, quesIndex) => {
  2306. //漏选扣一部分,对n题给n X partScore 分
  2307. if (item.ques) {
  2308. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2309. checkboxScore += item.partScore;
  2310. hasPart = true;
  2311. }
  2312. } else {
  2313. checkboxScore = 0;
  2314. }
  2315. });
  2316. }
  2317. if (!hasPart) {
  2318. //0分
  2319. item.scoreResult = 0;
  2320. if (item.ques) {
  2321. doWrongQuestionIds.push(item.questionId);
  2322. }
  2323. } else {
  2324. //部分分
  2325. // number++;
  2326. lessQuestionNum++;
  2327. // doWrongQuestionIds.push(item.questionId);
  2328. item.scoreResult = checkboxScore;
  2329. score += checkboxScore;
  2330. // rightQuestionIds.push(item.questionId)
  2331. }
  2332. }
  2333. allScore += item.score;
  2334. if (item.ques && item.ques.length) {
  2335. doQuestionNum++;
  2336. doQuestionIds.push(item.questionId);
  2337. }
  2338. } else if (item.type == 3) {
  2339. if (item.ques == item.ans) {
  2340. item.scoreResult = item.score;
  2341. score += item.score;
  2342. number++;
  2343. rightQuestionIds.push(item.questionId);
  2344. } else {
  2345. item.scoreResult = 0;
  2346. if (item.ques) {
  2347. doWrongQuestionIds.push(item.questionId);
  2348. }
  2349. }
  2350. allScore += item.score;
  2351. if (item.ques) {
  2352. doQuestionNum++;
  2353. doQuestionIds.push(item.questionId);
  2354. }
  2355. } else if (item.type == 4) {
  2356. allScore += item.score;
  2357. if (item.ques && item.ques.length) {
  2358. doQuestionNum++;
  2359. doQuestionIds.push(item.questionId);
  2360. }
  2361. } else if (item.type == 5) {
  2362. allScore += item.score;
  2363. if (item.ques && (item.ques.imageList || item.ques.text)) {
  2364. doQuestionNum++;
  2365. doQuestionIds.push(item.questionId);
  2366. }
  2367. }
  2368. });
  2369. //大于分及格
  2370. if (score >= passScore) {
  2371. reportStatus = 1;
  2372. } else {
  2373. reportStatus = 0;
  2374. }
  2375. clearInterval(this.timer);
  2376. //交卷 /bank/record/edit
  2377. this.$request
  2378. .bankRecordEdit({
  2379. moduleId: this.moduleId || 0,
  2380. chapterId: this.chapterId || 0,
  2381. sectionId: this.sectionId || 0,
  2382. gradeId: this.gradeId,
  2383. courseId: this.courseId,
  2384. orderGoodsId: this.orderGoodsId,
  2385. type: this.type, //题卷类型 1章卷 2节卷 3模块卷
  2386. examId: this.examId,
  2387. goodsId: this.goodsId,
  2388. reportStatus: reportStatus,
  2389. recordId: this.recordId,
  2390. rightQuestionNum: number,
  2391. lessQuestionNum: lessQuestionNum,
  2392. status: 1,
  2393. doQuestionIds: doQuestionIds.join(","),
  2394. rightQuestionIds: rightQuestionIds.join(","),
  2395. doQuestionNum: doQuestionNum,
  2396. performance: score,
  2397. totalScore: allScore,
  2398. examTime: parseInt(this.allTimes),
  2399. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2400. historyExamJson: JSON.stringify(this.questionList),
  2401. })
  2402. .then((res) => {
  2403. this.isSubmit = true;
  2404. clearInterval(this.timer);
  2405. this.$message({
  2406. type: "success",
  2407. message: "交卷成功",
  2408. });
  2409. setTimeout(() => {
  2410. let result = {
  2411. rightQuestionNum: number,
  2412. doWrongQuestionNum: doWrongQuestionIds.length,
  2413. score: score,
  2414. totalScore: allScore,
  2415. reportStatus: reportStatus,
  2416. lessQuestionNum: lessQuestionNum,
  2417. };
  2418. this.setExamResult(result);
  2419. this.$router.replace({
  2420. path: "/course-report",
  2421. query: {
  2422. // orderGoodsId: this.orderGoodsId,
  2423. // chapterId: this.chapterId,
  2424. // moduleId: this.moduleId,
  2425. examId: this.examId,
  2426. recordId: this.recordId,
  2427. type: this.type, //type:1章卷,2节卷,3模块卷
  2428. },
  2429. });
  2430. }, 1000);
  2431. })
  2432. .catch((err) => {
  2433. console.log(err, "err");
  2434. });
  2435. //错题集id提交(客观题)/exam/wwrong/record
  2436. this.$request
  2437. .examWrongRecord({
  2438. moduleId: this.moduleId || 0,
  2439. chapterId: this.chapterId || 0,
  2440. sectionId: this.sectionId || 0,
  2441. gradeId: this.gradeId,
  2442. courseId: this.courseId,
  2443. orderGoodsId: this.orderGoodsId,
  2444. examId: this.examId,
  2445. goodsId: this.goodsId,
  2446. questionIds: doWrongQuestionIds,
  2447. recordId: this.recordId,
  2448. type: 2, // 视频课程的传2
  2449. })
  2450. .then((res) => {})
  2451. .catch((err) => {});
  2452. },
  2453. },
  2454. computed: {
  2455. param() {
  2456. return {
  2457. examId: this.examId,
  2458. questionId: this.questionList[this.current]
  2459. ? this.questionList[this.current].questionId
  2460. : undefined,
  2461. goodsId: this.goodsId,
  2462. orderGoodsId: this.orderGoodsId,
  2463. collectQuestionId: this.collectList[this.current]
  2464. ? this.collectList[this.current].collectQuestionId
  2465. : undefined,
  2466. };
  2467. },
  2468. },
  2469. };
  2470. </script>
  2471. <!-- Add "scoped" attribute to limit CSS to this component only -->
  2472. <style scoped lang="scss">
  2473. .course-exam {
  2474. .section {
  2475. overflow: hidden;
  2476. &__header {
  2477. height: 20px;
  2478. margin-top: 20px;
  2479. }
  2480. &__body {
  2481. .explain-record {
  2482. &__header {
  2483. }
  2484. &__body {
  2485. border: 1px solid #eee;
  2486. .left-box {
  2487. position: relative;
  2488. float: left;
  2489. width: 970px;
  2490. min-height: 630px;
  2491. border: 1px solid #eee;
  2492. &__body {
  2493. border-bottom: 1px solid #eee;
  2494. .question {
  2495. padding: 12px 0 0 12px;
  2496. display: flex;
  2497. flex-direction: column;
  2498. height: 100%;
  2499. &__title {
  2500. padding-left: 12px;
  2501. font-size: 16px;
  2502. font-family: Microsoft YaHei;
  2503. font-weight: bold;
  2504. color: #333333;
  2505. line-height: 24px;
  2506. }
  2507. &__desc {
  2508. padding-left: 12px;
  2509. margin-top: 20px;
  2510. font-size: 16px;
  2511. font-family: Microsoft YaHei;
  2512. font-weight: 400;
  2513. color: #666666;
  2514. line-height: 24px;
  2515. text-align: justify;
  2516. /deep/ img {
  2517. max-width: 100% !important;
  2518. }
  2519. }
  2520. &__content {
  2521. /deep/ .el-tabs__item {
  2522. padding: 0 20px !important;
  2523. height: 40px;
  2524. line-height: 40px;
  2525. }
  2526. .question__content {
  2527. height: auto;
  2528. overflow: auto;
  2529. }
  2530. .question-list {
  2531. padding: 24px 0 24px 24px;
  2532. border-bottom: 1px solid #eee;
  2533. .checkbox,
  2534. .radio {
  2535. cursor: pointer;
  2536. margin-right: 24px;
  2537. padding: 0 24px;
  2538. display: flex;
  2539. align-items: center;
  2540. margin-top: 2px;
  2541. min-height: 40px;
  2542. padding-top: 10px;
  2543. padding-bottom: 10px;
  2544. background: #f5f9ff;
  2545. border-radius: 8px;
  2546. box-sizing: border-box;
  2547. &.right {
  2548. background: #37c65b;
  2549. }
  2550. &.wrong {
  2551. background: #ff3a30;
  2552. }
  2553. &.user_choose {
  2554. background: #007aff;
  2555. }
  2556. }
  2557. &.textarea {
  2558. margin-right: 12px;
  2559. .upload {
  2560. margin-top: 10px;
  2561. &__imgs {
  2562. margin-right: 10px;
  2563. width: 80px;
  2564. height: 80px;
  2565. background: #ffffff;
  2566. border: 1px solid #eeeeee;
  2567. border-radius: 4px;
  2568. position: relative;
  2569. display: flex;
  2570. float: left;
  2571. align-items: center;
  2572. justify-content: center;
  2573. img {
  2574. max-width: 100%;
  2575. max-height: 100%;
  2576. }
  2577. }
  2578. &__btn {
  2579. margin-right: 10px;
  2580. width: 80px;
  2581. height: 80px;
  2582. background: #ffffff;
  2583. border: 1px solid #eeeeee;
  2584. border-radius: 4px;
  2585. position: relative;
  2586. display: flex;
  2587. float: left;
  2588. align-items: center;
  2589. justify-content: center;
  2590. flex-direction: column;
  2591. .icon {
  2592. font-size: 20px;
  2593. color: #3f8dfd;
  2594. }
  2595. p {
  2596. font-size: 12px;
  2597. font-family: Microsoft YaHei;
  2598. font-weight: 400;
  2599. color: #999999;
  2600. line-height: 24px;
  2601. }
  2602. input {
  2603. position: absolute;
  2604. left: 0;
  2605. top: 0;
  2606. display: block;
  2607. width: 100%;
  2608. height: 100%;
  2609. opacity: 0;
  2610. }
  2611. }
  2612. }
  2613. }
  2614. /deep/
  2615. .el-checkbox__input.is-checked
  2616. + .el-checkbox__label {
  2617. color: #000 !important;
  2618. }
  2619. /deep/
  2620. .el-checkbox__input.is-disabled
  2621. + span.el-checkbox__label {
  2622. color: #000;
  2623. }
  2624. /deep/ .el-checkbox {
  2625. white-space: normal;
  2626. }
  2627. }
  2628. .answer-list {
  2629. height: 40px;
  2630. // border-top: 1px solid #eee;
  2631. border-bottom: 1px solid #eee;
  2632. // margin-top: 24px;
  2633. display: flex;
  2634. align-items: center;
  2635. justify-content: space-between;
  2636. padding: 0 24px;
  2637. &__left {
  2638. font-size: 16px;
  2639. font-family: Microsoft YaHei;
  2640. font-weight: 400;
  2641. color: #333333;
  2642. line-height: 24px;
  2643. }
  2644. &__right {
  2645. font-size: 16px;
  2646. font-family: Microsoft YaHei;
  2647. font-weight: 400;
  2648. color: #333333;
  2649. line-height: 24px;
  2650. }
  2651. }
  2652. .explain-list {
  2653. padding: 12px 24px;
  2654. &__header {
  2655. font-size: 16px;
  2656. font-family: Microsoft YaHei;
  2657. font-weight: bold;
  2658. color: #666666;
  2659. line-height: 24px;
  2660. }
  2661. &__body {
  2662. margin-top: 12px;
  2663. font-size: 16px;
  2664. font-family: Microsoft YaHei;
  2665. font-weight: 400;
  2666. color: #666666;
  2667. line-height: 24px;
  2668. }
  2669. .upload {
  2670. margin-top: 10px;
  2671. &__imgs {
  2672. margin-right: 10px;
  2673. width: 80px;
  2674. height: 80px;
  2675. background: #ffffff;
  2676. border: 1px solid #eeeeee;
  2677. border-radius: 4px;
  2678. position: relative;
  2679. display: flex;
  2680. float: left;
  2681. align-items: center;
  2682. justify-content: center;
  2683. img {
  2684. max-width: 100%;
  2685. max-height: 100%;
  2686. }
  2687. }
  2688. }
  2689. }
  2690. .question {
  2691. padding-bottom: 58px;
  2692. }
  2693. }
  2694. &__btns {
  2695. position: relative;
  2696. height: 32px;
  2697. .submit {
  2698. cursor: pointer;
  2699. margin: 0 auto;
  2700. width: 140px;
  2701. height: 32px;
  2702. background: #3f8dfd;
  2703. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2);
  2704. border-radius: 16px;
  2705. text-align: center;
  2706. line-height: 32px;
  2707. color: #fff;
  2708. font-size: 16px;
  2709. }
  2710. .collect {
  2711. cursor: pointer;
  2712. position: absolute;
  2713. right: 0;
  2714. top: 5px;
  2715. font-size: 12px;
  2716. font-family: Microsoft YaHei;
  2717. font-weight: 400;
  2718. color: #3f8dfd;
  2719. line-height: 24px;
  2720. }
  2721. }
  2722. }
  2723. }
  2724. }
  2725. .right-box {
  2726. float: right;
  2727. width: 299px;
  2728. border-right: 1px solid #eee;
  2729. &__header {
  2730. height: 40px;
  2731. line-height: 40px;
  2732. border-bottom: 1px solid #eeeeee;
  2733. padding: 0 10px;
  2734. .back-btn {
  2735. display: block;
  2736. margin: 0 auto;
  2737. width: 160px;
  2738. }
  2739. .title {
  2740. float: left;
  2741. font-size: 16px;
  2742. font-family: Microsoft YaHei;
  2743. font-weight: bold;
  2744. color: #333333;
  2745. float: left;
  2746. }
  2747. .time {
  2748. font-size: 16px;
  2749. font-family: Microsoft YaHei;
  2750. font-weight: 400;
  2751. color: #666666;
  2752. float: right;
  2753. }
  2754. }
  2755. &__body {
  2756. border-bottom: 1px solid #eee;
  2757. height: 510px;
  2758. .card {
  2759. &__note {
  2760. display: flex;
  2761. height: 64px;
  2762. align-items: center;
  2763. border-bottom: 1px solid #eee;
  2764. flex-wrap: wrap;
  2765. .item {
  2766. display: flex;
  2767. align-items: center;
  2768. margin-left: 10px;
  2769. width: 84px;
  2770. font-size: 12px;
  2771. .box {
  2772. margin-right: 5px;
  2773. width: 16px;
  2774. height: 16px;
  2775. border-radius: 4px;
  2776. &.white {
  2777. background: #ffffff;
  2778. border: 1px solid #eeeeee;
  2779. }
  2780. &.green {
  2781. background: #37c65b;
  2782. }
  2783. &.red {
  2784. background: #ff3a30;
  2785. }
  2786. &.yellow {
  2787. background: #ffc53d;
  2788. }
  2789. &.blue,
  2790. &.check_ans {
  2791. background: #3f8dfd;
  2792. }
  2793. }
  2794. }
  2795. }
  2796. &__content {
  2797. height: 440px;
  2798. overflow-y: scroll;
  2799. &::-webkit-scrollbar {
  2800. width: 6px;
  2801. }
  2802. &::-webkit-scrollbar-track {
  2803. background-color: #fff;
  2804. -webkit-border-radius: 2em;
  2805. -moz-border-radius: 2em;
  2806. border-radius: 2em;
  2807. }
  2808. &::-webkit-scrollbar-thumb {
  2809. background-color: #eeeeee;
  2810. -webkit-border-radius: 2em;
  2811. -moz-border-radius: 2em;
  2812. border-radius: 2em;
  2813. }
  2814. .list {
  2815. display: flex;
  2816. flex-wrap: wrap;
  2817. .item {
  2818. width: 40px;
  2819. height: 40px;
  2820. border-radius: 10px;
  2821. text-align: center;
  2822. line-height: 40px;
  2823. margin-left: 16px;
  2824. margin-top: 16px;
  2825. cursor: pointer;
  2826. &.white {
  2827. line-height: 38px;
  2828. color: #333333;
  2829. background: #ffffff;
  2830. border: 1px solid #eeeeee;
  2831. }
  2832. &.green {
  2833. color: #fff;
  2834. background: #37c65b;
  2835. }
  2836. &.red {
  2837. color: #fff;
  2838. background: #ff3a30;
  2839. }
  2840. &.blue,
  2841. &.check_ans {
  2842. color: #fff;
  2843. background: #3f8dfd;
  2844. }
  2845. &.yellow {
  2846. background: #ffc53d;
  2847. }
  2848. &.disabled {
  2849. cursor: not-allowed;
  2850. line-height: 38px;
  2851. color: #eeeeee;
  2852. background: #ffffff;
  2853. border: 1px solid #eeeeee;
  2854. }
  2855. }
  2856. }
  2857. }
  2858. }
  2859. }
  2860. &__footer {
  2861. border-bottom: 1px solid #eee;
  2862. height: 40px;
  2863. display: flex;
  2864. align-items: center;
  2865. justify-content: center;
  2866. .submit {
  2867. cursor: pointer;
  2868. width: 140px;
  2869. height: 32px;
  2870. background: #3f8dfd;
  2871. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2);
  2872. border-radius: 16px;
  2873. line-height: 32px;
  2874. text-align: center;
  2875. color: #fff;
  2876. font-size: 16px;
  2877. }
  2878. }
  2879. }
  2880. }
  2881. }
  2882. }
  2883. }
  2884. .take-photo {
  2885. /deep/ .el-dialog__header {
  2886. display: none;
  2887. }
  2888. /deep/ .el-dialog__body {
  2889. padding: 0;
  2890. overflow: unset;
  2891. }
  2892. &__close {
  2893. cursor: pointer;
  2894. position: absolute;
  2895. right: 0;
  2896. top: -28px;
  2897. width: 24px;
  2898. height: 24px;
  2899. line-height: 24px;
  2900. text-align: center;
  2901. color: #eee;
  2902. border: 1px solid #eee;
  2903. border-radius: 50%;
  2904. }
  2905. &__header {
  2906. height: 40px;
  2907. border-bottom: 1px solid #eee;
  2908. line-height: 40px;
  2909. font-size: 16px;
  2910. font-family: Microsoft YaHei;
  2911. font-weight: bold;
  2912. color: #333333;
  2913. padding-left: 24px;
  2914. }
  2915. &__body {
  2916. // height: 400px;
  2917. padding: 40px 24px;
  2918. .left-box {
  2919. width: 336px;
  2920. float: left;
  2921. .title {
  2922. font-size: 16px;
  2923. font-family: Microsoft YaHei;
  2924. font-weight: bold;
  2925. color: #ff3b30;
  2926. line-height: 24px;
  2927. }
  2928. .content {
  2929. font-size: 14px;
  2930. font-family: Microsoft YaHei;
  2931. font-weight: 400;
  2932. color: #333333;
  2933. line-height: 28px;
  2934. margin-top: 32px;
  2935. }
  2936. }
  2937. .right-box {
  2938. float: right;
  2939. width: 400px;
  2940. height: 400px;
  2941. position: relative;
  2942. overflow: hidden;
  2943. video {
  2944. width: 100%;
  2945. height: 100%;
  2946. }
  2947. .mask {
  2948. width: 55%;
  2949. height: 200px;
  2950. position: absolute;
  2951. top: 0;
  2952. left: 0;
  2953. right: 0;
  2954. bottom: 0;
  2955. margin: 30px auto 0;
  2956. box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
  2957. }
  2958. }
  2959. }
  2960. &__footer {
  2961. height: 90px;
  2962. border-top: 1px solid #eee;
  2963. text-align: center;
  2964. .take {
  2965. display: inline-block;
  2966. width: 200px;
  2967. height: 40px;
  2968. padding: 0;
  2969. border-radius: 20px;
  2970. text-align: center;
  2971. line-height: 40px;
  2972. margin: 24px auto;
  2973. }
  2974. }
  2975. }
  2976. }
  2977. </style>