question_report.vue 14 KB

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