question_report.vue 16 KB

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