index.vue 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  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. <div class="left-box__header">
  21. <!-- <el-progress
  22. class="progress"
  23. :text-inside="true"
  24. :stroke-width="26"
  25. :percentage="
  26. toFixed(
  27. (questionOverNum(true) / questionList.length) * 100
  28. ) || 0
  29. "
  30. ></el-progress>
  31. <div class="text">
  32. 已完成<span>{{ questionOverNum(true) }}</span
  33. >/{{ questionList.length }}道题
  34. </div> -->
  35. </div>
  36. <div class="left-box__body">
  37. <template v-for="(question, questionIndex) in questionList">
  38. <div
  39. class="question"
  40. v-if="question.type == 1 && current == questionIndex"
  41. :key="questionIndex"
  42. >
  43. <div class="question__title">
  44. {{ questionIndex + 1 }}、单选题
  45. </div>
  46. <div
  47. class="question__desc"
  48. v-html="question.content"
  49. ></div>
  50. <div class="question__content">
  51. <div class="question-list" v-if="!question.ques">
  52. <div
  53. class="radio"
  54. v-for="(item, index) in question.jsonStr"
  55. :key="index"
  56. >
  57. <div>{{ ast[index] }}. {{ item.content }}</div>
  58. </div>
  59. </div>
  60. <div class="question-list" v-if="question.ques">
  61. <div
  62. class="radio"
  63. :class="{
  64. right:
  65. item.optionsId == question.ques ||
  66. item.optionsId == question.ans,
  67. wrong:
  68. item.optionsId == question.ques &&
  69. question.ques != question.ans,
  70. }"
  71. v-for="(item, index) in question.jsonStr"
  72. :key="index"
  73. >
  74. <div>{{ ast[index] }}. {{ item.content }}</div>
  75. </div>
  76. </div>
  77. <div class="answer-list">
  78. <div class="answer-list__left">
  79. 正确答案:{{ ast[question.ans - 1] }}
  80. </div>
  81. <!-- <div class="answer-list__left">
  82. 我的答案:{{ ast[question.ques - 1] }}
  83. </div> -->
  84. </div>
  85. <div class="explain-list">
  86. <div class="explain-list__header">答案解析:</div>
  87. <div
  88. class="explain-list__body"
  89. v-html="question.analysisContent"
  90. ></div>
  91. </div>
  92. </div>
  93. <div class="question__btns"></div>
  94. </div>
  95. <div
  96. class="question"
  97. v-if="question.type == 2 && current == questionIndex"
  98. :key="questionIndex"
  99. >
  100. <div class="question__title">
  101. {{ questionIndex + 1 }}、多选题
  102. </div>
  103. <div
  104. class="question__desc"
  105. v-html="question.content"
  106. ></div>
  107. <div class="question__content">
  108. <div class="question-list" v-if="!question.ques">
  109. <el-checkbox
  110. disabled
  111. class="checkbox"
  112. v-for="(item, index) in question.jsonStr"
  113. :key="index"
  114. :label="item.optionsId"
  115. v-model="item.checked"
  116. >
  117. <div>{{ ast[index] }}. {{ item.content }}</div>
  118. </el-checkbox>
  119. </div>
  120. <div class="question-list" v-if="question.ques">
  121. <el-checkbox
  122. disabled
  123. class="checkbox"
  124. :class="{
  125. right:
  126. question.ques.indexOf(item.optionsId) != -1 ||
  127. question.ans.indexOf(item.optionsId) != -1,
  128. wrong:
  129. question.ques.indexOf(item.optionsId) != -1 &&
  130. question.ans.indexOf(item.optionsId) == -1,
  131. }"
  132. v-for="(item, index) in question.jsonStr"
  133. :key="index"
  134. :label="item.optionsId"
  135. v-model="item.checked"
  136. >
  137. <div>{{ ast[index] }}. {{ item.content }}</div>
  138. </el-checkbox>
  139. </div>
  140. <div class="answer-list">
  141. <div class="answer-list__left">
  142. 正确答案:
  143. <template v-for="ansItem in question.ans">{{
  144. ast[ansItem - 1]
  145. }}</template>
  146. </div>
  147. <!-- <div class="answer-list__left">
  148. 我的答案:
  149. <template v-for="quesItem in question.ques">{{
  150. ast[quesItem - 1]
  151. }}</template>
  152. </div> -->
  153. </div>
  154. <div class="explain-list">
  155. <div class="explain-list__header">答案解析:</div>
  156. <div
  157. class="explain-list__body"
  158. v-if="question.analysisContent"
  159. ></div>
  160. </div>
  161. </div>
  162. <div class="question__btns"></div>
  163. </div>
  164. <div
  165. class="question"
  166. v-if="question.type == 3 && current == questionIndex"
  167. :key="questionIndex"
  168. >
  169. <div class="question__title">
  170. {{ questionIndex + 1 }}、判断题
  171. </div>
  172. <div
  173. class="question__desc"
  174. v-html="question.content"
  175. ></div>
  176. <div class="question__content">
  177. <div class="question-list" v-if="!question.ques">
  178. <div
  179. class="radio"
  180. v-for="(item, index) in judge"
  181. :key="index"
  182. >
  183. <div>{{ ast[index] }}. {{ item }}</div>
  184. </div>
  185. </div>
  186. <div class="question-list" v-if="question.ques">
  187. <div
  188. class="radio"
  189. :class="{
  190. right:
  191. index == question.ques || index == question.ans,
  192. wrong:
  193. index == question.ques &&
  194. question.ques != question.ans,
  195. }"
  196. v-for="(item, index) in judge"
  197. :key="index"
  198. >
  199. <div>{{ ast[index] }}. {{ item }}</div>
  200. </div>
  201. </div>
  202. <div class="answer-list">
  203. <div class="answer-list__left">
  204. 正确答案:{{ ast[question.ans] }}
  205. </div>
  206. <!-- <div class="answer-list__left">
  207. 我的答案:{{ ast[question.ques] }}
  208. </div> -->
  209. </div>
  210. <div class="explain-list">
  211. <div class="explain-list__header">答案解析:</div>
  212. <div
  213. class="explain-list__body"
  214. v-html="question.analysisContent"
  215. ></div>
  216. </div>
  217. </div>
  218. <div class="question__btns"></div>
  219. </div>
  220. <div
  221. class="question"
  222. v-if="question.type == 4 && current == questionIndex"
  223. :key="questionIndex"
  224. >
  225. <div class="question__title">
  226. {{ questionIndex + 1 }}、案例题
  227. </div>
  228. <div class="question__content">
  229. <el-tabs v-model="question.tabIndex">
  230. <el-tab-pane
  231. v-for="(json, jsonIndex) in question.jsonStr"
  232. :label="'问题' + (jsonIndex + 1)"
  233. :name="jsonIndex + ''"
  234. :key="jsonIndex"
  235. >
  236. <div
  237. class="question"
  238. v-if="json.type == 1"
  239. :key="questionIndex"
  240. >
  241. <div class="question__title">
  242. {{ jsonIndex + 1 }}、单选题
  243. </div>
  244. <div
  245. class="question__desc"
  246. v-html="json.content"
  247. ></div>
  248. <div class="question__content">
  249. <div
  250. class="question-list"
  251. v-if="!question.ques[jsonIndex]"
  252. >
  253. <div
  254. class="radio"
  255. v-for="(item, index) in json.optionsList"
  256. :key="index"
  257. >
  258. <div>
  259. {{ ast[index] }}. {{ item.content }}
  260. </div>
  261. </div>
  262. </div>
  263. <div
  264. class="question-list"
  265. v-if="question.ques[jsonIndex]"
  266. >
  267. <div
  268. class="radio"
  269. :class="{
  270. right:
  271. item.optionsId ==
  272. question.ques[jsonIndex] ||
  273. item.optionsId ==
  274. question.ans[jsonIndex],
  275. wrong:
  276. item.optionsId ==
  277. question.ques[jsonIndex] &&
  278. question.ques[jsonIndex] !=
  279. question.ans[jsonIndex],
  280. }"
  281. v-for="(item, index) in json.optionsList"
  282. :key="index"
  283. >
  284. <div>
  285. {{ ast[index] }}. {{ item.content }}
  286. </div>
  287. </div>
  288. </div>
  289. <div class="answer-list">
  290. <div class="answer-list__left">
  291. 正确答案:{{
  292. ast[question.ans[jsonIndex] - 1]
  293. }}
  294. </div>
  295. <!-- <div class="answer-list__left">
  296. 我的答案:{{
  297. ast[question.ques[jsonIndex] - 1]
  298. }}
  299. </div> -->
  300. </div>
  301. <div class="explain-list">
  302. <div class="explain-list__header">
  303. 答案解析:
  304. </div>
  305. <div
  306. class="explain-list__body"
  307. v-html="json.analysisContent"
  308. ></div>
  309. </div>
  310. </div>
  311. <div class="question__btns"></div>
  312. </div>
  313. <div
  314. class="question"
  315. v-if="json.type == 2"
  316. :key="jsonIndex"
  317. >
  318. <div class="question__title">
  319. {{ jsonIndex + 1 }}、多选题
  320. </div>
  321. <div
  322. class="question__desc"
  323. v-html="json.content"
  324. ></div>
  325. <div class="question__content">
  326. <div
  327. class="question-list"
  328. v-if="!question.ques[jsonIndex]"
  329. >
  330. <el-checkbox
  331. disabled
  332. class="checkbox"
  333. v-for="(item, index) in json.optionsList"
  334. :key="index"
  335. :label="item.optionsId"
  336. v-model="item.checked"
  337. >
  338. <div>
  339. {{ ast[index] }}. {{ item.content }}
  340. </div>
  341. </el-checkbox>
  342. </div>
  343. <div
  344. class="question-list"
  345. v-if="question.ques[jsonIndex]"
  346. >
  347. <el-checkbox
  348. disabled
  349. class="checkbox"
  350. :class="{
  351. right:
  352. question.ques[jsonIndex].indexOf(
  353. item.optionsId
  354. ) != -1 ||
  355. question.ans[jsonIndex].indexOf(
  356. item.optionsId
  357. ) != -1,
  358. wrong:
  359. question.ques[jsonIndex].indexOf(
  360. item.optionsId
  361. ) != -1 &&
  362. question.ans[jsonIndex].indexOf(
  363. item.optionsId
  364. ) == -1,
  365. }"
  366. v-for="(item, index) in json.optionsList"
  367. :key="index"
  368. :label="item.optionsId"
  369. v-model="item.checked"
  370. >
  371. <div>
  372. {{ ast[index] }}. {{ item.content }}
  373. </div>
  374. </el-checkbox>
  375. </div>
  376. <div class="answer-list">
  377. <div class="answer-list__left">
  378. 正确答案:
  379. <template
  380. v-for="ansItem in question.ans[jsonIndex]"
  381. >{{ ast[ansItem - 1] }}</template
  382. >
  383. </div>
  384. <!-- <div class="answer-list__left">
  385. 我的答案:
  386. <template
  387. v-for="quesItem in question.ques[
  388. jsonIndex
  389. ]"
  390. >{{ ast[quesItem - 1] }}</template
  391. >
  392. </div> -->
  393. </div>
  394. <div class="explain-list">
  395. <div class="explain-list__header">
  396. 答案解析:
  397. </div>
  398. <div
  399. class="explain-list__body"
  400. v-html="json.analysisContent"
  401. ></div>
  402. </div>
  403. </div>
  404. <div class="question__btns"></div>
  405. </div>
  406. <div
  407. class="question"
  408. v-if="json.type == 3"
  409. :key="jsonIndex"
  410. >
  411. <div class="question__title">
  412. {{ jsonIndex + 1 }}、判断题
  413. </div>
  414. <div
  415. class="question__desc"
  416. v-html="json.content"
  417. ></div>
  418. <div class="question__content">
  419. <div
  420. class="question-list"
  421. v-if="!question.ques[jsonIndex]"
  422. >
  423. <div
  424. class="radio"
  425. v-for="(item, index) in judge"
  426. :key="index"
  427. >
  428. <div>{{ ast[index] }}. {{ item }}</div>
  429. </div>
  430. </div>
  431. <div
  432. class="question-list"
  433. v-if="question.ques[jsonIndex]"
  434. >
  435. <div
  436. class="radio"
  437. :class="{
  438. right:
  439. index == question.ques[jsonIndex] ||
  440. index == question.ans[jsonIndex],
  441. wrong:
  442. index == question.ques[jsonIndex] &&
  443. question.ques[jsonIndex] !=
  444. question.ans[jsonIndex],
  445. }"
  446. v-for="(item, index) in judge"
  447. :key="index"
  448. >
  449. <div>{{ ast[index] }}. {{ item }}</div>
  450. </div>
  451. </div>
  452. <div class="answer-list">
  453. <div class="answer-list__left">
  454. 正确答案:{{ ast[question.ans[jsonIndex]] }}
  455. </div>
  456. <!-- <div class="answer-list__left">
  457. 我的答案:{{
  458. ast[question.ques[jsonIndex]]
  459. }}
  460. </div> -->
  461. </div>
  462. <div class="explain-list">
  463. <div class="explain-list__header">
  464. 答案解析:
  465. </div>
  466. <div
  467. class="explain-list__body"
  468. v-html="json.analysisContent"
  469. ></div>
  470. </div>
  471. </div>
  472. <div class="question__btns"></div>
  473. </div>
  474. <div
  475. class="question"
  476. v-if="json.type == 5"
  477. :key="jsonIndex"
  478. >
  479. <div class="question__title">
  480. {{ jsonIndex }}、简答题
  481. </div>
  482. <div
  483. class="question__desc"
  484. v-html="json.content"
  485. ></div>
  486. <div class="question__content">
  487. <div class="explain-list">
  488. <div class="explain-list__header">
  489. 我的答案:
  490. </div>
  491. <div class="explain-list__body">
  492. <div>
  493. {{
  494. question.ques[jsonIndex] &&
  495. question.ques[jsonIndex].text
  496. }}
  497. </div>
  498. <div class="upload clearfix">
  499. <div
  500. class="upload__imgs"
  501. v-for="(img, imgIndex) in question.ques[
  502. jsonIndex
  503. ] && question.ques[jsonIndex].imageList"
  504. :key="imgIndex"
  505. >
  506. <img
  507. :src="$tools.splitImgHost(img, true)"
  508. alt=""
  509. />
  510. </div>
  511. </div>
  512. </div>
  513. <div class="explain-list__header">
  514. 答案解析:
  515. </div>
  516. <div
  517. class="explain-list__body"
  518. v-html="question.analysisContent"
  519. ></div>
  520. </div>
  521. </div>
  522. <div class="question__btns"></div>
  523. </div>
  524. </el-tab-pane>
  525. </el-tabs>
  526. </div>
  527. <div class="question__btns"></div>
  528. </div>
  529. <div
  530. class="question"
  531. v-if="question.type == 5 && current == questionIndex"
  532. :key="questionIndex"
  533. >
  534. <div class="question__title">
  535. {{ questionIndex }}、简答题
  536. </div>
  537. <div
  538. class="question__desc"
  539. v-html="question.content"
  540. ></div>
  541. <div class="question__content">
  542. <div class="explain-list">
  543. <!-- <div class="explain-list__header">我的答案:</div>
  544. <div class="explain-list__body">
  545. <div>{{ question.ques.text }}</div>
  546. <div class="upload clearfix">
  547. <div
  548. class="upload__imgs"
  549. v-for="(img, imgIndex) in question.ques
  550. .imageList"
  551. :key="imgIndex"
  552. >
  553. <img
  554. :src="$tools.splitImgHost(img, true)"
  555. alt=""
  556. />
  557. </div>
  558. </div>
  559. </div> -->
  560. <div class="explain-list__header">答案解析:</div>
  561. <div
  562. class="explain-list__body"
  563. v-html="question.analysisContent"
  564. ></div>
  565. </div>
  566. </div>
  567. <div class="question__btns"></div>
  568. </div>
  569. </template>
  570. </div>
  571. <div class="left-box__footer">
  572. <div class="btn" @click="prevQuestion">上一题</div>
  573. <div class="btn" @click="nextQuestion">下一题</div>
  574. </div>
  575. </div>
  576. <div class="right-box">
  577. <div class="right-box__header">
  578. <el-button
  579. type="primary"
  580. round
  581. plain
  582. size="small"
  583. class="back-btn"
  584. @click="$router.back(-1)"
  585. >返回</el-button
  586. >
  587. </div>
  588. <div class="right-box__header">答题卡</div>
  589. <div class="right-box__body">
  590. <div class="card">
  591. <div class="card__note">
  592. <div class="item">
  593. <div class="box green"></div>
  594. 正确
  595. </div>
  596. <div class="item">
  597. <div class="box red"></div>
  598. 错误
  599. </div>
  600. <div class="item">
  601. <div class="box blue"></div>
  602. 已做未评改
  603. </div>
  604. <div class="item">
  605. <div class="box white"></div>
  606. 未做
  607. </div>
  608. </div>
  609. <div class="card__content">
  610. <ul class="list">
  611. <li
  612. class="item white"
  613. v-for="(item, index) in questionList"
  614. :key="index"
  615. :class="{
  616. green: isRight(item, index),
  617. red: isWrong(item, index),
  618. blue: isOver(item, index),
  619. }"
  620. @click="changeIndex(index)"
  621. >
  622. {{ index + 1 }}
  623. </li>
  624. </ul>
  625. </div>
  626. </div>
  627. </div>
  628. <div class="right-box__footer"></div>
  629. </div>
  630. </div>
  631. </div>
  632. </div>
  633. </div>
  634. </section>
  635. <ToolBar></ToolBar>
  636. <Footer></Footer>
  637. </div>
  638. </template>
  639. <script>
  640. import Footer from "@/components/footer/index";
  641. import Header from "@/components/header/index";
  642. import ToolBar from "@/components/toolbar/index";
  643. import { mapMutations } from "vuex";
  644. export default {
  645. name: "BankExplain",
  646. components: {
  647. Footer,
  648. Header,
  649. ToolBar,
  650. },
  651. data() {
  652. return {
  653. checked: false,
  654. questionList: [],
  655. judge: ["错误", "正确"],
  656. ast: ["A", "B", "C", "D", "E", "F", "G"],
  657. examId: 0,
  658. goodsId: 0,
  659. moduleId: 0,
  660. chapterId: 0,
  661. current: 0,
  662. };
  663. },
  664. async mounted() {
  665. this.recordId = this.$route.params.recordId;
  666. this.examId = this.$route.query.examId;
  667. this.moduleId = this.$route.query.moduleId;
  668. this.chapterId = this.$route.query.chapterId;
  669. this.goodsId = this.$route.query.goodsId;
  670. this.goodsQuestionList();
  671. },
  672. methods: {
  673. ...mapMutations(["setExamResult"]),
  674. toFixed(num) {
  675. if (num) {
  676. let str = String(num).indexOf(".");
  677. if (str != -1) {
  678. return +num.toFixed(2);
  679. } else {
  680. return num;
  681. }
  682. } else {
  683. return 0;
  684. }
  685. },
  686. changeIndex(index) {
  687. this.current = index;
  688. },
  689. /**
  690. * 请求题目列表
  691. */
  692. goodsQuestionList() {
  693. this.$request
  694. .goodsQuestionList({
  695. examId: this.examId,
  696. })
  697. .then(async (res) => {
  698. res.data.forEach((item, index) => {
  699. if (typeof item.jsonStr == "string") {
  700. item.jsonStr = JSON.parse(item.jsonStr);
  701. if (item.type == 2) {
  702. //多选
  703. item.jsonStr.forEach((str) => {
  704. str.optionsId = "" + str.optionsId;
  705. });
  706. let arr = item.answerQuestion.split(",");
  707. arr.forEach((a, i) => {
  708. arr[i] = "" + a;
  709. });
  710. item.ans = arr;
  711. item.ques = item.ans;
  712. return;
  713. } else if (item.type == 5) {
  714. item.ansText = {
  715. text: item.analysisContent,
  716. imageList: [],
  717. };
  718. item.ques = {
  719. text: item.analysisContent,
  720. imageList: [],
  721. };
  722. return;
  723. } else if (item.type == 4) {
  724. console.log(item.jsonStr);
  725. item.ques = [];
  726. item.current = 0;
  727. let ansArr = [];
  728. item.jsonStr.forEach((json, index) => {
  729. if (json.type == 1) {
  730. ansArr[index] = json.answerQuestion;
  731. } else if (json.type == 2) {
  732. json.optionsList.forEach((str) => {
  733. str.optionsId = "" + str.optionsId;
  734. });
  735. let arr = json.answerQuestion.split(",");
  736. arr.forEach((a, i) => {
  737. arr[i] = "" + a;
  738. });
  739. ansArr[index] = arr;
  740. } else if (json.type == 3) {
  741. ansArr[index] = json.answerQuestion;
  742. } else if (json.type == 5) {
  743. ansArr[index] = {
  744. text: "",
  745. imageList: [],
  746. };
  747. json.ansText = {
  748. text: "",
  749. imageList: [],
  750. };
  751. }
  752. });
  753. item.ans = ansArr;
  754. item.ques = item.ans;
  755. return;
  756. }
  757. item.ans = item.answerQuestion;
  758. item.ques = item.ans;
  759. } else {
  760. item.ques = item.ans;
  761. }
  762. });
  763. this.questionList = res.data;
  764. });
  765. },
  766. nextQuestion() {
  767. if (this.current >= this.questionList.length - 1) {
  768. this.$message({
  769. type: "warning",
  770. message: "已经是最后一题了!",
  771. });
  772. return;
  773. }
  774. this.current++;
  775. },
  776. prevQuestion() {
  777. if (this.current == 0) {
  778. this.$message({
  779. type: "warning",
  780. message: "已经是第一题了!",
  781. });
  782. return;
  783. } else {
  784. this.current--;
  785. }
  786. },
  787. isOver(item, index) {
  788. if (this.questionList[index].ques) {
  789. if (item.type == 4) {
  790. //案例题
  791. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  792. if (
  793. jsonItem.type == 1 ||
  794. jsonItem.type == 2 ||
  795. jsonItem.type == 3
  796. ) {
  797. if (item.ques[indexs]) {
  798. return true;
  799. } else {
  800. return false;
  801. }
  802. } else if (jsonItem.type == 5) {
  803. // if (
  804. // item.ques[indexs] &&
  805. // (item.ques[indexs].text || item.ques[indexs].imageList.length)
  806. // ) {
  807. // console.log("chil");
  808. // return true;
  809. // } else {
  810. // return false;
  811. // }
  812. }
  813. });
  814. if (isOver) {
  815. return true;
  816. } else {
  817. return false;
  818. }
  819. } else if (item.type == 5) {
  820. //简答题
  821. //每一项都相等
  822. // if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  823. // return true;
  824. // }
  825. //判断
  826. } else {
  827. return false;
  828. }
  829. } else {
  830. return false;
  831. }
  832. },
  833. isRight(item, index) {
  834. //单选
  835. if (this.questionList[index].ques) {
  836. if (item.type == 1) {
  837. console.log(
  838. this.questionList[index].ques == this.questionList[index].ans
  839. );
  840. return this.questionList[index].ques == this.questionList[index].ans;
  841. //多选
  842. } else if (item.type == 2) {
  843. //每一项都相等
  844. return this.questionList[index].ans.every((item, i) => {
  845. return item == this.questionList[index].ques[i];
  846. });
  847. //判断
  848. } else if (item.type == 3) {
  849. return this.questionList[index].ques == this.questionList[index].ans;
  850. } else {
  851. return false;
  852. }
  853. } else {
  854. return false;
  855. }
  856. },
  857. isWrong(item, index) {
  858. if (this.questionList[index].ques) {
  859. //单选
  860. if (item.type == 1) {
  861. return this.questionList[index].ques != this.questionList[index].ans;
  862. //多选
  863. } else if (item.type == 2) {
  864. //每一项都相等
  865. return this.questionList[index].ans.some((item, i) => {
  866. return item != this.questionList[index].ques[i];
  867. });
  868. //判断
  869. } else if (item.type == 3) {
  870. return this.questionList[index].ques != this.questionList[index].ans;
  871. } else {
  872. return false;
  873. }
  874. } else {
  875. return false;
  876. }
  877. },
  878. right(bankIndex, ansIndex, option) {
  879. if (
  880. this.questionList[bankIndex].ques[ansIndex] &&
  881. this.questionList[bankIndex].ans[ansIndex]
  882. ) {
  883. if (
  884. this.questionList[bankIndex].ques[ansIndex].indexOf(
  885. option.optionsId
  886. ) != -1 ||
  887. this.questionList[bankIndex].ans[ansIndex].indexOf(
  888. option.optionsId
  889. ) != -1
  890. ) {
  891. return true;
  892. } else {
  893. return false;
  894. }
  895. } else {
  896. return false;
  897. }
  898. },
  899. wrong(bankIndex, ansIndex, option) {
  900. if (
  901. this.questionList[bankIndex].ques[ansIndex] &&
  902. this.questionList[bankIndex].ans[ansIndex]
  903. ) {
  904. if (
  905. this.questionList[bankIndex].ques[ansIndex].indexOf(
  906. option.optionsId
  907. ) != -1 &&
  908. this.questionList[bankIndex].ans[ansIndex].indexOf(
  909. option.optionsId
  910. ) == -1
  911. ) {
  912. return true;
  913. } else {
  914. return false;
  915. }
  916. } else {
  917. return false;
  918. }
  919. },
  920. /**
  921. * 获取已经回答的题目数
  922. * hasSpecail (是否包含简答和案例)
  923. */
  924. questionOverNum(hasSpecail) {
  925. let count = 0;
  926. this.questionList.forEach((item) => {
  927. if (item.type == 1 || item.type == 2 || item.type == 3) {
  928. if (item.ques) {
  929. count++;
  930. }
  931. } else if (item.type == 4) {
  932. //案例题
  933. if (hasSpecail) {
  934. let isOver = item.jsonStr.every((jsonItem, index) => {
  935. if (
  936. jsonItem.type == 1 ||
  937. jsonItem.type == 2 ||
  938. jsonItem.type == 3
  939. ) {
  940. if (item.ques[index]) {
  941. return true;
  942. } else {
  943. return false;
  944. }
  945. } else if (jsonItem.type == 5) {
  946. // if (
  947. // item.ques[index] &&
  948. // (item.ques[index].text || item.ques[index].imageList.length)
  949. // ) {
  950. // return true;
  951. // } else {
  952. // return false;
  953. // }
  954. }
  955. });
  956. if (isOver) {
  957. count++;
  958. console.log(item, 444);
  959. }
  960. }
  961. } else if (item.type == 5) {
  962. //简答题
  963. if (hasSpecail) {
  964. // if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  965. // console.log(5, item);
  966. // count++;
  967. // }
  968. }
  969. }
  970. });
  971. return count;
  972. },
  973. },
  974. };
  975. </script>
  976. <!-- Add "scoped" attribute to limit CSS to this component only -->
  977. <style scoped lang="scss">
  978. .course-exam {
  979. .section {
  980. overflow: hidden;
  981. &__header {
  982. height: 20px;
  983. margin-top: 20px;
  984. }
  985. &__body {
  986. .explain-record {
  987. &__header {
  988. }
  989. &__body {
  990. height: 800px;
  991. border: 1px solid #eee;
  992. .left-box {
  993. float: left;
  994. width: 970px;
  995. border-right: 1px solid #eee;
  996. &__header {
  997. height: 40px;
  998. padding-left: 12px;
  999. border-bottom: 1px solid #eeeeee;
  1000. display: flex;
  1001. align-items: center;
  1002. .progress {
  1003. width: 636px;
  1004. }
  1005. .text {
  1006. margin-left: 15px;
  1007. font-size: 16px;
  1008. span {
  1009. font-family: Microsoft YaHei;
  1010. font-weight: bold;
  1011. color: #3f8dfd;
  1012. line-height: 24px;
  1013. }
  1014. }
  1015. }
  1016. &__body {
  1017. height: 720px;
  1018. border-bottom: 1px solid #eee;
  1019. .question {
  1020. padding: 12px 0 0 12px;
  1021. display: flex;
  1022. flex-direction: column;
  1023. height: 100%;
  1024. &__title {
  1025. padding-left: 12px;
  1026. font-size: 16px;
  1027. font-family: Microsoft YaHei;
  1028. font-weight: bold;
  1029. color: #333333;
  1030. line-height: 24px;
  1031. }
  1032. &__desc {
  1033. padding-left: 12px;
  1034. margin-top: 20px;
  1035. font-size: 16px;
  1036. font-family: Microsoft YaHei;
  1037. font-weight: 400;
  1038. color: #666666;
  1039. line-height: 24px;
  1040. /deep/ img {
  1041. max-width: 100% !important;
  1042. max-height: 400px !important;
  1043. }
  1044. }
  1045. &__content {
  1046. flex: 1;
  1047. overflow-y: scroll;
  1048. &::-webkit-scrollbar {
  1049. width: 6px;
  1050. }
  1051. &::-webkit-scrollbar-track {
  1052. background-color: #fff;
  1053. -webkit-border-radius: 2em;
  1054. -moz-border-radius: 2em;
  1055. border-radius: 2em;
  1056. }
  1057. &::-webkit-scrollbar-thumb {
  1058. background-color: #eeeeee;
  1059. -webkit-border-radius: 2em;
  1060. -moz-border-radius: 2em;
  1061. border-radius: 2em;
  1062. }
  1063. /deep/ .el-tabs__item {
  1064. padding: 0 20px !important;
  1065. height: 40px;
  1066. line-height: 40px;
  1067. }
  1068. .question__content {
  1069. height: auto;
  1070. overflow: auto;
  1071. }
  1072. .question-list {
  1073. padding: 24px 0 0 24px;
  1074. .checkbox,
  1075. .radio {
  1076. cursor: pointer;
  1077. margin-right: 24px;
  1078. padding: 0 24px;
  1079. display: flex;
  1080. align-items: center;
  1081. margin-top: 2px;
  1082. min-height: 40px;
  1083. padding-top: 10px;
  1084. padding-bottom: 10px;
  1085. background: #f5f9ff;
  1086. border-radius: 8px;
  1087. box-sizing: border-box;
  1088. &.right {
  1089. background: #37c65b;
  1090. }
  1091. &.wrong {
  1092. background: #ff3a30;
  1093. }
  1094. }
  1095. &.textarea {
  1096. margin-right: 12px;
  1097. .upload {
  1098. margin-top: 10px;
  1099. &__imgs {
  1100. margin-right: 10px;
  1101. width: 80px;
  1102. height: 80px;
  1103. background: #ffffff;
  1104. border: 1px solid #eeeeee;
  1105. border-radius: 4px;
  1106. position: relative;
  1107. display: flex;
  1108. float: left;
  1109. align-items: center;
  1110. justify-content: center;
  1111. img {
  1112. max-width: 100%;
  1113. max-height: 100%;
  1114. }
  1115. }
  1116. &__btn {
  1117. margin-right: 10px;
  1118. width: 80px;
  1119. height: 80px;
  1120. background: #ffffff;
  1121. border: 1px solid #eeeeee;
  1122. border-radius: 4px;
  1123. position: relative;
  1124. display: flex;
  1125. float: left;
  1126. align-items: center;
  1127. justify-content: center;
  1128. flex-direction: column;
  1129. .icon {
  1130. font-size: 20px;
  1131. color: #3f8dfd;
  1132. }
  1133. p {
  1134. font-size: 12px;
  1135. font-family: Microsoft YaHei;
  1136. font-weight: 400;
  1137. color: #999999;
  1138. line-height: 24px;
  1139. }
  1140. input {
  1141. position: absolute;
  1142. left: 0;
  1143. top: 0;
  1144. display: block;
  1145. width: 100%;
  1146. height: 100%;
  1147. opacity: 0;
  1148. }
  1149. }
  1150. }
  1151. }
  1152. /deep/ .el-checkbox {
  1153. white-space: pre-wrap;
  1154. }
  1155. }
  1156. .answer-list {
  1157. height: 40px;
  1158. border-top: 1px solid #eee;
  1159. border-bottom: 1px solid #eee;
  1160. margin-top: 24px;
  1161. display: flex;
  1162. align-items: center;
  1163. justify-content: space-between;
  1164. padding: 0 24px;
  1165. &__left {
  1166. font-size: 16px;
  1167. font-family: Microsoft YaHei;
  1168. font-weight: 400;
  1169. color: #333333;
  1170. line-height: 24px;
  1171. }
  1172. &__right {
  1173. font-size: 16px;
  1174. font-family: Microsoft YaHei;
  1175. font-weight: 400;
  1176. color: #333333;
  1177. line-height: 24px;
  1178. }
  1179. }
  1180. .explain-list {
  1181. padding: 12px 24px;
  1182. &__header {
  1183. font-size: 16px;
  1184. font-family: Microsoft YaHei;
  1185. font-weight: bold;
  1186. color: #666666;
  1187. line-height: 24px;
  1188. }
  1189. &__body {
  1190. margin-top: 12px;
  1191. font-size: 16px;
  1192. font-family: Microsoft YaHei;
  1193. font-weight: 400;
  1194. color: #666666;
  1195. line-height: 24px;
  1196. }
  1197. .upload {
  1198. margin-top: 10px;
  1199. &__imgs {
  1200. margin-right: 10px;
  1201. width: 80px;
  1202. height: 80px;
  1203. background: #ffffff;
  1204. border: 1px solid #eeeeee;
  1205. border-radius: 4px;
  1206. position: relative;
  1207. display: flex;
  1208. float: left;
  1209. align-items: center;
  1210. justify-content: center;
  1211. img {
  1212. max-width: 100%;
  1213. max-height: 100%;
  1214. }
  1215. }
  1216. }
  1217. }
  1218. }
  1219. &__btns {
  1220. position: relative;
  1221. height: 32px;
  1222. .submit {
  1223. cursor: pointer;
  1224. margin: 0 auto;
  1225. width: 140px;
  1226. height: 32px;
  1227. background: #3f8dfd;
  1228. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2);
  1229. border-radius: 16px;
  1230. text-align: center;
  1231. line-height: 32px;
  1232. color: #fff;
  1233. font-size: 16px;
  1234. }
  1235. .collect {
  1236. cursor: pointer;
  1237. position: absolute;
  1238. right: 0;
  1239. top: 5px;
  1240. font-size: 12px;
  1241. font-family: Microsoft YaHei;
  1242. font-weight: 400;
  1243. color: #3f8dfd;
  1244. line-height: 24px;
  1245. }
  1246. }
  1247. }
  1248. }
  1249. &__footer {
  1250. height: 40px;
  1251. display: flex;
  1252. justify-content: space-around;
  1253. align-items: center;
  1254. .btn {
  1255. cursor: pointer;
  1256. width: 140px;
  1257. height: 32px;
  1258. background: #ffffff;
  1259. border: 1px solid #3f8dfd;
  1260. border-radius: 16px;
  1261. line-height: 32px;
  1262. text-align: center;
  1263. color: #3f8dfd;
  1264. }
  1265. }
  1266. }
  1267. .right-box {
  1268. float: right;
  1269. width: 300px;
  1270. &__header {
  1271. height: 40px;
  1272. line-height: 40px;
  1273. font-size: 16px;
  1274. font-family: Microsoft YaHei;
  1275. font-weight: bold;
  1276. color: #333333;
  1277. text-align: center;
  1278. border-bottom: 1px solid #eeeeee;
  1279. .back-btn {
  1280. width: 160px;
  1281. }
  1282. }
  1283. &__body {
  1284. height: 720px;
  1285. border-bottom: 1px solid #eee;
  1286. .card {
  1287. &__note {
  1288. display: flex;
  1289. height: 40px;
  1290. align-items: center;
  1291. border-bottom: 1px solid #eee;
  1292. .item {
  1293. display: flex;
  1294. align-items: center;
  1295. margin-left: 10px;
  1296. .box {
  1297. margin-right: 5px;
  1298. width: 16px;
  1299. height: 16px;
  1300. border-radius: 4px;
  1301. &.white {
  1302. background: #ffffff;
  1303. border: 1px solid #eeeeee;
  1304. }
  1305. &.green {
  1306. background: #37c65b;
  1307. }
  1308. &.red {
  1309. background: #ff3a30;
  1310. }
  1311. &.blue {
  1312. background: #3f8dfd;
  1313. }
  1314. }
  1315. }
  1316. }
  1317. &__content {
  1318. height: 630px;
  1319. overflow-y: scroll;
  1320. &::-webkit-scrollbar {
  1321. width: 6px;
  1322. }
  1323. &::-webkit-scrollbar-track {
  1324. background-color: #fff;
  1325. -webkit-border-radius: 2em;
  1326. -moz-border-radius: 2em;
  1327. border-radius: 2em;
  1328. }
  1329. &::-webkit-scrollbar-thumb {
  1330. background-color: #eeeeee;
  1331. -webkit-border-radius: 2em;
  1332. -moz-border-radius: 2em;
  1333. border-radius: 2em;
  1334. }
  1335. .list {
  1336. display: flex;
  1337. flex-wrap: wrap;
  1338. .item {
  1339. width: 40px;
  1340. height: 40px;
  1341. border-radius: 10px;
  1342. text-align: center;
  1343. line-height: 40px;
  1344. margin-left: 16px;
  1345. margin-top: 16px;
  1346. cursor: pointer;
  1347. &.white {
  1348. line-height: 38px;
  1349. color: #333333;
  1350. background: #ffffff;
  1351. border: 1px solid #eeeeee;
  1352. }
  1353. &.green {
  1354. color: #fff;
  1355. background: #37c65b;
  1356. }
  1357. &.red {
  1358. color: #fff;
  1359. background: #ff3a30;
  1360. }
  1361. &.blue {
  1362. border: 1rpx solid #eeeeee;
  1363. color: #fff;
  1364. background: #3f8dfd;
  1365. }
  1366. &.disabled {
  1367. cursor: not-allowed;
  1368. line-height: 38px;
  1369. color: #eeeeee;
  1370. background: #ffffff;
  1371. border: 1px solid #eeeeee;
  1372. }
  1373. }
  1374. }
  1375. }
  1376. }
  1377. }
  1378. &__footer {
  1379. height: 40px;
  1380. display: flex;
  1381. align-items: center;
  1382. justify-content: center;
  1383. .submit {
  1384. cursor: pointer;
  1385. width: 140px;
  1386. height: 32px;
  1387. background: #3f8dfd;
  1388. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2);
  1389. border-radius: 16px;
  1390. line-height: 32px;
  1391. text-align: center;
  1392. color: #fff;
  1393. font-size: 16px;
  1394. }
  1395. }
  1396. }
  1397. }
  1398. }
  1399. }
  1400. }
  1401. .take-photo {
  1402. /deep/ .el-dialog__header {
  1403. display: none;
  1404. }
  1405. /deep/ .el-dialog__body {
  1406. padding: 0;
  1407. overflow: unset;
  1408. }
  1409. &__close {
  1410. cursor: pointer;
  1411. position: absolute;
  1412. right: 0;
  1413. top: -28px;
  1414. width: 24px;
  1415. height: 24px;
  1416. line-height: 24px;
  1417. text-align: center;
  1418. color: #eee;
  1419. border: 1px solid #eee;
  1420. border-radius: 50%;
  1421. }
  1422. &__header {
  1423. height: 40px;
  1424. border-bottom: 1px solid #eee;
  1425. line-height: 40px;
  1426. font-size: 16px;
  1427. font-family: Microsoft YaHei;
  1428. font-weight: bold;
  1429. color: #333333;
  1430. padding-left: 24px;
  1431. }
  1432. &__body {
  1433. height: 400px;
  1434. padding: 40px 24px;
  1435. .left-box {
  1436. width: 336px;
  1437. float: left;
  1438. .title {
  1439. font-size: 16px;
  1440. font-family: Microsoft YaHei;
  1441. font-weight: bold;
  1442. color: #ff3b30;
  1443. line-height: 24px;
  1444. }
  1445. .content {
  1446. font-size: 14px;
  1447. font-family: Microsoft YaHei;
  1448. font-weight: 400;
  1449. color: #333333;
  1450. line-height: 28px;
  1451. margin-top: 32px;
  1452. }
  1453. }
  1454. .right-box {
  1455. float: right;
  1456. width: 400px;
  1457. height: 300px;
  1458. video {
  1459. width: 100%;
  1460. height: 100%;
  1461. }
  1462. }
  1463. }
  1464. &__footer {
  1465. height: 90px;
  1466. border-top: 1px solid #eee;
  1467. text-align: center;
  1468. .take {
  1469. display: inline-block;
  1470. width: 200px;
  1471. height: 40px;
  1472. padding: 0;
  1473. border-radius: 20px;
  1474. text-align: center;
  1475. line-height: 40px;
  1476. margin: 24px auto;
  1477. }
  1478. }
  1479. }
  1480. }
  1481. </style>