question_report.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <view>
  3. <nav-bar title="试卷报告"></nav-bar>
  4. <view
  5. :class="
  6. reportStatus == 0
  7. ? 'redBtn'
  8. : reportStatus == 1
  9. ? 'greenBtn'
  10. : 'disNone'
  11. "
  12. v-if="reportStatus !== null"
  13. >
  14. {{
  15. reportStatus == 0 ? "测试未通过" : reportStatus == 1 ? "测试通过" : ""
  16. }}
  17. </view>
  18. <view class="top">
  19. <view class="box">
  20. <view class="left">
  21. <view
  22. >{{
  23. (
  24. (rightQuestionNum / (rightQuestionNum + doWrongQuestionNum)) *
  25. 100
  26. ).toFixed(0)
  27. }}%</view
  28. >
  29. <view>正确率</view>
  30. <view>不含简答/案例题</view>
  31. </view>
  32. <view class="right">
  33. <view class="flex up">
  34. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  35. <image
  36. class="right_num"
  37. src="/static/right_num.png"
  38. mode="widthFix"
  39. ></image>
  40. <view class="text">正确题数</view>
  41. <text class="green">{{ rightQuestionNum }}</text>
  42. </view>
  43. <view class="flex up">
  44. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  45. <image
  46. class="right_num"
  47. src="/static/out_num.png"
  48. mode="widthFix"
  49. ></image>
  50. <view class="text">少选题数</view>
  51. <text class="yellow">{{ lessQuestionNum }}</text>
  52. </view>
  53. <view class="flex down">
  54. <!-- <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon> -->
  55. <image
  56. class="right_num"
  57. src="/static/wrong_num.png"
  58. mode="widthFix"
  59. ></image>
  60. <view class="text">错误题数</view>
  61. <text class="red">{{ doWrongQuestionNum }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="dis_fst">
  66. <navigator
  67. v-if="doWrongQuestionNum != 0"
  68. :url="
  69. '/pages2/bank/questionBankWrongExplain?recordId=' +
  70. reportdata.recordId +
  71. '&id=' +
  72. reportdata.examId +
  73. '&courseType=2'
  74. "
  75. >
  76. <view class="btnACs">错题解析</view>
  77. </navigator>
  78. <navigator
  79. :url="
  80. '/pages2/bank/questionBankAllExplain?id=' +
  81. reportdata.examId +
  82. '&goodsid=' +
  83. reportdata.goodsId +
  84. '&moduleId=' +
  85. reportdata.moduleId +
  86. '&chapterId=' +
  87. reportdata.chapterId +
  88. '&recordId=' +
  89. reportdata.recordId +
  90. '&courseType=2'
  91. "
  92. >
  93. <view class="btnACs">全部解析</view>
  94. </navigator>
  95. <view
  96. class="btnACs"
  97. @click="
  98. doRepeat(
  99. reportdata.examId,
  100. reportdata.goodsId,
  101. reportdata.moduleId,
  102. reportdata.chapterId
  103. )
  104. "
  105. >重新做题</view
  106. >
  107. <!-- <view class="btnACs" v-if="nextExamId" @click="backBank">继续做题</view> -->
  108. </view>
  109. </view>
  110. <view class="bottom">
  111. <view class="circle-wrap">
  112. <view class="circle-list">
  113. <view class="item" v-show="totalScore">
  114. <view class="title">
  115. 试卷得分
  116. <text>(不含简答和案例题)</text>
  117. </view>
  118. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  119. </view>
  120. <view class="item" v-show="examTime">
  121. <view class="title">答题时长</view>
  122. <canvas canvas-id="Canvas2"></canvas>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <view v-if="courseList.length" class="course_list">
  128. <view class="titles">
  129. <image class="code" src="@/static/learn/act_icon.png"></image>
  130. <text class="title">推荐课程</text>
  131. </view>
  132. <view
  133. class="list_item"
  134. v-for="(item, index) in courseList"
  135. :key="index"
  136. @click="toBuy(item)"
  137. >
  138. <view class="course_content">
  139. <view class="c_title">{{ item.goodsName }}</view>
  140. <view class="c_downs">
  141. <view class="img">
  142. <image :src="$method.splitImgHost(item.coverUrl, true)"></image>
  143. <view class="time" v-if="item.year">{{
  144. item.year ? item.year : ""
  145. }}</view>
  146. </view>
  147. <view class="text">
  148. <view class="desc">
  149. <view class="left">
  150. <text class="mon_t">¥ {{ item.standPrice }}</text>
  151. <!-- <text class="sale">/限时优惠</text> -->
  152. <text v-if="item.linePrice" class="sale"> ¥ </text>
  153. <text v-if="item.linePrice" class="price_line"
  154. >&nbsp;{{ item.linePrice }}</text
  155. >
  156. </view>
  157. <view class="right">
  158. <view class="regiser_row" v-if="!hideBuyState">立即购买</view>
  159. </view>
  160. </view>
  161. <view v-if="item.buyUserNum" class="joins">
  162. <!-- <image class="people" src="/static/index/people.png"></image> -->
  163. <!-- 为0时,不显示 -->
  164. <view class="people">{{ item.buyUserNum }}人参与</view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. </template>
  173. <script>
  174. import { mapGetters } from "vuex";
  175. export default {
  176. data() {
  177. return {
  178. id: "",
  179. hideBtns: false,
  180. examData: {},
  181. examId: "",
  182. context1: null,
  183. context2: null,
  184. rightQuestionNum: "",
  185. // doWrongQuestionNum:'',
  186. score: "",
  187. totalScore: "",
  188. doTime: "",
  189. examTime: "",
  190. reportStatus: null,
  191. lessQuestionNum: 0,
  192. courseList: [],
  193. pageNum: 1,
  194. pageSize: 10,
  195. total: 0,
  196. recordId: "",
  197. reportdata: {},
  198. examType: 0, // 3-模块,1-章,2-节
  199. orderGoodsId: "",
  200. };
  201. },
  202. onPullDownRefresh() {
  203. this.pageNum = 1;
  204. this.courseList = [];
  205. this.getcourList();
  206. // this.timer = setTimeout(function() {
  207. // uni.stopPullDownRefresh()
  208. // }, 500)
  209. },
  210. onReachBottom() {
  211. console.log(this.total, "total");
  212. console.log(this.courseList.length, "length");
  213. if (this.courseList.length < this.total) {
  214. this.pageNum++;
  215. this.getcourList();
  216. }
  217. },
  218. onUnload() {},
  219. computed: {
  220. ...mapGetters(["userInfo", "hideBuyState"]),
  221. doWrongQuestionNum() {
  222. let value =
  223. this.reportdata.totalQuestionNum -
  224. this.reportdata.rightQuestionNum -
  225. this.reportdata.lessQuestionNum;
  226. return value > 0 ? value : 0;
  227. },
  228. },
  229. async onShow() {
  230. this.pageNum = 1;
  231. this.courseList = [];
  232. this.getcourList();
  233. },
  234. async onLoad(option) {
  235. this.examType = option.type;
  236. this.recordId = option.recordId;
  237. this.examId = option.examId;
  238. this.orderGoodsId = option.orderGoodsId;
  239. // this.examTime = option.examTime;
  240. // this.doTime = option.doTime;
  241. // this.reportStatus = option.reportStatus;
  242. // this.rightQuestionNum = +option.rightQuestionNum;
  243. // this.doWrongQuestionNum = +option.doWrongQuestionNum;
  244. // this.score = +option.score;
  245. // this.lessQuestionNum = option.lessQuestionNum;
  246. // this.totalScore = +option.totalScore;
  247. // this.hideBtns = Boolean(option.hideBtns);
  248. this.bankReport();
  249. },
  250. methods: {
  251. getCanvas() {
  252. this.$method.getCanvas(this).then(({ systemInfo }) => {
  253. var caculateX = systemInfo.screenWidth / 750;
  254. if (this.totalScore) {
  255. var context1 = uni.createCanvasContext("Canvas1");
  256. this.context1 = context1;
  257. context1.setStrokeStyle("#EEEEEE");
  258. context1.setLineWidth(caculateX * 20);
  259. context1.arc(
  260. caculateX * 90,
  261. caculateX * 90,
  262. caculateX * 80,
  263. 0,
  264. 2 * Math.PI,
  265. true
  266. );
  267. context1.stroke();
  268. context1.beginPath();
  269. context1.setStrokeStyle("#32D74B");
  270. context1.setFillStyle("#32D74B");
  271. context1.setTextAlign("center");
  272. context1.setTextBaseline("middle");
  273. context1.setLineCap("round");
  274. context1.setFontSize(caculateX * 64);
  275. context1.fillText(
  276. this.score,
  277. caculateX * 90,
  278. caculateX * 90,
  279. caculateX * 180
  280. );
  281. context1.setFillStyle("#999999");
  282. context1.setFontSize(caculateX * 20);
  283. context1.fillText(
  284. `满分${this.totalScore}`,
  285. caculateX * 90,
  286. caculateX * 130,
  287. caculateX * 180
  288. );
  289. context1.arc(
  290. caculateX * 90,
  291. caculateX * 90,
  292. caculateX * 80,
  293. -Math.PI / 2,
  294. -Math.PI / 2 + (this.score / this.totalScore) * 2 * Math.PI,
  295. false
  296. );
  297. context1.stroke();
  298. context1.draw();
  299. }
  300. if (this.examTime) {
  301. var context2 = uni.createCanvasContext("Canvas2");
  302. this.context2 = context2;
  303. context2.setStrokeStyle("#EEEEEE");
  304. context2.setLineWidth(caculateX * 20);
  305. context2.arc(
  306. caculateX * 90,
  307. caculateX * 90,
  308. caculateX * 80,
  309. 0,
  310. 2 * Math.PI,
  311. true
  312. );
  313. context2.stroke();
  314. context2.beginPath();
  315. context2.setStrokeStyle("#007AFF");
  316. context2.setFillStyle("#007AFF");
  317. context2.setTextAlign("center");
  318. context2.setTextBaseline("middle");
  319. context2.setLineCap("round");
  320. context2.setFontSize(caculateX * 64);
  321. context2.fillText(
  322. `${this.doTime}'`,
  323. caculateX * 90,
  324. caculateX * 90,
  325. caculateX * 180
  326. );
  327. context2.setFillStyle("#999999");
  328. context2.setFontSize(caculateX * 20);
  329. context2.fillText(
  330. `限时${this.examTime}'`,
  331. caculateX * 90,
  332. caculateX * 130,
  333. caculateX * 180
  334. );
  335. context2.arc(
  336. caculateX * 90,
  337. caculateX * 90,
  338. caculateX * 80,
  339. -Math.PI / 2,
  340. -Math.PI / 2 + (this.doTime / this.examTime) * 2 * Math.PI,
  341. false
  342. );
  343. context2.stroke();
  344. context2.draw();
  345. }
  346. });
  347. },
  348. getcourList() {
  349. this.$http({
  350. url: "/apply/recommend/goodsList",
  351. method: "post",
  352. data: {
  353. examId: this.examId,
  354. pageNum: this.pageNum,
  355. pageSize: this.pageSize,
  356. },
  357. }).then((res) => {
  358. if (res.data.code == 200) {
  359. this.courseList.push(...(res.data.rows || []));
  360. this.total = res.data.total;
  361. }
  362. });
  363. },
  364. toBuy(item) {
  365. // if (item.goodsType == 1) {
  366. // uni.navigateTo({
  367. // url: '/pages3/course/detail?id='+item.goodsId
  368. // })
  369. // } else
  370. if (item.goodsType == 2) {
  371. uni.navigateTo({
  372. url: "/pages2/bank/detail?id=" + item.goodsId,
  373. });
  374. } else {
  375. // /pages5/liveDetail/index
  376. uni.navigateTo({
  377. url:
  378. "/pages3/course/detail?id=" +
  379. item.goodsId +
  380. "&goodsType=" +
  381. item.goodsType,
  382. });
  383. }
  384. },
  385. bankReport() {
  386. this.$api.bankReportData(this.recordId).then((res) => {
  387. this.reportdata = res.data.data;
  388. // console.log('reportdata:', this.reportdata)
  389. const {
  390. examTime,
  391. doTime,
  392. reportStatus,
  393. rightQuestionNum,
  394. performance,
  395. lessQuestionNum,
  396. totalScore,
  397. } = this.reportdata;
  398. this.examTime = examTime;
  399. this.doTime = doTime;
  400. this.reportStatus = reportStatus;
  401. this.rightQuestionNum = rightQuestionNum;
  402. // this.doWrongQuestionNum = +option.doWrongQuestionNum;
  403. this.score = performance;
  404. this.lessQuestionNum = lessQuestionNum;
  405. this.totalScore = totalScore;
  406. this.getCanvas();
  407. });
  408. },
  409. /**
  410. * 去做题
  411. */
  412. async doRepeat(examId, goodsId, moduleId = 0, chapterId = 0) {
  413. let count = await this.bankRecordDoNum();
  414. let answerNum = await this.getExamDetail(examId);
  415. //超过答题次数
  416. if (answerNum > 0 && count >= answerNum) {
  417. this.$u.toast("该试卷只能答题" + answerNum + "次!");
  418. return;
  419. }
  420. // answerNum==0没有答题次数限制
  421. if (answerNum == 0 || (answerNum - count > 0 && answerNum > 0)) {
  422. const { courseId, gradeId, sectionId } = this.reportdata;
  423. uni.navigateTo({
  424. url:
  425. "/pages2/class/questionBank?courseId=" +
  426. courseId +
  427. "&gradeId=" +
  428. gradeId +
  429. "&isFromVideo=1&id=" +
  430. examId +
  431. "&goodsid=" +
  432. goodsId +
  433. "&moduleId=" +
  434. moduleId +
  435. "&chapterId=" +
  436. chapterId +
  437. "&sectionId=" +
  438. sectionId +
  439. "&orderGoodsId=" +
  440. this.orderGoodsId +
  441. "&type=" +
  442. this.examType +
  443. "&learning=" +
  444. this.reportStatus,
  445. });
  446. }
  447. },
  448. /**
  449. * 获取试卷已做的次数
  450. */
  451. bankRecordDoNum() {
  452. return new Promise((resolve) => {
  453. this.$api
  454. .bankRecordDoNum({
  455. goodsId: this.reportdata.goodsId,
  456. gradeId: this.reportdata.gradeId,
  457. chapterId: this.reportdata.chapterId || 0,
  458. courseId: this.reportdata.courseId,
  459. moduleId: this.reportdata.moduleId || 0,
  460. examId: this.reportdata.examId,
  461. })
  462. .then((res) => {
  463. resolve(res.data.data);
  464. });
  465. });
  466. },
  467. /**
  468. * @param {Object} exam_id
  469. * 获取试卷可以做的次数
  470. */
  471. getExamDetail(exam_id) {
  472. return new Promise((resolve) => {
  473. this.$api.getExamDetail(exam_id).then((res) => {
  474. resolve(res.data.data.answerNum);
  475. });
  476. });
  477. },
  478. },
  479. };
  480. </script>
  481. <style>
  482. page {
  483. background-color: #eaeef1;
  484. }
  485. </style>
  486. <style lang="scss" scope>
  487. @import "../../pages5/examReport/indexCourseList.scss";
  488. .disNone {
  489. display: none;
  490. }
  491. .greenBtn {
  492. margin: 16rpx 16rpx 0;
  493. height: 80rpx;
  494. line-height: 80rpx;
  495. text-align: center;
  496. background-color: #f7fff8;
  497. border-radius: 16rpx;
  498. color: #34c759;
  499. font-weight: bold;
  500. font-size: 30rpx;
  501. }
  502. .redBtn {
  503. margin: 16rpx 16rpx 0;
  504. height: 80rpx;
  505. line-height: 80rpx;
  506. text-align: center;
  507. background-color: #fff3f2;
  508. border-radius: 16rpx;
  509. color: #ff3b30;
  510. font-weight: bold;
  511. font-size: 30rpx;
  512. }
  513. .dis_fst {
  514. margin-top: 40rpx;
  515. display: flex;
  516. align-items: center;
  517. justify-content: space-around;
  518. }
  519. .btnACs {
  520. height: 48rpx;
  521. width: 160rpx;
  522. text-align: center;
  523. line-height: 48rpx;
  524. border: 1rpx solid #007aff;
  525. border-radius: 16rpx;
  526. color: #007aff;
  527. font-size: 24rpx;
  528. }
  529. .top {
  530. margin: 16rpx 16rpx 0;
  531. border-radius: 16rpx;
  532. padding: 40rpx 24rpx 16rpx;
  533. background: #fff;
  534. .title {
  535. font-size: 32rpx;
  536. font-weight: bold;
  537. color: #333333;
  538. }
  539. .desc {
  540. margin-top: 20rpx;
  541. font-size: 24rpx;
  542. color: #999999;
  543. }
  544. .box {
  545. margin-top: 30rpx;
  546. display: flex;
  547. .left {
  548. width: 250rpx;
  549. height: 176rpx;
  550. background: #f5f5f5;
  551. border-radius: 16rpx;
  552. display: flex;
  553. align-items: center;
  554. justify-content: center;
  555. flex-direction: column;
  556. margin-right: 16rpx;
  557. view {
  558. text-align: center;
  559. &:nth-of-type(1) {
  560. font-size: 60rpx;
  561. font-weight: bold;
  562. color: #007aff;
  563. }
  564. &:nth-of-type(2) {
  565. font-size: 32rpx;
  566. font-weight: bold;
  567. color: #333333;
  568. }
  569. &:nth-of-type(3) {
  570. font-size: 24rpx;
  571. color: #999999;
  572. }
  573. }
  574. }
  575. .right {
  576. flex: 1;
  577. display: flex;
  578. flex-direction: column;
  579. justify-content: space-between;
  580. .flex {
  581. background: #f5f5f5;
  582. display: flex;
  583. height: 80rpx;
  584. align-items: center;
  585. padding: 0 40rpx;
  586. border-radius: 16rpx;
  587. image {
  588. margin-right: 28rpx;
  589. &.right_num {
  590. width: 26rpx;
  591. }
  592. &.out_num {
  593. width: 38rpx;
  594. }
  595. &.wrong_num {
  596. width: 30rpx;
  597. }
  598. }
  599. .text {
  600. flex: 1;
  601. font-size: 30rpx;
  602. color: #666666;
  603. }
  604. text {
  605. font-size: 48rpx;
  606. color: #e12626;
  607. &.red {
  608. color: #ff3b30;
  609. }
  610. &.green {
  611. color: #36c75a;
  612. }
  613. &.yellow {
  614. color: #ffc53d;
  615. }
  616. }
  617. }
  618. }
  619. }
  620. }
  621. .bottom {
  622. .circle-wrap {
  623. .circle-list {
  624. display: flex;
  625. .item {
  626. padding: 20rpx;
  627. border-radius: 16rpx;
  628. background: #fff;
  629. margin: 16rpx;
  630. flex: 1;
  631. .title {
  632. font-weight: bold;
  633. font-size: 30rpx;
  634. line-height: 24rpx;
  635. color: #333333;
  636. text {
  637. font-size: 20rpx;
  638. color: #999999;
  639. }
  640. }
  641. canvas {
  642. margin: 36rpx auto 0;
  643. width: 180rpx;
  644. height: 180rpx;
  645. }
  646. .text {
  647. text-align: center;
  648. margin-top: 16rpx;
  649. font-size: 24rpx;
  650. color: #333333;
  651. }
  652. }
  653. }
  654. }
  655. }
  656. </style>