question_report.vue 13 KB

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