Browse Source

feat: 随机一练

xuqiaoying 2 years ago
parent
commit
b11753fa43

+ 11 - 0
pages.json

@@ -716,6 +716,17 @@
 						"bounce": "none"
 					}
 				}
+			},
+			{
+				"path": "randomPractice/index",
+				"style": {
+					"navigationBarTitleText": "随机练习",
+					"navigationStyle": "custom", // 隐藏系统导航栏
+					"app-plus": {
+						"titleNView": false, //禁用原生导航栏 
+						"bounce": "none"
+					}
+				}
 			}
 		]
 		 

+ 6 - 1
pages/questionBank/index.vue

@@ -72,7 +72,7 @@
 						<!-- 按钮 -->
 						<view class="study_btns">
 							<view class="exam_word intos" @click.stop="toDailyPractice(item)">每日一练</view>
-							<view class="exam_word intos">随机联系</view>
+							<view class="exam_word intos" @click.stop="toRandomPractice(item)">随机联系</view>
 							<view class="exam_word intos" @click="studyques(item,index)">章节练习</view>
 						</view>
 					</view>
@@ -149,6 +149,11 @@ export default {
 				url: '/pages2/dailyPractice/index?goodsId=' + item.goodsId + '&orderGoodsId=' + item.orderGoodsId
 			})
 		},
+		toRandomPractice(item) {
+			uni.navigateTo({
+				url: '/pages2/randomPractice/index?goodsId=' + item.goodsId + '&orderGoodsId=' + item.orderGoodsId
+			})
+		},
 		// 进入练习
 		studyques(item,index){
 			let sysTime = this.$method.timest()

+ 61 - 9
pages2/bank/questionBank.vue

@@ -918,13 +918,15 @@ export default {
       examData: {},
       orderGoodsId: "",
       cgType: 0, //对应设计稿弹窗编码
-      courseId: '',
-      entryType: '', // 进入做题页面的入口类型,daily-每日一练进来,其他的-题库做题进入
+      // courseId: '',
+      entryType: '', // 进入做题页面的入口类型,daily-每日一练进来,random-随机练习, 其他的-题库做题进入
+      bankNum: 5, // 随机练习的题目数量
     };
   },
   async onLoad(option) {
     this.entryType = option.entryType || ''
-    this.courseId = option.courseId
+    this.bankNum = option.bankNum
+    // this.courseId = option.courseId || ''
     this.orderGoodsId = option.orderGoodsId || 0;
     this.current = +option.current || 0;
     this.id = option.id;
@@ -970,11 +972,16 @@ export default {
         this.lastTime--;
       }, 1000);
     } else {
+      if (this.entryType == 'random') {
+        this.bankType = 1 // 随机练习全部都是练习类型
+        this.randomQuestionList()
+      } else {
       //进入页面
       await this.bankExam();
       // 请求题目列表
       this.goodsQuestionList();
     }
+    }
   },
   onUnload() {
     if (this.isSubmit) {
@@ -1337,6 +1344,7 @@ export default {
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
           type: 1, // 题库试卷传1
+          doMode: this.entryType == 'random' ? 2 : 1, // 做题模式 1章卷 2随机练习
         })
         .then((res) => {});
     },
@@ -1493,7 +1501,8 @@ export default {
           goodsId: this.goodsId,
           totalQuestionNum: questionList,
           allQuestionNum: this.questionList.length,
-          courseId: this.courseId,
+          doMode: this.entryType == 'random' ? 2 : 1, // 做题模式 1章卷 2随机练习
+          // courseId: this.courseId,
           // type: ''
         })
         .then((res) => {
@@ -1526,6 +1535,43 @@ export default {
     hideDialog() {
       this.showDialog = false;
     },
+    // 请求随机练习题目列表
+    randomQuestionList() {
+      this.$http({
+        url: '/bank/exam/temp',
+        method: 'post',
+        data: {
+          goodsId: this.goodsId,
+          orderGoodsId: this.orderGoodsId,
+          number: this.bankNum
+        }
+      }).then((res) => {
+        if(res.data.code == 200) {
+          this.examData = res.data.data || {}
+          this.id = this.examData.examId
+          if (!this.examData.questionList.length) {
+            this.hideDialog();
+            uni.showModal({
+              showCancel: false,
+              content: "该试卷暂无题目",
+              success: (k) => {
+                if (k.confirm) {
+                  this.isSubmit = true;
+                  uni.navigateBack();
+                }
+              },
+            });
+            return;
+          }
+          this.dataAnlyze(this.examData.questionList || [])
+        } else {
+          this.$u.toast(res.data.msg)
+          setTimeout(() => {
+            uni.navigateBack()
+          }, 2000)
+        }
+      })
+    },
     /**
      * 请求题目列表 app/common/bank/question/list
      */
@@ -1571,7 +1617,12 @@ export default {
             }, 1000);
           } else {
           }
-          res.data.data.forEach((item, index) => {
+          this.dataAnlyze(res.data.data)
+        });
+    },
+    dataAnlyze(datas = []) {
+      console.log('datas:', datas)
+      datas.forEach((item, index) => {
             // if (typeof item.jsonStr == 'string') {
             item.jsonStr = JSON.parse(item.jsonStr);
 
@@ -1697,12 +1748,11 @@ export default {
             // }
           });
 
-          this.questionList = res.data.data;
+          this.questionList = datas;
 
           this.lastCount = this.questionList.length;
           this.examRecord();
           this.getCollectInfo(this.current);
-        });
     },
     /**
      * @param {Object} e单选点击
@@ -2148,7 +2198,7 @@ export default {
       //交卷
       this.$api
         .examRecordEdit({
-          courseId: this.courseId,
+          // courseId: this.courseId,
           examId: this.id,
           goodsId: this.goodsId,
           reportStatus: reportStatus,
@@ -2193,7 +2243,7 @@ export default {
                   "&id=" +
                   this.recordId +
                   "&orderGoodsId=" +
-                  this.orderGoodsId + '&entryType=daily',
+                  this.orderGoodsId + '&entryType=' + this.entryType,
               });
             }, 1000);
           }
@@ -2208,6 +2258,7 @@ export default {
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
           type: 1, // 题库试卷传1
+          doMode: this.entryType == 'random' ? 2 : 1, // 做题模式 1章卷 2随机练习
         })
         .then((res) => {});
     },
@@ -2242,6 +2293,7 @@ export default {
             questionId: this.questionList[index].questionId,
             goodsId: this.goodsId || "",
             orderGoodsId: this.orderGoodsId,
+            doMode: this.entryType == 'random' ? 2 : 1, //做题模式 1章卷 2随机练习
           })
           .then((res) => {
             if (res.data.code == 200) {

+ 3 - 0
pages2/bank/questionBankContinue.vue

@@ -891,6 +891,7 @@ export default {
             questionId: this.questionList[index].questionId,
             goodsId: this.goodsId || "",
             orderGoodsId: this.orderGoodsId,
+            doMode: 1, //做题模式 1章卷 2随机练习
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -1350,6 +1351,7 @@ export default {
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
           type: 1, // 题库试卷传1
+          doMode: 1, // 做题模式 1章卷 2随机练习
         })
         .then((res) => {});
     },
@@ -1610,6 +1612,7 @@ export default {
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
           type: 1, // 题库试卷传1
+          doMode: 1, // 做题模式 1章卷 2随机练习
         })
         .then((res) => {});
     },

+ 1 - 0
pages2/bank/questionBankExplainDetail.vue

@@ -1032,6 +1032,7 @@ export default {
             examId: this.id,
             questionId: this.questionList[index].questionId,
             goodsId: this.goodsId || "",
+            doMode: 1, //做题模式 1章卷 2随机练习
           })
           .then((res) => {
             if (res.data.code == 200) {

+ 3 - 3
pages2/bank/question_report.vue

@@ -79,7 +79,7 @@
 					<view class="btnACs">全部解析</view>
 				</navigator>
 				<view class="btnACs" v-if="entryType != 'daily'" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
-				<view class="btnACs" v-if="entryType != 'daily' && nextExamId" @click="backBank">继续做题</view>
+				<view class="btnACs" v-if="(entryType != 'daily' && entryType != 'random') && nextExamId" @click="backBank">继续做题</view>
 			</view>
 		</view>
 		<view class="bottom">
@@ -244,7 +244,7 @@ export default {
 								context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
 								context1.setFillStyle('#999999');
 								context1.setFontSize(caculateX * 20);
-								context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
+								context1.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
 								context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
 								context1.stroke();
 								context1.draw();
@@ -290,7 +290,7 @@ export default {
 								context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
 								context3.setFillStyle('#999999');
 								context3.setFontSize(caculateX * 20);
-								context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
+								context3.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
 								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);
 								context3.stroke();
 								context3.draw();

+ 0 - 3
pages2/dailyPractice/index.vue

@@ -105,9 +105,6 @@ export default {
                 method: 'get',
                 data: {
                     goodsId: this.goodsId,
-                    // chapterExamId: this.dayExamDetail.chapterExamId || 0,
-                    // moduleExamId: this.dayExamDetail.moduleExamId || 0,
-                    // examId: this.dayExamDetail.examId,
                 }
             }).then((res) => {
                 if (res.data.code == 200) {

+ 81 - 0
pages2/randomPractice/index.vue

@@ -0,0 +1,81 @@
+<template>
+    <view class="random_practice">
+        <nav-bar title="随机练习"></nav-bar>
+        <view class="contents">
+            <view>试卷情况</view>
+            <view>本题库共{{ questionNum.totalNum || 0 }}道题,剩余800题,你已做{{ questionNum.doNum || 0}}</view>
+            <view class="number_crad">
+                <view>选择做题数量</view>
+                <view v-for="(item, index) in numberLists" :key="index" class="items" @click="changeNum(item)">
+                    {{item}}
+                </view>
+                <view class="starts" @click="startPractice()">
+                    开始做题
+                </view>
+            </view>
+            
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            goodsId: '',
+            orderGoodsId: '',
+            numberLists: [5, 10, 15, 20, 50, 100],
+            number: 5,
+            questionNum: {}
+        }
+    },
+    onLoad(option) {
+        this.goodsId = option.goodsId
+        this.orderGoodsId = option.orderGoodsId
+    },
+    onShow() {
+        this.getQuestionTempNum()
+    },
+    methods: {
+        changeNum(item) {
+            console.log(item);
+            this.number = item
+        },
+        getQuestionTempNum() {
+            this.$http({
+                url: `/goods/bank/questionTempNum/${this.orderGoodsId}`,
+                method: 'get',
+            }).then((res) => {
+                if (res.data.code == 200) {
+                    this.questionNum = res.data.data || {}
+                }
+            })
+        },
+        startPractice() {
+            uni.navigateTo({
+                url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=""' + '&goodsid=' + this.goodsId 
+                +'&moduleId=0' + '&chapterId=0' + '&entryType=random' + '&bankNum=' + this.number
+            })
+        }
+    },
+}
+</script>
+
+<style lang="scss">
+.number_crad {
+    .items {
+        margin-bottom: 28rpx;
+    }
+    .starts {
+        width: 646rpx;
+        height: 96rpx;
+        line-height: 96rpx;
+        text-align: center;
+        color: #fff;
+        font-size: 32rpx;
+        font-weight: bold;
+        background: #3577E8;
+        border-radius: 24rpx;
+    }
+}
+</style>